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

No importer registered for op: Inverse. Attempting to import as plugin, torch.inverse not support to onnx #52

Open
lix19937 opened this issue Nov 4, 2024 · 0 comments

Comments

@lix19937
Copy link
Owner

lix19937 commented Nov 4, 2024

import torch
import numpy as np

class TRT_NMS_NN(torch.nn.Module): 
    def __init__(self): 
        super().__init__() 
 
    def forward(self, x, y, z): 
        return torch.inverse(x).matmul(y).matmul(z)    
        # return torch.linalg.inv(x).matmul(y).matmul(z)

sz = 3

x = torch.tensor([[4.1, 2.8, 2.1], [9.676, 6.608, 3.2], [1.1, 2.5, 0.2]])
# x = torch.from_numpy(np.ones(sz*sz).reshape(1,sz,sz)).float()
y = torch.from_numpy(np.arange(sz*sz).reshape(sz,sz)).float()
z = torch.from_numpy(np.arange(sz*sz).reshape(sz,sz)).float()

model = TRT_NMS_NN()
model(x, y, z)

print("export ...")

ops=17
output_file = "inverse" + str(ops) + ".onnx"
torch.onnx.export(
    TRT_NMS_NN(),
    (x, y, z),
    output_file,
    export_params=True,
    keep_initializers_as_inputs=True,
    do_constant_folding=True,
    verbose=True,
    opset_version=ops, #17
)
print("export done")

define torch.inverse as a custom plugin.

@lix19937 lix19937 changed the title torch.inverse not support to onnx No importer registered for op: Inverse. Attempting to import as plugin, torch.inverse not support to onnx Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant