99 releases
0.19.7 | Feb 24, 2023 |
---|---|
0.19.2 | Jan 27, 2023 |
0.19.0-alpha.19 | Dec 19, 2022 |
0.18.4 | Nov 23, 2022 |
0.1.1 | Nov 2, 2018 |
#10 in #tensor-flow
622 downloads per month
Used in 3 crates
1.5MB
14K
SLoC
Tract TensorFlow module
Tiny, no-nonsense, self contained, portable inference.
Example
# extern crate tract_tensorflow;
# fn main() {
use tract_tensorflow::prelude::*;
// build a simple model that just add 3 to each input component
let tf = tensorflow();
let mut model = tf.model_for_path("tests/models/plus3.pb").unwrap();
// set input input type and shape, then optimize the network.
model.set_input_fact(0, f32::fact(&[3]).into()).unwrap();
let model = model.into_optimized().unwrap();
// we build an execution plan. default input and output 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]));
# }
Dependencies
~11–20MB
~416K SLoC