-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bf1cd6
commit 283e0d8
Showing
9 changed files
with
210 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
47 changes: 47 additions & 0 deletions
47
crates/burn-import/onnx-tests/tests/reduce_min/reduce_min.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
#!/usr/bin/env python3 | ||
|
||
# used to generate model: onnx-tests/tests/reduce_min/reduce_min.onnx | ||
|
||
import torch | ||
import torch.nn as nn | ||
|
||
|
||
class Model(nn.Module): | ||
def __init__(self): | ||
super(Model, self).__init__() | ||
|
||
def forward(self, x): | ||
return ( | ||
# ReduceMin, keepdims=0, axes=None | ||
torch.min(x), | ||
# ReduceMin, keepdims=1, axes=[1] | ||
torch.min(x, dim=1, keepdim=True).values, | ||
# ReduceMin, keepdims=1, axes=[-1] | ||
torch.min(x, dim=-1, keepdim=True).values, | ||
) | ||
|
||
|
||
def main(): | ||
# Set random seed for reproducibility | ||
torch.manual_seed(0) | ||
|
||
# Export to onnx | ||
model = Model() | ||
model.eval() | ||
device = torch.device("cpu") | ||
onnx_name = "reduce_min.onnx" | ||
test_input = torch.tensor([[[[1.0, 4.0, 9.0, 25.0]]]], device=device) | ||
|
||
torch.onnx.export(model, test_input, onnx_name, verbose=False, opset_version=16) | ||
|
||
print(f"Finished exporting model to {onnx_name}") | ||
|
||
# Output some test data for use in the test | ||
print(f"Test input data: {test_input}") | ||
output = model.forward(*test_input) | ||
print(f"Test output data: {output}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters