From 96b50a286d406d918efaa116c86d360ba9677148 Mon Sep 17 00:00:00 2001 From: mgoin Date: Tue, 21 Mar 2023 10:33:12 -0400 Subject: [PATCH] Add Engine.generate_random_inputs() --- src/deepsparse/engine.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/deepsparse/engine.py b/src/deepsparse/engine.py index 4cbcf0e86c..c1df313f47 100644 --- a/src/deepsparse/engine.py +++ b/src/deepsparse/engine.py @@ -25,7 +25,11 @@ from tqdm.auto import tqdm from deepsparse.benchmark import BenchmarkResults -from deepsparse.utils import model_to_path, override_onnx_input_shapes +from deepsparse.utils import ( + generate_random_inputs, + model_to_path, + override_onnx_input_shapes, +) try: @@ -314,6 +318,13 @@ def cpu_vnni(self) -> bool: """ return self._cpu_vnni + def generate_random_inputs(self) -> List[numpy.ndarray]: + """ + Generate random data that matches the type and shape of the ONNX model + :return: List of random tensors + """ + return generate_random_inputs(self.model_path, self.batch_size) + def run( self, inp: List[numpy.ndarray],