tritonclient.utils#

函数

deserialize_bf16_tensor(encoded_tensor)

将编码的 bf16 张量反序列化为 dtype 为 python 对象的 numpy 数组

deserialize_bytes_tensor(encoded_tensor)

将编码的字节张量反序列化为 dtype 为 python 对象的 numpy 数组

np_to_triton_dtype(np_dtype)

raise_error(msg)

使用提供的消息引发错误

serialize_bf16_tensor(input_tensor)

将 bfloat16 张量序列化为字节的扁平 numpy 数组。

serialize_byte_tensor(input_tensor)

将字节张量序列化为长度前缀字节的扁平 numpy 数组。

serialized_byte_size(tensor_value)

获取 numpy ndarray 的底层字节数。

triton_to_np_dtype(dtype)

异常

InferenceServerException(msg[, status, ...])

指示非成功状态的异常。

exception tritonclient.utils.InferenceServerException(msg, status=None, debug_details=None)#

指示非成功状态的异常。

参数:
  • msg (str) – 错误的简要描述

  • status (str) – 错误代码

  • debug_details (str) – 关于错误的附加详细信息

debug_details()#

获取有关异常的详细信息以进行调试

返回:

返回异常详细信息

返回类型:

str

message()#

获取异常消息。

返回:

与此异常关联的消息,如果没有消息则为 None。

返回类型:

str

status()#

获取异常的状态。

返回:

返回异常的状态

返回类型:

str

tritonclient.utils.deserialize_bf16_tensor(encoded_tensor)#

将编码的 bf16 张量反序列化为 dtype 为 python 对象的 numpy 数组

参数:

encoded_tensor (bytes) – 编码的字节张量,其中每个元素为 2 个字节(bfloat16 的大小)

返回:

string_tensor – 包含以行优先形式反序列化的字节的 float32 类型的 1-D numpy 数组。

返回类型:

np.array

tritonclient.utils.deserialize_bytes_tensor(encoded_tensor)#

将编码的字节张量反序列化为 dtype 为 python 对象的 numpy 数组

参数:

encoded_tensor (bytes) – 编码的字节张量,其中每个元素的前 4 个字节是长度,后跟内容

返回:

string_tensor – 包含以行优先形式反序列化的字节的对象类型的 1-D numpy 数组。

返回类型:

np.array

tritonclient.utils.np_to_triton_dtype(np_dtype)#
tritonclient.utils.raise_error(msg)#

使用提供的消息引发错误

tritonclient.utils.serialize_bf16_tensor(input_tensor)#

将 bfloat16 张量序列化为字节的扁平 numpy 数组。numpy 数组应使用 np.float32 的 dtype。

参数:

input_tensor (np.array) – 要序列化的 bfloat16 张量。

返回:

serialized_bf16_tensor – 包含以行优先形式序列化的字节的 uint8 类型的 1-D numpy 数组。

返回类型:

np.array

引发:

InferenceServerException – 如果无法序列化给定的张量。

tritonclient.utils.serialize_byte_tensor(input_tensor)#

将字节张量序列化为长度前缀字节的扁平 numpy 数组。numpy 数组应使用 np.object 的 dtype。对于 np.bytes,numpy 将删除字节序列末尾的尾随零,因此应避免使用它。

参数:

input_tensor (np.array) – 要序列化的字节张量。

返回:

serialized_bytes_tensor – 包含以行优先形式序列化的字节的 uint8 类型的 1-D numpy 数组。

返回类型:

np.array

引发:

InferenceServerException – 如果无法序列化给定的张量。

tritonclient.utils.serialized_byte_size(tensor_value)#

获取 numpy ndarray 的底层字节数。

参数:

tensor_value (numpy.ndarray) – 用于计算字节数的 Numpy 数组。

返回:

此张量中存在的字节数

返回类型:

int

tritonclient.utils.triton_to_np_dtype(dtype)#

模块