Skip to content

Commit

Permalink
Add tensor_buffer() & tensor_buffer_mut() for Interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
boncheolgu committed Dec 26, 2019
1 parent 53e2002 commit d70cda6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,18 @@ where
slice::from_raw_parts_mut(inner.data.raw as *mut T, inner.bytes / size_of::<T>())
})
}

pub fn tensor_buffer(&self, tensor_index: TensorIndex) -> Fallible<&[u8]> {
let inner = self.tensor_inner(tensor_index)?;

Ok(unsafe { slice::from_raw_parts(inner.data.raw_const as *mut u8, inner.bytes) })
}

pub fn tensor_buffer_mut(&mut self, tensor_index: TensorIndex) -> Fallible<&mut [u8]> {
let inner = self.tensor_inner(tensor_index)?;

Ok(unsafe { slice::from_raw_parts_mut(inner.data.raw as *mut u8, inner.bytes) })
}
}

#[cfg(test)]
Expand Down

0 comments on commit d70cda6

Please sign in to comment.