pub struct NetronExporter { /* private fields */ }Expand description
Netron exporter for model visualization
Implementations§
Source§impl NetronExporter
impl NetronExporter
Sourcepub fn with_format(self, format: ExportFormat) -> Self
pub fn with_format(self, format: ExportFormat) -> Self
Set the export format
Sourcepub fn set_metadata(&mut self, metadata: ModelMetadata)
pub fn set_metadata(&mut self, metadata: ModelMetadata)
Set model metadata
Add model author
Sourcepub fn set_version(&mut self, version: &str)
pub fn set_version(&mut self, version: &str)
Add model version
Sourcepub fn add_property(&mut self, key: &str, value: &str)
pub fn add_property(&mut self, key: &str, value: &str)
Add a custom property to metadata
Sourcepub fn add_node(
&mut self,
name: &str,
op_type: &str,
inputs: Vec<String>,
outputs: Vec<String>,
attributes: HashMap<String, AttributeValue>,
)
pub fn add_node( &mut self, name: &str, op_type: &str, inputs: Vec<String>, outputs: Vec<String>, attributes: HashMap<String, AttributeValue>, )
Add a graph node (layer/operation)
§Example
let mut exporter = NetronExporter::new("model", "test model");
let mut attrs = HashMap::new();
attrs.insert("in_features".to_string(),
trustformers_debug::netron_export::AttributeValue::Int(768));
attrs.insert("out_features".to_string(),
trustformers_debug::netron_export::AttributeValue::Int(3072));
exporter.add_node(
"fc1",
"Linear",
vec!["input".to_string()],
vec!["hidden".to_string()],
attrs,
);Sourcepub fn add_node_with_doc(
&mut self,
name: &str,
op_type: &str,
inputs: Vec<String>,
outputs: Vec<String>,
attributes: HashMap<String, AttributeValue>,
doc_string: &str,
)
pub fn add_node_with_doc( &mut self, name: &str, op_type: &str, inputs: Vec<String>, outputs: Vec<String>, attributes: HashMap<String, AttributeValue>, doc_string: &str, )
Add a node with documentation
Sourcepub fn add_tensor_data(
&mut self,
name: &str,
dtype: &str,
shape: Vec<i64>,
data: Option<Vec<f32>>,
)
pub fn add_tensor_data( &mut self, name: &str, dtype: &str, shape: Vec<i64>, data: Option<Vec<f32>>, )
Add tensor data (weights/biases)
Sourcepub fn model(&self) -> &NetronModel
pub fn model(&self) -> &NetronModel
Get a reference to the model
Sourcepub fn model_mut(&mut self) -> &mut NetronModel
pub fn model_mut(&mut self) -> &mut NetronModel
Get a mutable reference to the model
Sourcepub fn to_json_string(&self) -> Result<String>
pub fn to_json_string(&self) -> Result<String>
Export model to a string (JSON format)
Sourcepub fn create_linear_node(
name: &str,
input_name: &str,
output_name: &str,
in_features: i64,
out_features: i64,
has_bias: bool,
) -> GraphNode
pub fn create_linear_node( name: &str, input_name: &str, output_name: &str, in_features: i64, out_features: i64, has_bias: bool, ) -> GraphNode
Create a simple linear layer node
Auto Trait Implementations§
impl Freeze for NetronExporter
impl RefUnwindSafe for NetronExporter
impl Send for NetronExporter
impl Sync for NetronExporter
impl Unpin for NetronExporter
impl UnwindSafe for NetronExporter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.