1
+ #![ doc = include_str ! ( "../README.md" ) ]
2
+
1
3
pub mod download;
2
4
pub mod environment;
3
5
pub mod error;
@@ -42,6 +44,11 @@ lazy_static! {
42
44
} ;
43
45
}
44
46
47
+ /// Attempts to acquire the global OrtApi object.
48
+ ///
49
+ /// # Panics
50
+ ///
51
+ /// Panics if another thread panicked while holding the API lock, or if the ONNX Runtime API could not be initialized.
45
52
pub fn ort ( ) -> sys:: OrtApi {
46
53
let mut api_ref = G_ORT_API . lock ( ) . expect ( "failed to acquire OrtApi lock; another thread panicked?" ) ;
47
54
let api_ref_mut: & mut * mut sys:: OrtApi = api_ref. get_mut ( ) ;
@@ -176,15 +183,20 @@ extern_system_fn! {
176
183
}
177
184
}
178
185
179
- /// ONNX Runtime logging level.
186
+ /// The minimum logging level. Logs will be handled by the `tracing` crate .
180
187
#[ derive( Debug ) ]
181
188
#[ cfg_attr( not( windows) , repr( u32 ) ) ]
182
189
#[ cfg_attr( windows, repr( i32 ) ) ]
183
190
pub enum LoggingLevel {
191
+ /// Verbose logging level. This will log *a lot* of messages!
184
192
Verbose = sys:: OrtLoggingLevel_ORT_LOGGING_LEVEL_VERBOSE as OnnxEnumInt ,
193
+ /// Info logging level.
185
194
Info = sys:: OrtLoggingLevel_ORT_LOGGING_LEVEL_INFO as OnnxEnumInt ,
195
+ /// Warning logging level. Recommended to receive potentially important warnings.
186
196
Warning = sys:: OrtLoggingLevel_ORT_LOGGING_LEVEL_WARNING as OnnxEnumInt ,
197
+ /// Error logging level.
187
198
Error = sys:: OrtLoggingLevel_ORT_LOGGING_LEVEL_ERROR as OnnxEnumInt ,
199
+ /// Fatal logging level.
188
200
Fatal = sys:: OrtLoggingLevel_ORT_LOGGING_LEVEL_FATAL as OnnxEnumInt
189
201
}
190
202
@@ -212,7 +224,7 @@ impl From<LoggingLevel> for sys::OrtLoggingLevel {
212
224
/// The optimizations belonging to one level are performed after the optimizations of the previous level have been
213
225
/// applied (e.g., extended optimizations are applied after basic optimizations have been applied).
214
226
///
215
- /// **All optimizations are enabled by default.**
227
+ /// **All optimizations (i.e. [`GraphOptimizationLevel::Level3`]) are enabled by default.**
216
228
///
217
229
/// # Online/offline mode
218
230
/// All optimizations can be performed either online or offline. In online mode, when initializing an inference session,
@@ -233,6 +245,7 @@ impl From<LoggingLevel> for sys::OrtLoggingLevel {
233
245
#[ cfg_attr( not( windows) , repr( u32 ) ) ]
234
246
#[ cfg_attr( windows, repr( i32 ) ) ]
235
247
pub enum GraphOptimizationLevel {
248
+ /// Disables all graph optimizations.
236
249
Disable = sys:: GraphOptimizationLevel_ORT_DISABLE_ALL as OnnxEnumInt ,
237
250
/// Level 1 includes semantics-preserving graph rewrites which remove redundant nodes and redundant computation.
238
251
/// They run before graph partitioning and thus apply to all the execution providers. Available basic/level 1 graph
@@ -292,13 +305,13 @@ impl From<GraphOptimizationLevel> for sys::GraphOptimizationLevel {
292
305
}
293
306
}
294
307
295
- /// Allocator type
308
+ /// Execution provider allocator type.
296
309
#[ derive( Debug , Clone ) ]
297
310
#[ repr( i32 ) ]
298
311
pub enum AllocatorType {
299
- /// Device allocator
312
+ /// Default device-specific allocator.
300
313
Device = sys:: OrtAllocatorType_OrtDeviceAllocator ,
301
- /// Arena allocator
314
+ /// Arena allocator.
302
315
Arena = sys:: OrtAllocatorType_OrtArenaAllocator
303
316
}
304
317
@@ -311,17 +324,20 @@ impl From<AllocatorType> for sys::OrtAllocatorType {
311
324
}
312
325
}
313
326
314
- /// Memory type
327
+ /// Memory types for allocated memory.
315
328
#[ derive( Debug , Clone ) ]
316
329
#[ repr( i32 ) ]
317
330
pub enum MemType {
331
+ /// Any CPU memory used by non-CPU execution provider.
318
332
CPUInput = sys:: OrtMemType_OrtMemTypeCPUInput ,
333
+ /// CPU accessible memory outputted by non-CPU execution provider, i.e. CUDA_PINNED.
319
334
CPUOutput = sys:: OrtMemType_OrtMemTypeCPUOutput ,
320
- /// Default memory type
335
+ /// The default allocator for an execution provider.
321
336
Default = sys:: OrtMemType_OrtMemTypeDefault
322
337
}
323
338
324
339
impl MemType {
340
+ /// Temporary CPU accessible memory allocated by non-CPU execution provider, i.e. CUDA_PINNED.
325
341
pub const CPU : MemType = MemType :: CPUOutput ;
326
342
}
327
343
0 commit comments