Fix build.py bug which prevents running some unit tests (#5990)

Also ignore an exception occurred for execution providers which generate compiled nodes
This commit is contained in:
baijumeswani 2020-12-03 08:57:55 -08:00 committed by GitHub
parent 0acc3837ee
commit 2b35f7d4f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View file

@ -9,6 +9,7 @@ import onnxruntime as onnxrt
import threading
import sys
from helper import get_name
from onnxruntime.capi.onnxruntime_pybind11_state import Fail
class TestInferenceSession(unittest.TestCase):
@ -20,12 +21,19 @@ class TestInferenceSession(unittest.TestCase):
np.testing.assert_allclose(output_expected, res[0], rtol=1e-05, atol=1e-08)
def testModelSerialization(self):
so = onnxrt.SessionOptions()
so.log_verbosity_level = 1
so.logid = "TestModelSerialization"
so.optimized_model_filepath = "./PythonApiTestOptimizedModel.onnx"
onnxrt.InferenceSession(get_name("mul_1.onnx"), sess_options=so)
self.assertTrue(os.path.isfile(so.optimized_model_filepath))
try:
so = onnxrt.SessionOptions()
so.log_verbosity_level = 1
so.logid = "TestModelSerialization"
so.optimized_model_filepath = "./PythonApiTestOptimizedModel.onnx"
onnxrt.InferenceSession(get_name("mul_1.onnx"), sess_options=so)
self.assertTrue(os.path.isfile(so.optimized_model_filepath))
except Fail as onnxruntime_error:
if str(onnxruntime_error) == "[ONNXRuntimeError] : 1 : FAIL : Unable to serialize model as it contains" \
" compiled nodes. Please disable any execution providers which generate compiled nodes.":
pass
else:
raise onnxruntime_error
def testGetProviders(self):
self.assertTrue('CPUExecutionProvider' in onnxrt.get_available_providers())

View file

@ -1457,7 +1457,7 @@ def run_onnxruntime_tests(args, source_dir, ctest_path, build_dir, configs):
# Disable python tests in a reduced build as we don't know which ops have been included and which
# models can run
if args.include_ops_by_model or args.include_ops_by_config or args.minimal_build:
if args.include_ops_by_model or args.include_ops_by_config or args.minimal_build != 'off':
return
if is_windows():