From 63dc0626ef5c44df337a16ebcc3476bbf236369c Mon Sep 17 00:00:00 2001 From: pinto0309 Date: Sun, 15 May 2022 00:34:28 +0900 Subject: [PATCH] Check if the number of input OPs in the model matches the number of inputs in the test data --- sit4onnx/onnx_inference_test.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sit4onnx/onnx_inference_test.py b/sit4onnx/onnx_inference_test.py index 7980224..0019ff9 100644 --- a/sit4onnx/onnx_inference_test.py +++ b/sit4onnx/onnx_inference_test.py @@ -260,6 +260,15 @@ def inference( ) for ort_input_name, ort_input_shape, onnx_input_type in zip(ort_input_names, ort_input_shapes, onnx_input_types) } else: + # Check if the number of input OPs in the model matches the number of inputs in the test data + if len(ort_input_names) != len(numpy_ndarrays_for_testing): + print( + f'{Color.RED}ERROR:{Color.RESET} '+ + f'The number of input OPs in the model must match the number of test data inputs.\n'+ + f'Number of model input OPs: {len(ort_input_names)}\n'+ + f'Number of test data inputs: {len(numpy_ndarrays_for_testing)}' + ) + sys.exit(1) input_dict = { ort_input_name: numpy_ndarray_for_testing \ for ort_input_name, numpy_ndarray_for_testing in zip(ort_input_names, numpy_ndarrays_for_testing)