Commit f108953
Thiago Crepaldi
Remove unnecessary constant outputs from ONNX exported graph
TracingAdapter creates extra outputs (through flatten_to_tuple) to store
metadata to rebuild the original data format.
This is unnecessary during ONNX export as the original data will never
be reconstructed to its original format using Schema.__call__ API.
This PR suppresses such extra output constants during
torch.onnx.export() execution. Outside this API, the behavior is not
changed, ensuring BC.
Although not stricly necessary to achieve the same numerical results as
PyTorch, when a ONNX model schema is compared to PyTorch's, the diffrent
number of outputs (ONNX model will have more outputs than PyTorch) may
not only confuse users, but also result in false negative when coding
model comparison helpers.1 parent b352172 commit f108953
1 file changed
+26
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
254 | 256 | | |
255 | 257 | | |
256 | 258 | | |
| 259 | + | |
257 | 260 | | |
258 | 261 | | |
259 | 262 | | |
| |||
307 | 310 | | |
308 | 311 | | |
309 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
310 | 328 | | |
311 | 329 | | |
312 | 330 | | |
| |||
323 | 341 | | |
324 | 342 | | |
325 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
326 | 352 | | |
327 | 353 | | |
328 | 354 | | |
| |||
0 commit comments