module utils.onnxruntime_helper#

Short summary#

module onnxcustom.utils.onnxruntime_helper

Onnxruntime helper.

source on GitHub

Functions#

function

truncated documentation

device_to_providers

Returns the corresponding providers for a specific device.

get_ort_device

Converts device into C_OrtDevice.

get_ort_device_from_session

Retrieves the device from an object InferenceSession.

get_ort_device_type

Converts device into device type.

numpy_to_ort_value

Converts a numpy array to C_OrtValue.

ort_device_to_string

Returns a string representing the device. Opposite of function get_ort_device().

provider_to_device

Converts provider into a device.

Documentation#

Onnxruntime helper.

source on GitHub

onnxcustom.utils.onnxruntime_helper.device_to_providers(device)#

Returns the corresponding providers for a specific device.

Parameters:

deviceC_OrtDevice

Returns:

providers

source on GitHub

onnxcustom.utils.onnxruntime_helper.get_ort_device(device)#

Converts device into C_OrtDevice.

Parameters:

device – any type

Returns:

C_OrtDevice

Example:

get_ort_device('cpu')
get_ort_device('gpu')
get_ort_device('cuda')
get_ort_device('cuda:0')

source on GitHub

onnxcustom.utils.onnxruntime_helper.get_ort_device_from_session(sess)#

Retrieves the device from an object InferenceSession.

Parameters:

sessInferenceSession

Returns:

C_OrtDevice

source on GitHub

onnxcustom.utils.onnxruntime_helper.get_ort_device_type(device)#

Converts device into device type.

Parameters:

device – string

Returns:

device type

source on GitHub

onnxcustom.utils.onnxruntime_helper.numpy_to_ort_value(arr, device=None)#

Converts a numpy array to C_OrtValue.

Parameters:
  • arr – numpy array

  • deviceC_OrtDevice or None for cpu

Returns:

C_OrtValue

source on GitHub

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

source on GitHub

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

source on GitHub