@@ -28,12 +28,14 @@ unsafe impl Sync for Model {}
28
28
29
29
impl Model {
30
30
/// Create a new [`Model`] from an internal pointer.
31
+ #[ inline]
31
32
pub ( crate ) fn from_ptr ( ptr : * mut ov_model_t ) -> Self {
32
33
Self { ptr }
33
34
}
34
35
35
36
/// Get the pointer to the underlying [`ov_model_t`].
36
- pub ( crate ) fn as_ptr ( & self ) -> * mut ov_model_t {
37
+ #[ inline]
38
+ pub ( crate ) fn as_ptr ( & self ) -> * const ov_model_t {
37
39
self . ptr
38
40
}
39
41
@@ -59,7 +61,7 @@ impl Model {
59
61
index,
60
62
std:: ptr:: addr_of_mut!( node)
61
63
) ) ?;
62
- Ok ( Node :: new ( node) )
64
+ Ok ( Node :: from_ptr ( node) )
63
65
}
64
66
65
67
/// Retrieve the output node by index.
@@ -70,7 +72,7 @@ impl Model {
70
72
index,
71
73
std:: ptr:: addr_of_mut!( node)
72
74
) ) ?;
73
- Ok ( Node :: new ( node) )
75
+ Ok ( Node :: from_ptr ( node) )
74
76
}
75
77
76
78
/// Retrieve the constant output node by index.
@@ -81,7 +83,7 @@ impl Model {
81
83
index,
82
84
std:: ptr:: addr_of_mut!( node)
83
85
) ) ?;
84
- Ok ( Node :: new ( node) )
86
+ Ok ( Node :: from_ptr ( node) )
85
87
}
86
88
87
89
/// Returns `true` if the model contains dynamic shapes.
@@ -128,7 +130,7 @@ impl CompiledModel {
128
130
self . ptr,
129
131
std:: ptr:: addr_of_mut!( port)
130
132
) ) ?;
131
- Ok ( Node :: new ( port) )
133
+ Ok ( Node :: from_ptr ( port) )
132
134
}
133
135
134
136
/// Get an input port of the compiled model by port index.
@@ -139,7 +141,7 @@ impl CompiledModel {
139
141
index,
140
142
std:: ptr:: addr_of_mut!( port)
141
143
) ) ?;
142
- Ok ( Node :: new ( port) )
144
+ Ok ( Node :: from_ptr ( port) )
143
145
}
144
146
145
147
/// Get an input port of the compiled model by name.
@@ -151,7 +153,7 @@ impl CompiledModel {
151
153
name,
152
154
std:: ptr:: addr_of_mut!( port)
153
155
) ) ?;
154
- Ok ( Node :: new ( port) )
156
+ Ok ( Node :: from_ptr ( port) )
155
157
}
156
158
157
159
/// Get the number of outputs of the compiled model.
@@ -168,7 +170,7 @@ impl CompiledModel {
168
170
self . ptr,
169
171
std:: ptr:: addr_of_mut!( port)
170
172
) ) ?;
171
- Ok ( Node :: new ( port) )
173
+ Ok ( Node :: from_ptr ( port) )
172
174
}
173
175
174
176
/// Get an output port of the compiled model by port index.
@@ -179,7 +181,7 @@ impl CompiledModel {
179
181
index,
180
182
std:: ptr:: addr_of_mut!( port)
181
183
) ) ?;
182
- Ok ( Node :: new ( port) )
184
+ Ok ( Node :: from_ptr ( port) )
183
185
}
184
186
185
187
/// Get an output port of the compiled model by name.
@@ -191,7 +193,7 @@ impl CompiledModel {
191
193
name,
192
194
std:: ptr:: addr_of_mut!( port)
193
195
) ) ?;
194
- Ok ( Node :: new ( port) )
196
+ Ok ( Node :: from_ptr ( port) )
195
197
}
196
198
197
199
/// Gets runtime model information from a device.
0 commit comments