You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Not all inputs provided are torch.tensors. Please provide torch.tensors as inputs"
358
+
)
359
+
ifoutput_formatnotinaccepted_formats:
360
+
raiseValueError(
361
+
f"Provided output_format {output_format} is not supported. Supported options are exported_program | torchscript"
362
+
)
363
+
ifnotfile_path:
364
+
raiseValueError("File path cannot be empty. Please provide a valid file path")
365
+
366
+
ifmodule_type==_ModuleType.nn:
367
+
raiseValueError(
368
+
"Input model is of type nn.Module. Saving nn.Module directly is not supported. Supported model types torch.jit.ScriptModule | torch.fx.GraphModule | torch.export.ExportedProgram."
369
+
)
370
+
elifmodule_type==_ModuleType.ts:
371
+
ifoutput_format=="exported_program":
372
+
raiseValueError(
373
+
"Provided model is a torch.jit.ScriptModule but the output_format specified is exported_program. Please verify the output_format"
374
+
)
375
+
else:
376
+
torch.jit.save(module, file_path)
377
+
elifmodule_type==_ModuleType.ep:
378
+
ifoutput_format=="torchscript":
379
+
raiseValueError(
380
+
"Provided model is a torch.export.ExportedProgram but the output_format specified is torchscript. Please verify the output_format"
381
+
)
382
+
else:
383
+
torch.export.save(module, file_path)
384
+
elifmodule_type==_ModuleType.fx:
385
+
ifnotinputs:
386
+
raiseValueError(
387
+
"Provided model is a torch.fx.GraphModule however the inputs are empty. Please provide valid torch.tensors as inputs to trace and save the model"
Copy file name to clipboardExpand all lines: py/torch_tensorrt/dynamo/_exporter.py
+3-14Lines changed: 3 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -18,27 +18,16 @@
18
18
defexport(
19
19
gm: torch.fx.GraphModule,
20
20
inputs: Sequence[torch.Tensor],
21
-
output_format: str,
22
21
) ->ExportedProgram:
23
22
"""Export the result of TensorRT compilation into the desired output format.
24
23
25
24
Arguments:
26
25
gm (torch.fx.GraphModule): Compiled Torch-TensorRT module, generated by ``torch_tensorrt.dynamo.compile``
27
26
inputs (torch.Tensor): Torch input tensors
28
-
output_format (str): Output format of the result of TRT compilation. Options include "exported_program" (or) "ep" | "torchscript" (or) "ts" | "graph_module" (or) "fx". Default is "exported_program"
Copy file name to clipboardExpand all lines: py/torch_tensorrt/dynamo/_settings.py
-3Lines changed: 0 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,6 @@
19
19
MIN_BLOCK_SIZE,
20
20
NUM_AVG_TIMING_ITERS,
21
21
OPTIMIZATION_LEVEL,
22
-
OUTPUT_FORMAT,
23
22
PASS_THROUGH_BUILD_FAILURES,
24
23
PRECISION,
25
24
REFIT,
@@ -71,7 +70,6 @@ class CompilationSettings:
71
70
TRT Engines. Prints detailed logs of the graph structure and nature of partitioning. Optionally saves the
72
71
ouptut to a file if a string path is specified
73
72
hardware_compatible (bool): Build the TensorRT engines compatible with GPU architectures other than that of the GPU on which the engine was built (currently works for NVIDIA Ampere and newer)
74
-
output_format (str): Output format of the result of TRT compilation. Options include "exported_program" (or) "ep" | "torchscript" (or) "ts" | "graph_module" (or) "fx". Default is "exported_program"
0 commit comments