Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions circle-mlir/models/unit/Transpose_F32_R4/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import torch


# Generate Transpose operator with Float32, Rank-4
class net_Transpose(torch.nn.Module):
def __init__(self):
super().__init__()

def forward(self, input):
# NOTE two transpose will produce NCHW to NHWC single transpose
x = torch.transpose(input, 1, 3)
return torch.transpose(x, 1, 2)
Comment on lines +11 to +12
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about input.permute(0,2,3,1)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input.permute() gives same result, but I'd like to use torch.transpose()


def onnx_opset_version(self):
# TODO set to appropriate value
return 13


_model_ = net_Transpose()

_inputs_ = torch.randn(1, 3, 6, 4)