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

Method save

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

Save this script to the specified destination. Args: dest (file-like): A file-like object that defines ``write()``, ``flush()``, ``isatty``, and has a ``name`` attribute.

(self, dest)

Source from the content-addressed store, hash-verified

437 return script
438
439 def save(self, dest):
440 """
441 Save this script to the specified destination.
442
443 Args:
444 dest (file-like):
445 A file-like object that defines ``write()``, ``flush()``, ``isatty``, and has a ``name`` attribute.
446 """
447 path = dest.name
448 # Somehow, piping fools isatty, e.g. `polygraphy run --gen-script - | cat`
449 is_file = not dest.isatty() and path not in ["<stdout>", "<stderr>"]
450
451 dest.write(str(self))
452 dest.flush()
453
454 if is_file:
455 G_LOGGER.info(f"Writing script to: {path}")
456 # Make file executable
457 os.chmod(path, os.stat(path).st_mode | 0o111)

Callers 15

run_implMethod · 0.95
run_implMethod · 0.95
run_implMethod · 0.95
run_implMethod · 0.95
test_save_vectorsMethod · 0.45
calibrate_modelFunction · 0.45
generate.pyFile · 0.45
replace.pyFile · 0.45
fold.pyFile · 0.45
generate.pyFile · 0.45
generate.pyFile · 0.45
isolate.pyFile · 0.45

Calls 2

writeMethod · 0.80
infoMethod · 0.45

Tested by 4

test_save_vectorsMethod · 0.36
test_tacticsMethod · 0.36
replayFunction · 0.36
test_save_loadMethod · 0.36