Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mixed Array Support #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions onnxruntime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ use sys::OnnxEnumInt;

// Re-export ndarray as it's part of the public API anyway
pub use ndarray;
use ndarray::Array;
use crate::tensor::OrtTensor;

lazy_static! {
// static ref G_ORT: Arc<Mutex<AtomicPtr<sys::OrtApi>>> =
Expand Down Expand Up @@ -459,6 +461,34 @@ impl_type_trait!(u64, Uint64);
// impl_type_trait!(, Complex128);
// impl_type_trait!(, Bfloat16);

#[derive(Debug)]
pub enum TypedArray<D: ndarray::Dimension> {
F32(Array<f32, D>),
U8(Array<u8, D>),
I8(Array<i8, D>),
U16(Array<u16, D>),
I16(Array<i16, D>),
I32(Array<i32, D>),
I64(Array<i64, D>),
F64(Array<f64, D>),
U32(Array<u32, D>),
U64(Array<u64, D>),
}

#[derive(Debug)]
pub enum TypedOrtTensor<'t, D: ndarray::Dimension> {
F32(OrtTensor<'t, f32, D>),
U8(OrtTensor<'t, u8, D>),
I8(OrtTensor<'t, i8, D>),
U16(OrtTensor<'t, u16, D>),
I16(OrtTensor<'t, i16, D>),
I32(OrtTensor<'t, i32, D>),
I64(OrtTensor<'t, i64, D>),
F64(OrtTensor<'t, f64, D>),
U32(OrtTensor<'t, u32, D>),
U64(OrtTensor<'t, u64, D>),
}

/// Adapter for common Rust string types to Onnx strings.
///
/// It should be easy to use both `String` and `&str` as [TensorElementDataType::String] data, but
Expand Down
Loading