style: apply rustfmt across all crates and demos
Consistent formatting pass: line wrapping, import sorting, trailing whitespace removal, let-chain indentation, merged derive attributes, and unsafe block reformatting. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
@@ -2,16 +2,16 @@
|
||||
//!
|
||||
//! This module contains code generators for individual ONNX operators.
|
||||
|
||||
mod arithmetic;
|
||||
mod activation;
|
||||
mod arithmetic;
|
||||
mod conv;
|
||||
mod matmul;
|
||||
mod normalization;
|
||||
mod pooling;
|
||||
mod reshape;
|
||||
|
||||
pub use arithmetic::*;
|
||||
pub use activation::*;
|
||||
pub use arithmetic::*;
|
||||
pub use conv::*;
|
||||
pub use matmul::*;
|
||||
pub use normalization::*;
|
||||
@@ -21,8 +21,8 @@ pub use reshape::*;
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::quote;
|
||||
|
||||
use crate::ir::{Node, NodeKind, OnnxGraph};
|
||||
use crate::error::{Error, Result};
|
||||
use crate::ir::{Node, NodeKind, OnnxGraph};
|
||||
|
||||
/// Generate code for a single node.
|
||||
pub fn generate_node_code(node: &Node, graph: &OnnxGraph) -> Result<TokenStream> {
|
||||
@@ -183,12 +183,12 @@ pub fn sanitize_name(name: &str) -> String {
|
||||
|
||||
// Handle Rust keywords
|
||||
match result.as_str() {
|
||||
"type" | "fn" | "let" | "mut" | "ref" | "self" | "Self" | "mod" | "pub" | "use" |
|
||||
"struct" | "enum" | "trait" | "impl" | "for" | "while" | "loop" | "if" | "else" |
|
||||
"match" | "return" | "break" | "continue" | "move" | "box" | "where" | "async" |
|
||||
"await" | "dyn" | "abstract" | "become" | "const" | "crate" | "do" | "extern" |
|
||||
"final" | "in" | "macro" | "override" | "priv" | "static" | "super" | "try" |
|
||||
"typeof" | "unsafe" | "unsized" | "virtual" | "yield" => {
|
||||
"type" | "fn" | "let" | "mut" | "ref" | "self" | "Self" | "mod" | "pub" | "use"
|
||||
| "struct" | "enum" | "trait" | "impl" | "for" | "while" | "loop" | "if" | "else"
|
||||
| "match" | "return" | "break" | "continue" | "move" | "box" | "where" | "async"
|
||||
| "await" | "dyn" | "abstract" | "become" | "const" | "crate" | "do" | "extern"
|
||||
| "final" | "in" | "macro" | "override" | "priv" | "static" | "super" | "try"
|
||||
| "typeof" | "unsafe" | "unsized" | "virtual" | "yield" => {
|
||||
result.push('_');
|
||||
}
|
||||
_ => {}
|
||||
@@ -223,7 +223,9 @@ fn generate_min_max(node: &Node, op: &str) -> Result<TokenStream> {
|
||||
let output = &node.outputs[0];
|
||||
let out_ident = quote::format_ident!("{}", sanitize_name(output));
|
||||
|
||||
let input_idents: Vec<_> = node.inputs.iter()
|
||||
let input_idents: Vec<_> = node
|
||||
.inputs
|
||||
.iter()
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(|s| quote::format_ident!("{}", sanitize_name(s)))
|
||||
.collect();
|
||||
|
||||
Reference in New Issue
Block a user