This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
backend_ort.py
56 lines (50 loc) · 1.96 KB
/
backend_ort.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
@file
@brief ONNX Backend for @see cl OnnxInference.
::
import unittest
from contextlib import redirect_stdout, redirect_stderr
from io import StringIO
from onnx.backend.test import BackendTest
import mlprodict.onnxrt.backend_ort as backend
back_test = BackendTest(backend, __name__)
back_test.exclude('.*_blvc_.*')
back_test.exclude('.*_densenet_.*')
back_test.exclude('.*_densenet121_.*')
back_test.exclude('.*_inception_.*')
back_test.exclude('.*_resnet50_.*')
back_test.exclude('.*_shufflenet_.*')
back_test.exclude('.*_squeezenet_.*')
back_test.exclude('.*_vgg19_.*')
back_test.exclude('.*_zfnet512_.*')
globals().update(back_test.enable_report().test_cases)
buffer = StringIO()
print('---------------------------------')
if True:
with redirect_stdout(buffer):
with redirect_stderr(buffer):
res = unittest.main(verbosity=2, exit=False)
else:
res = unittest.main(verbosity=2, exit=False)
testsRun = res.result.testsRun
errors = len(res.result.errors)
skipped = len(res.result.skipped)
unexpectedSuccesses = len(res.result.unexpectedSuccesses)
expectedFailures = len(res.result.expectedFailures)
print('---------------------------------')
print("testsRun=%d errors=%d skipped=%d unexpectedSuccesses=%d "
"expectedFailures=%d" % (
testsRun, errors, skipped, unexpectedSuccesses,
expectedFailures))
ran = testsRun - skipped
print("ratio=%f" % (1 - errors * 1.0 / ran))
print('---------------------------------')
lines = buffer.getvalue().split('\\n')
print("\\n".join(line for line in lines
if "skipped 'no matched include pattern'" not in line))
"""
from .backend import OnnxInferenceBackendOrt
is_compatible = OnnxInferenceBackendOrt.is_compatible
prepare = OnnxInferenceBackendOrt.prepare
run = OnnxInferenceBackendOrt.run_model
supports_device = OnnxInferenceBackendOrt.supports_device