File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 227
227
# normalization layers to evaluation mode before running inference.
228
228
# Failing to do this will yield inconsistent inference results.
229
229
#
230
-
230
+ # Saving an ExportedProgram
231
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~
232
+ #
233
+ # If you are using torch.export, you can save and load your ExportedProgram using the
234
+ # `torch.export.save()` and `torch.export.load()` APIs. with the `.pt2` file extension.
235
+ #
236
+ # .. code-block:: python
237
+ #
238
+ # class SimpleModel(torch.nn.Module):
239
+ # def forward(self, x):
240
+ # return x + 10
241
+ #
242
+ # # Create a sample input
243
+ # sample_input = torch.randn(5)
244
+ #
245
+ # # Export the model
246
+ # exported_program = torch.export.export(SimpleModel(), sample_input)
247
+ #
248
+ # # Save the exported program
249
+ # torch.export.save(exported_program, 'exported_program.pt2')
250
+ #
251
+ # # Load the exported program
252
+ # saved_exported_program = torch.export.load('exported_program.pt2')
253
+ #
231
254
232
255
######################################################################
233
256
# Saving & Loading a General Checkpoint for Inference and/or Resuming Training
You can’t perform that action at this time.
0 commit comments