Crates.io | flashlight_tensor |
lib.rs | flashlight_tensor |
version | 0.4.5 |
created_at | 2025-04-19 13:52:39.784837+00 |
updated_at | 2025-07-07 17:14:46.79754+00 |
description | gpu/cpu tensor library focused around matrix and neural network operations |
homepage | https://github.com/Bejmach/flashlight_tensor |
repository | https://github.com/Bejmach/flashlight_tensor |
max_upload_size | |
id | 1640672 |
size | 484,483 |
Tensor library written in pure rust, designed mostly for matrix operations
project not related to similarly named flashlight. The name was coincidental and chosen independently.
[dependencies]
flashlight_tensor = "0.4.5"
# Experimental(Not everything documented and working. Use at your own risk)
flashlight_tensor = { git = "https://github.com/Bejmach/flashlight_tensor"}
For gpu usage go to examples on github
use flashlight_tensor::prelude::*;
fn main(){
//2 rows, 2 collumns, fill with 1.0
let a: Tensor<f32> = Tensor::fill(1.0, &[2, 2]);
}
Run tests with:
cargo test
bug fixes
let mut gpu_data = GpuData::new();
gpu_data.disable_shapes();
let sample = Sample::from_data(vec!{Tensor::fill(1.0, &[2, 2])}, vec!{1.0}, &[2, 2]);
gpu_data.append(sample);
let mut buffers = GpuBuffers::init(1, MemoryMetric::GB, &mut gpu_data, 0).await;
buffers.set_shader(&GpuOperations::Add);
buffers.prepare();
let full_gpu_output: Vec<Tensor<f32>> = buffers.run().await;
New way also has integrated chunking, so if data you try to process it bigger than max buffer size, then it will run the operation in chunks and merge data at the end
You also dont need to set output size for sample. GpuRunner handles that
let mut runner: GpuRunner = GpuRunner::init(1, MemoryMetric::GB);
let sample = Sample::from_data(vec!{Tensor::fill(1.0, &[2, 2])}, vec!{1.0}, &[]);
runner.append(sample);
let output_data: Vec<Tensor<f32>> = runner.add().await;