2 releases

0.1.1 Mar 21, 2024
0.1.0 Mar 9, 2024

#25 in #auto-diff

Download history 1/week @ 2024-07-17 16/week @ 2024-07-24 1/week @ 2024-09-18 9/week @ 2024-09-25 2/week @ 2024-10-02

74 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.5–1MB
~21K SLoC