Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diff tool #168

Merged
merged 15 commits into from
Aug 26, 2024
Prev Previous commit
Next Next commit
Diff
  • Loading branch information
justinchuby committed Aug 26, 2024
commit babf4fc1133c1634bca9a3c9776095765ac18f41
26 changes: 26 additions & 0 deletions tests/models/senet154_diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import torch
import torch_onnx
import torch_onnx.tools
import torch_onnx.tools.diff_model
from monai.networks.nets import SENet154


def main():
model = SENet154(spatial_dims=3, in_channels=2, num_classes=2).eval()
data = (torch.randn(2, 2, 64, 64, 64),)
# torch_onnx.export(model, data, verify=True, report=True)
ep = torch.export.export(model, data)
onnx_program = torch_onnx.export(model, data)
onnx_program.save("senet154.onnx", external_data=True)
results = torch_onnx.tools.diff_model.diff_exported_program(
"senet154.onnx",
ep,
["output"],
data,
keep_original_outputs=True,
)
print(results)


if __name__ == "__main__":
main()
Loading