module utils.onnxruntime_helper
#
Short summary#
module onnxcustom.utils.onnxruntime_helper
Onnxruntime helper.
Functions#
function |
truncated documentation |
---|---|
Returns the corresponding providers for a specific device. |
|
Converts device into C_OrtDevice. |
|
Retrieves the device from an object InferenceSession. |
|
Converts device into device type. |
|
Converts a numpy array to C_OrtValue. |
|
Returns a string representing the device. Opposite of function |
|
Converts provider into a device. |
Documentation#
Onnxruntime helper.
- onnxcustom.utils.onnxruntime_helper.device_to_providers(device)#
Returns the corresponding providers for a specific device.
- Parameters:
device – C_OrtDevice
- Returns:
providers
- onnxcustom.utils.onnxruntime_helper.get_ort_device(device)#
Converts device into C_OrtDevice.
- Parameters:
device – any type
- Returns:
Example:
get_ort_device('cpu') get_ort_device('gpu') get_ort_device('cuda') get_ort_device('cuda:0')
- onnxcustom.utils.onnxruntime_helper.get_ort_device_from_session(sess)#
Retrieves the device from an object InferenceSession.
- Parameters:
sess – InferenceSession
- Returns:
- onnxcustom.utils.onnxruntime_helper.get_ort_device_type(device)#
Converts device into device type.
- Parameters:
device – string
- Returns:
device type
- onnxcustom.utils.onnxruntime_helper.numpy_to_ort_value(arr, device=None)#
Converts a numpy array to C_OrtValue.
- Parameters:
arr – numpy array
device – C_OrtDevice or None for cpu
- Returns:
- onnxcustom.utils.onnxruntime_helper.ort_device_to_string(device)#
Returns a string representing the device. Opposite of function
get_ort_device
.- Parameters:
device – see C_OrtDevice
- Returns:
string
- onnxcustom.utils.onnxruntime_helper.provider_to_device(provider_name)#
Converts provider into a device.
- Parameters:
provider_name – provider name
- Returns:
device name
<<<
from onnxcustom.utils.onnxruntime_helper import provider_to_device print(provider_to_device('CPUExecutionProvider'))
>>>
cpu