[−][src]Crate tract_core
Tract
Tiny, no-nonsense, self contained, portable TensorFlow and ONNX inference.
Example
use tract_core::internal::*; // build a simple model that just add 3 to each input component let mut model = InferenceModel::default(); let input = model.add_source("input", InferenceFact::default()).unwrap(); let three = model.add_const("three".to_string(), tensor0(3f32)).unwrap(); let add = model.wire_node("add".to_string(), tract_core::ops::math::add::bin(), [input, three].as_ref() ).unwrap(); model.auto_outputs().unwrap(); // We build an execution plan. Default inputs and outputs are inferred from // the model graph. let plan = SimplePlan::new(&model).unwrap(); // run the computation. let input = tensor1(&[1.0f32, 2.5, 5.0]); let mut outputs = plan.run(tvec![input]).unwrap(); // take the first and only output tensor let mut tensor = outputs.pop().unwrap(); assert_eq!(tensor, rctensor1(&[4.0f32, 5.5, 8.0]));
While creating a model from Rust code is useful for testing the library, real-life use-cases will usually load a TensorFlow or ONNX model using tract-tensorflow or tract-onnx crates.
Re-exports
pub extern crate error_chain; |
pub extern crate ndarray; |
pub extern crate objekt; |
pub use crate::errors::*; |
Modules
analyser | Model graph type inference. |
broadcast | N-way tensor broadcast |
datum |
|
dim | Extended dimension support |
errors | error_chain generated types |
framework | Enforce consistent API between the implemented Frameworks importers. |
internal | This prelude is meant for code extending tract (like implementing new ops). |
macros | |
model | B |
ops | Ops |
plan | |
prelude | This prelude is meant for code using tract. |
pulse | |
tensor |
|
Macros
args_1 | |
args_2 | |
args_3 | |
args_4 | |
args_5 | |
assert_backward | Asserts that backward inference results work as expected. |
assert_close | |
assert_forward | Asserts that forward inference results work as expected. |
bin_to_super_type | |
boxed_new | |
canonic | |
dimfact | Constructs a dimension fact. |
dispatch_copy | |
dispatch_datum | |
dispatch_floatlike | |
dispatch_model | |
dispatch_model_no_pulse | |
dispatch_numbers | |
dispatch_signed | |
element_wise | |
element_wise_oop | |
impl_op_same_as | |
inference_op_as_op | |
not_a_pulsed_op | |
not_a_typed_op | |
op_as_pulsed_op | |
op_as_typed_op | |
pulsed_op_as_op | |
pulsed_op_to_typed_op | |
shapefact | Constructs a shape fact. |
to_typed | |
tvec | |
typed_op_as_op | |
typefact | Constructs a type fact. |
unwrap_or_none | Tries to unwrap an option, or returns Ok(None) otherwise. |
valuefact | Constructs an value fact. |
wrap |