MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / check

Function check

tools/Polygraphy/tests/conftest.py:77–116  ·  view source on GitHub ↗
(runner)

Source from the content-addressed store, hash-verified

75 """
76
77 def check(runner):
78 import contextlib
79 import io
80
81 import numpy as np
82
83 outfile = io.StringIO()
84 with contextlib.redirect_stdout(outfile), contextlib.redirect_stderr(outfile):
85 runner.activate()
86 metadata = runner.get_input_metadata()
87 runner.infer({name: np.ones(shape, dtype=dtype) for name, (dtype, shape) in metadata.items()})
88 runner.deactivate()
89
90 outfile.seek(0)
91 out = outfile.read()
92
93 def check_warning(method, warning_expected):
94 assert (
95 f"Calling '{type(runner).__name__}.{method}_impl()' directly is not recommended. Please use '{method}()' instead."
96 in out
97 ) == warning_expected
98
99 check_warning("get_input_metadata", warning_expected=False)
100 check_warning("activate", warning_expected=False)
101 check_warning("infer", warning_expected=False)
102 check_warning("deactivate", warning_expected=False)
103
104 runner.activate_impl()
105 metadata = runner.get_input_metadata_impl()
106 runner.infer_impl({name: np.ones(shape, dtype=dtype) for name, (dtype, shape) in metadata.items()})
107 runner.deactivate_impl()
108
109 outfile.seek(0)
110 out = outfile.read()
111 print(out)
112
113 check_warning("get_input_metadata", warning_expected=True)
114 check_warning("activate", warning_expected=True)
115 check_warning("infer", warning_expected=True)
116 check_warning("deactivate", warning_expected=True)
117
118 return check
119

Calls 15

check_warningFunction · 0.85
printFunction · 0.85
typeFunction · 0.85
get_input_metadataMethod · 0.80
deactivateMethod · 0.80
readMethod · 0.80
activateMethod · 0.45
inferMethod · 0.45
itemsMethod · 0.45
activate_implMethod · 0.45
infer_implMethod · 0.45

Tested by

no test coverage detected