question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MaxPool op resolved as Aten OP

See original GitHub issue

I created a small model training script, to test out maxpool gradient op for OneDNN EP, and the model definition below was used. But for some reason, the maxpool was resolved to Aten Op in the onnx graph. Is there a way to force torch-ort to use maxpool instead aten op? (maybe by disabling use of aten ops?)

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(1, 10, kernel_size=5)
        self.conv2 = nn.Conv2d(10, 20, kernel_size=5)
        self.maxpool1 = nn.MaxPool2d(2)
        self.maxpool2 = nn.MaxPool2d(2)
        #self.conv2_drop = nn.Dropout2d()
        self.fc1 = nn.Linear(320, 50)
        self.fc2 = nn.Linear(50, 10)

    def forward(self, x):
        x = F.relu(self.maxpool1(self.conv1(x)))
        x = F.relu(self.maxpool2(self.conv2(x)))
        x = x.view(-1, 320)
        x = F.relu(self.fc1(x))
        x = F.dropout(x, training=self.training)
        x = self.fc2(x)
        return F.log_softmax(x)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
baijumeswanicommented, Apr 6, 2022

@chethanpk I just tried this on my end as well. If I comment out this code in my local pip directory, I can avoid generating the Aten nodes that you’re seeing in your graph. Here is the sample I am using (from you example):

import torch.nn as nn
import torch.nn.functional as F
import torch
from onnxruntime.training import ORTModule

from onnxruntime.training.ortmodule import DebugOptions

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(1, 10, kernel_size=5)
        self.conv2 = nn.Conv2d(10, 20, kernel_size=5)
        self.maxpool1 = nn.MaxPool2d(2)
        self.maxpool2 = nn.MaxPool2d(2)
        #self.conv2_drop = nn.Dropout2d()
        self.fc1 = nn.Linear(320, 50)
        self.fc2 = nn.Linear(50, 10)

    def forward(self, x):
        x = F.relu(self.maxpool1(self.conv1(x)))
        x = F.relu(self.maxpool2(self.conv2(x)))
        x = x.view(-1, 320)
        x = F.relu(self.fc1(x))
        x = F.dropout(x, training=self.training)
        x = self.fc2(x)
        return F.log_softmax(x)

x = torch.randn([1, 1, 30, 30], dtype=torch.float32)
net = ORTModule(Net(), DebugOptions(save_onnx=True, onnx_prefix='test'))
out = net(x)
print(out)

Here is the graph I get: image

1reaction
chethanpkcommented, Apr 8, 2022

Rebuilding the wheel worked, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

onnx/Operators.md at main - GitHub
This op uses the population size (N) for calculating variance, and not the sample size N-1. Type Constraints. T : tensor(float16), tensor(float), tensor(double) ......
Read more >
torch.onnx — PyTorch 1.13 documentation
When export fails due to an unconvertible ATen op, there may in fact be more than one such op but the error message...
Read more >
docs/source/onnx.rst - PyTorch - Fossies
ATen is PyTorch's built-in tensor library. If the operator is an ATen operator (shows up in the TorchScript graph with the prefix aten::...
Read more >
torch.onnx — PyTorch master documentation
This mode is used to export all operators as ATen ops, and avoid conversion to ONNX. Example torch ir graph: graph(%0 : Float(2:12,...
Read more >
torch.onnx — PyTorch master documentation
Make sure the function has the same name as the ATen operator/function defined in VariableType.h . The first parameter is always the exported...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found