2 releases

0.1.1 Mar 21, 2024
0.1.0 Mar 9, 2024

#888 in Machine learning

Download history 123/week @ 2024-03-04 31/week @ 2024-03-11 127/week @ 2024-03-18 38/week @ 2024-04-01

215 downloads per month

MIT/Apache

170KB
4K SLoC

zyx-derive

This crate contains procedural macros for zyx.

Macro Module automatically implements IntoIterator<Item = &Tensor> for your module, so that you can use it in backpropagation and save it to disk.

use zyx_core::backend::Backend;
use zyx_core::tensor::Tensor;

#[derive(Module)]
struct MyNet<B: Backend> {
    b: Tensor<B>,
    w: Tensor<B>,
}

impl<B: Backend> MyNet<B> {
    fn forward(&self, x: &Tensor<B>) -> Tensor<B> {
        x.dot(self.w) + self.b
    }
}

For README and source code, please visit github.

For more details, there is a book.

Features

  • std - enables zyx-core/std

lib.rs:

zyx-derive

This crate contains procedural macros for zyx.

Macro Module automatically implements IntoIterator<Item = &Tensor> for your module, so that you can use it in backpropagation and save it to disk.

use zyx_core::backend::Backend;
use zyx_core::tensor::Tensor;
use zyx_derive::Module;

#[derive(Module)]
struct MyNet<B: Backend> {
    b: Tensor<B>,
    w: Tensor<B>,
}

impl<B: Backend> MyNet<B> {
    fn forward(&self, x: &Tensor<B>) -> Tensor<B> {
        x.dot(&self.w) + &self.b
    }
}

For README, quick tutorial and source code, please visit https://www.github.com/zk4x/zyx.

For more details, there is a book.

Dependencies

~0.6–1MB
~23K SLoC