Initial commit

This commit is contained in:
redclawsystems
2026-03-04 00:08:42 +00:00
commit 4d88dc0584
4449 changed files with 1556714 additions and 0 deletions
@@ -0,0 +1,40 @@
//! Activation operator code generation.
use proc_macro2::TokenStream;
use quote::quote;
use crate::ir::Node;
use crate::error::Result;
use super::sanitize_name;
/// Generate softmax operation.
pub fn generate_softmax(node: &Node) -> Result<TokenStream> {
let input = &node.inputs[0];
let output = &node.outputs[0];
let in_ident = quote::format_ident!("{}", sanitize_name(input));
let out_ident = quote::format_ident!("{}", sanitize_name(output));
// Get axis attribute (default -1)
let axis = node.get_int("axis").unwrap_or(-1);
Ok(quote! {
let #out_ident = #in_ident.softmax(#axis)?;
})
}
/// Generate leaky ReLU operation.
pub fn generate_leaky_relu(node: &Node) -> Result<TokenStream> {
let input = &node.inputs[0];
let output = &node.outputs[0];
let in_ident = quote::format_ident!("{}", sanitize_name(input));
let out_ident = quote::format_ident!("{}", sanitize_name(output));
// Get alpha attribute (default 0.01)
let alpha = node.get_float("alpha").unwrap_or(0.01);
Ok(quote! {
let #out_ident = #in_ident.leaky_relu(#alpha)?;
})
}