Add from_raw function
This commit is contained in:
parent
8abd94d828
commit
6f77c950bc
10
src/lib.rs
10
src/lib.rs
@ -16,7 +16,7 @@ pub use allocator::Allocator;
|
||||
|
||||
// note that this be come after the macro definitions (in api)
|
||||
mod value;
|
||||
pub use value::{Tensor, OrtType};
|
||||
pub use value::{OrtType, Tensor};
|
||||
|
||||
macro_rules! ort_type {
|
||||
($t:ident, $r:ident) => {
|
||||
@ -28,6 +28,9 @@ macro_rules! ort_type {
|
||||
pub fn raw(&self) -> *mut sys::$t {
|
||||
self.raw
|
||||
}
|
||||
pub unsafe fn from_raw(raw: *mut sys::$t) -> Self {
|
||||
Self { raw }
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for $t {
|
||||
@ -128,7 +131,10 @@ impl SessionOptions {
|
||||
Ok(SessionOptions { raw })
|
||||
}
|
||||
|
||||
pub fn set_optimized_model_filepath(&mut self, optimized_model_filepath: &str) -> Result<&mut Self> {
|
||||
pub fn set_optimized_model_filepath(
|
||||
&mut self,
|
||||
optimized_model_filepath: &str,
|
||||
) -> Result<&mut Self> {
|
||||
let optimized_model_filepath = CString::new(optimized_model_filepath)?;
|
||||
unsafe {
|
||||
checked_call!(
|
||||
|
@ -195,7 +195,8 @@ impl<T: OrtType> Tensor<T> {
|
||||
|
||||
// must be owned or will panic, don't give it negative dims
|
||||
pub fn resize(&mut self, dims: Vec<i64>)
|
||||
where T: Clone + Default
|
||||
where
|
||||
T: Clone + Default,
|
||||
{
|
||||
let len = dims.iter().product::<i64>();
|
||||
let owned = self.owned.as_mut().expect("Tensor::resize not owned");
|
||||
|
Loading…
Reference in New Issue
Block a user