File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ impl Core {
112
112
113
113
/// Gets properties related to device behavior.
114
114
///
115
- /// The method extracts information that can be set via the [`set_property`] method.
115
+ /// The method extracts information that can be set via the [`Core:: set_property`] method.
116
116
///
117
117
/// # Panics
118
118
///
Original file line number Diff line number Diff line change @@ -11,6 +11,26 @@ use openvino_sys::{
11
11
} ;
12
12
13
13
/// See [`Tensor`](https://docs.openvino.ai/2023.3/api/c_cpp_api/group__ov__tensor__c__api.html).
14
+ ///
15
+ /// To create a tensor from in-memory data, construct it and then fill it:
16
+ ///
17
+ /// ```rust
18
+ /// # use openvino::{Shape, Tensor, ElementType};
19
+ /// # fn main() -> anyhow::Result<()> {
20
+ /// # openvino_sys::library::load().unwrap();
21
+ /// let data = [1u8; 1000];
22
+ /// let shape = Shape::new(&[10, 10, 10])?;
23
+ /// let mut tensor = Tensor::new(ElementType::U8, &shape)?;
24
+ /// tensor.get_raw_data_mut()?.copy_from_slice(&data);
25
+ /// # Ok(())
26
+ /// # }
27
+ /// ```
28
+ ///
29
+ /// This approach currently results in a copy, which is sub-optimal. It is safe, however; passing a
30
+ /// slice to OpenVINO is unsafe unless additional lifetime constraints are added (to improve this in
31
+ /// the future, see the context in [#125]).
32
+ ///
33
+ /// [#125]: https://github.com/intel/openvino-rs/pull/125
14
34
pub struct Tensor {
15
35
ptr : * mut ov_tensor_t ,
16
36
}
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ macro_rules! drop_using_function {
27
27
( $ty: ty, $free_fn: expr) => {
28
28
impl Drop for $ty {
29
29
fn drop( & mut self ) {
30
- unsafe { $free_fn( self . ptr. cast( ) ) }
30
+ let free = $free_fn;
31
+ unsafe { free( self . ptr. cast( ) ) }
31
32
}
32
33
}
33
34
} ;
You can’t perform that action at this time.
0 commit comments