mirror of
https://github.com/pykeio/ort
synced 2026-04-25 16:34:55 +02:00
refactor: usability
aka The Cleanening, part 2 - Add clearer documentation and examples for more things. - Rework string tensors by introducing `PrimitiveTensorElementType` for primitive (i.e. f32) types, and again re-implementing `IntoTensorElementType` for `String`. This allows string tensors to be used via `Tensor<String>` instead of exclusively via `DynTensor`. Additionally, string tensors no longer require an `Allocator` to be created (which didn't make sense, since string data in Rust can only ever be stored on the CPU anyway). This also now applies to `Map`s, since their data also needed to be on the CPU anyway. (`Sequence`s are currently unaffected because I think a custom allocator could be useful for them?) - Rework the `IoBinding` interface, and add an example clarifying the intended usage of it (ref #209). Thanks to AAce from the pyke Discord for pointing out the mutability issue in the old interface, which should be addressed now. - Refactor `OperatorDomain::add` from the slightly-nicer-looking-but-more-confusing `fn<T>(t: T)` to just `fn<T>()` to further enforce the fact that `Operator`s are zero-sized. - Maps can now have `String` keys. - Remove some unused errors.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
use std::path::Path;
|
||||
|
||||
use ndarray::{ArrayD, IxDyn};
|
||||
use ort::{inputs, DynTensor, GraphOptimizationLevel, Session};
|
||||
use ort::{inputs, GraphOptimizationLevel, Session, Tensor};
|
||||
use test_log::test;
|
||||
|
||||
#[test]
|
||||
@@ -22,7 +22,7 @@ fn vectorizer() -> ort::Result<()> {
|
||||
let array = ndarray::CowArray::from(ndarray::Array::from_shape_vec((1,), vec!["document".to_owned()]).unwrap());
|
||||
|
||||
// Just one input
|
||||
let input_tensor_values = inputs![DynTensor::from_string_array(session.allocator(), &array)?]?;
|
||||
let input_tensor_values = inputs![Tensor::from_string_array(&array)?]?;
|
||||
|
||||
// Perform the inference
|
||||
let outputs = session.run(input_tensor_values)?;
|
||||
|
||||
Reference in New Issue
Block a user