-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rust] Change inputs and outputs to session.run
Adds WithOrtOwnedTensor<T> and WithOrtTensor<T> that tie the drop of T to the underlying tensor. Changes the run function to take Vec<impl ConstructTensor> where ConstructTensor is implemented for items that can construct a WithOrtTensor<T> for a particular T.
- Loading branch information
1 parent
03333c6
commit 1c01875
Showing
11 changed files
with
554 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//! convert module has the trait for conversion of Inputs ConstructTensor. | ||
use crate::{memory::MemoryInfo, OrtError}; | ||
use onnxruntime_sys::OrtAllocator; | ||
use onnxruntime_sys::OrtValue; | ||
use std::fmt::Debug; | ||
|
||
/// The Input type for Rust onnxruntime Session::run | ||
/// Many types can construct a | ||
pub trait ConstructTensor: Debug { | ||
/// Constuct an OrtTensor Input using the `MemoryInfo` and a raw pointer to the `OrtAllocator`. | ||
fn construct<'a>( | ||
&'a mut self, | ||
memory_info: &MemoryInfo, | ||
allocator: *mut OrtAllocator, | ||
) -> Result<Box<dyn InputTensor + 'a>, OrtError>; | ||
} | ||
|
||
/// Allows the return value of ConstructTensor::construct | ||
/// to be generic. | ||
pub trait InputTensor { | ||
/// The input tensor's shape | ||
fn shape(&self) -> &[usize]; | ||
|
||
/// The input tensor's ptr | ||
fn ptr(&self) -> *mut OrtValue; | ||
} |
Oops, something went wrong.