deepsparse.utils package

Submodules

deepsparse.utils.data module

deepsparse.utils.data.arrays_to_bytes(arrays: List[numpy.array])bytearray[source]
Parameters

arrays – List of numpy arrays to serialize as bytes

Returns

bytearray representation of list of numpy arrays

deepsparse.utils.data.bytes_to_arrays(serialized_arr: bytearray)List[numpy.array][source]
Parameters

serialized_arr – bytearray representation of list of numpy arrays

Returns

List of numpy arrays decoded from input

deepsparse.utils.data.verify_outputs(outputs: List[numpy.array], gt_outputs: List[numpy.array], atol: float = 0.0008, rtol: float = 0.0)List[float][source]

Compares two lists of output tensors, checking that they are sufficiently similar :param outputs: List of numpy arrays, usually model outputs :param gt_outputs: List of numpy arrays, usually reference outputs :param atol: Absolute tolerance for allclose :param rtol: Relative tolerance for allclose :return: The list of max differences for each pair of outputs

deepsparse.utils.log module

deepsparse.utils.log.log_init(name)[source]

deepsparse.utils.onnx module

deepsparse.utils.onnx.generate_random_inputs(onnx_filepath: str, batch_size: Optional[int] = None)List[numpy.array][source]

Generate random data that matches the type and shape of ONNX model, with a batch size override :param onnx_filepath: File path to ONNX model :param batch_size: If provided, override for the batch size dimension :return: List of random tensors

deepsparse.utils.onnx.get_external_inputs(onnx_filepath: str)List[source]

Gather external inputs of ONNX model :param onnx_filepath: File path to ONNX model :return: List of input objects

deepsparse.utils.onnx.get_external_outputs(onnx_filepath: str)List[source]

Gather external outputs of ONNX model :param onnx_filepath: File path to ONNX model :return: List of output objects

deepsparse.utils.onnx.get_input_names(onnx_filepath: str)List[str][source]

Gather names of all external inputs of ONNX model :param onnx_filepath: File path to ONNX model :return: List of string names

deepsparse.utils.onnx.get_output_names(onnx_filepath: str)List[str][source]

Gather names of all external outputs of ONNX model :param onnx_filepath: File path to ONNX model :return: List of string names

deepsparse.utils.onnx.override_onnx_batch_size(onnx_filepath: str, batch_size: int)[source]

Rewrite batch sizes of ONNX model, saving the modified model and returning its path :param onnx_filepath: File path to ONNX model :param batch_size: Override for the batch size dimension :return: File path to modified ONNX model

Module contents