Skip to content

Commit d7ee11c

Browse files
authored
Update the code snippet
1 parent 618bc00 commit d7ee11c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

_mobile/ios.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,14 @@ Starting from 1.4.0, PyTorch supports custom build. You can now build the PyTorc
200200

201201
1\. Verify your PyTorch version is 1.4.0 or above. You can do that by checking the value of `torch.__version__`.
202202

203-
2\. To dump the operators in your model, run the following lines of Python code:
203+
2\. To dump the operators in your model, say `MobileNetV2`, run the following lines of Python code:
204204

205205
```python
206206
import torch, yaml
207-
model = torch.jit.load("example.pt")
208-
ops = torch.jit.export_opnames(m)
209-
f = open('example.yaml', 'w')
210-
yaml.dump(ops, f)
207+
model = torch.jit.load('MobileNetV2.pt')
208+
ops = torch.jit.export_opnames(model)
209+
with open('MobileNetV2.yaml', 'w') as output:
210+
yaml.dump(ops, output)
211211
```
212212
In the snippet above, you first need to load the ScriptModule. Then, use `export_opnames` to return a list of operator names of the ScriptModule and its submodules. Lastly, save the result in a yaml file.
213213

0 commit comments

Comments
 (0)