Git Product home page Git Product logo

Comments (3)

ezyang avatar ezyang commented on July 19, 2024

UnsupportedOperatorError: Exporting the operator 'aten::select_backward' to ONNX opset version 17 is not supported

I mean, sounds like you're gonna have a bad time, because ONNX's operator set is insufficient for backwards/training

from pytorch.

thisisd3 avatar thisisd3 commented on July 19, 2024

That's quite strange because this self contained example

import torch
import onnxruntime as ort
import numpy as np

class F(torch.nn.Module):
    def forward(self, X):
        y = X.square().sum()
        return torch.autograd.grad(y, X, create_graph=True, retain_graph=True)

f = F()
X = torch.arange(3).to(torch.float32)
X.requires_grad_(True)
test_out = f(X)
print(test_out)

X2 = torch.arange(3).to(torch.float32)
X2.requires_grad_(True)
torch.onnx.export(f, X2,'test.onnx', input_names=['X'],
            output_names=['out'])

inArray = np.arange(3).astype(np.float32)
ort_sess = ort.InferenceSession('test.onnx')
outputs = ort_sess.run(None, {'X': inArray})

print("input:", inArray)
print("output:", outputs[0])

also uses autograd and tracks the gradient, and runs absolutely fine. I'm not sure I understand why it works fine tracking a scalar with autograd.grad, but fails when it comes to the multivariate jacobian.

from pytorch.

ezyang avatar ezyang commented on July 19, 2024

I mean, how complicated your backward graph is depends on your model. If you're lucky you'll hit everything in the onnx opset. But we have some pretty strange backward ops and onnx doesn't always have full coverage.

from pytorch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.