PyTorch-like tensor operations implemented in MoonBit.
-
Add
tonyfettes/torch
module as a dependenciesmoon add tonyfettes/torch
-
Import
tonyfettes/torch
package.{ "import": { "tonyfettes/torch" } }
-
Use it in your package
fn main { let tensor = @torch.tensor(1.0) println("\{tensor}") }
- Monofy Tensor for every dtype (
bool
,i8
,i16
,i32
,f32
,f64
) - PyTorch tensor operations
-
torch.transpose
-
torch.argmax
-
- PyTorch module
-
torch.nn.init
-
torch.nn.init.uniform_
-
torch.nn.init.normal_
-
torch.nn.init.xavier_uniform_
-
- Negative index support for view, etc.
- PyTorch functional module
-
torch.nn.functional.rms_norm
-
torch.nn.functional.silu
-
- Module/model saving and loading
- Static JSON format.
- Dynamic JSON format. "Dynamic" means saving/loading a trait object (
Module
here) - Binary format
- Computation graph optimization
-
Get
operation fusing - Make
Sum
operate onArray[Tensor]
directly - Eliminate
Cat(Get(...))
-
- Loss
- KL-divergence
-
torch.nn.NLLLoss
- Distributions
- re-parametrization trick
-
entropy
-
Normal::log_prob
-
Adam*
optimizers - WASM-SIMD
v128
-
add
-
mul
-
General Matrix Multiplymatmul
-