Zero-dependency, cross-platform N-dimensional Tensor library for MoonBit inference and numerical computing
moon add matrixlt/tensorlet a = @tensor.Tensor::from_f32_array([2, 3], [1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
let b = a.transpose([1, 0]).contiguous()
let c = b.reshape([1, -1])
let pool = @tensor.BufferPool::new()
let scratch = pool.acquire_f32(1024)
pool.release_f32(scratch)pub struct Tensor {
data : TensorData
offset : Int
shape : Array[Int]
strides : Array[Int]
dtype : DType
}fn Tensor::reshape(self : Tensor, target : Array[Int], allowzero? : Bool) -> Tensor raise TensorErrorpub(all) enum TensorData {
F32(FixedArray[Float])
F64(FixedArray[Double])
I64(FixedArray[Int64])
I32(FixedArray[Int])
Bool(FixedArray[Bool])
}fn broadcast_strides(src_shape : Array[Int], src_strides : Array[Int], target_shape : Array[Int]) -> Array[Int] raise TensorErrorInstall
Download zipZero-dependency, cross-platform N-dimensional Tensor library for MoonBit inference and numerical computing