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

Class Script

tools/Polygraphy/polygraphy/tools/script.py:197–457  ·  view source on GitHub ↗

Represents a Python script that uses the Polygraphy API.

Source from the content-addressed store, hash-verified

195
196@mod.export()
197class Script:
198 """
199 Represents a Python script that uses the Polygraphy API.
200 """
201
202 class String:
203 """
204 Represents a string that has passed Polygraphy's security checks.
205 """
206
207 def __init__(self, s, safe=False, inline=False):
208 self.s = s
209 self.safe = safe
210 self.inline = inline
211
212 def __str__(self):
213 return str(self.s)
214
215 def __repr__(self):
216 if self.inline:
217 # Since only safe strings can be marked inline, self.safe is always
218 # True in this branch, so no need to check it.
219 return str(self.s)
220 return repr(self.s)
221
222 def __iadd__(self, other):
223 if not isinstance(other, Script.String):
224 G_LOGGER.internal_error(f"Cannot concatenate str and Script.String. Note: str was: {other}")
225 elif self.safe != other.safe:
226 G_LOGGER.internal_error(f"Cannot concatenate unsafe string ({other}) to safe string ({self.s})!")
227 self.s += other.s
228 return self
229
230 def __eq__(self, other):
231 return (
232 isinstance(other, Script.String)
233 and self.safe == other.safe
234 and self.inline == other.inline
235 and self.s == other.s
236 )
237
238 def __hash__(self):
239 return hash((self.s, self.safe, self.inline))
240
241 def unwrap(self):
242 """
243 Returns the underlying string object.
244
245 Returns:
246 str
247 """
248 return self.s
249
250 DATA_LOADER_NAME = String("data_loader", safe=True, inline=True)
251
252 def __init__(self, summary=None, always_create_runners=True):
253 """
254 Args:

Callers 15

test_trtexec_pathMethod · 0.90
test_use_cuda_graphMethod · 0.90
test_avg_runsMethod · 0.90
test_bestMethod · 0.90
test_durationMethod · 0.90
test_deviceMethod · 0.90
test_streamsMethod · 0.90
test_min_timingMethod · 0.90
test_avg_timingMethod · 0.90
test_expose_dmaMethod · 0.90
test_trtexec_warmupMethod · 0.90

Calls 1

StringClass · 0.85

Tested by 15

test_trtexec_pathMethod · 0.72
test_use_cuda_graphMethod · 0.72
test_avg_runsMethod · 0.72
test_bestMethod · 0.72
test_durationMethod · 0.72
test_deviceMethod · 0.72
test_streamsMethod · 0.72
test_min_timingMethod · 0.72
test_avg_timingMethod · 0.72
test_expose_dmaMethod · 0.72
test_trtexec_warmupMethod · 0.72