Skip to main content

Crate incin_macros

Crate incin_macros 

Source
Expand description

§Incin Macros

incin-macros provides procedural macros that form the ergonomic frontend for the Incin framework. Because Incin relies heavily on compile-time type verification using typenum, manipulating raw types can be extremely verbose (e.g., Prod<UInt<UTerm, B1>, ...>). These macros hide that complexity, allowing developers to write clean, intuitive syntax while the macros generate the underlying type boundaries.

§Provided Macros

  • s![...]: Defines a shape directly from integer literals (e.g., s![1, 3, 224, 224]).
  • i![...]: Defines runtime indexing/slicing arguments for tensors (e.g., i![1..3, .., -1]).
  • idx![...]: Defines an advanced type-level slicing target.
  • #[module]: Derives neural network module traits automatically for structs, similar to #[derive(Module)] but specifically tailored for Incin.
  • model!("model.onnx", Name): Compiles an ONNX model file into a fully-typed Rust module structurally matching the ONNX graph.
  • import_model!("model.onnx", Name): Compiles an ONNX model file into a fully-typed Rust module structurally matching the ONNX graph.

Macros§

axis
Build an arbitrary static or runtime axis selector.
i
Build runtime indexing and slicing expressions for Tensor::get.
idx
A macro to construct index and slicing arguments for tensor reshaping and subsetting.
import_model
Attribute-style entry: #[distributed_main] selects and wraps a process-rank main.
model
Expands a supported .onnx graph or imports .safetensors metadata.
s
A macro to construct static Tensor shapes ergonomically in the type system.
shape
Builds a Tensor directly from a literal, inferring shape and (unless told otherwise) dtype from how it’s written - the macro analogue of vec![...].
tensor
Procedural macro tensor! building a typed tensor literal with static shape checking.

Attribute Macros§

module
The #[module] attribute automatically derives composable module capabilities for custom neural network structs.