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

The operator 'aten::lerp.Scalar_out' is not currently supported on the DML backend and will fall back to run on the CPU. This may have performance implications. #675

Open
lovelyallen opened this issue Dec 8, 2024 · 1 comment

Comments

@lovelyallen
Copy link

lovelyallen commented Dec 8, 2024

I've encountered this warning when programming a resnet.
my torch-directml version is 0.2.5.dev20240914

this is the code:

import torch
import torch_directml
from torch import *
from torch import nn
import polars
import numpy as np
from PIL import Image
from torch import optim
from torch.optim.nadam import NAdam
from torch.optim.adam import Adam
dml=torch_directml.device()
torch.set_default_device(dml)
X=polars.read_csv("tr_x.csv").to_numpy()
X=np.delete(X,[0],1)
X=np.reshape(X,[-1,30,1,28,28])
print(X.shape)
X=tensor(X,dtype=uint8)
Y=polars.read_csv("tr_y.csv").to_numpy()
Y=np.delete(Y,[0],1)
Y=np.reshape(Y,[-1,30])
Y=tensor(Y,device="cpu")
Y=nn.functional.one_hot(Y,26).to(dml)
class Block(nn.Module):
def init(self):
super(Block,self).init();
self.conv1=nn.Conv2d(32,32,3,padding=1)
self.conv2=nn.Conv2d(32,32,3,padding=1)
self.relu=nn.ReLU()
def forward(self,x):
r=clone(x)
x=self.conv1(x)
x=self.conv2(x)
x=self.relu(x)
x=r+x
return x
mod=nn.Sequential(
nn.Conv2d(1,32,5),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
nn.Flatten(),
nn.Linear(322424,128),
nn.ReLU(),
nn.Linear(128,26),
nn.Sigmoid()
).to(dml)
epoches=100
opt=NAdam(mod.parameters())
los=nn.CrossEntropyLoss().to(dml)
for _ in range(0,epoches):
total_loss=0
total_acc=0
for i in range(0,X.shape[0]):
x=X[i.item().int()].type(float32)
y=Y[i.item().int()].type(float32)
#print(y.shape)
pred=mod(x)
opt.zero_grad()
loss:Tensor=los(pred,y)
loss.backward()
opt.step()
if (i%100==0):
print(i)

any solutions?

(I am new to here and i dont know what to do with coping. sorry for that)

@AbdullahTrees
Copy link

The developers basically have to implement this function in the back-end, really hope they fix it soon. Adam optimizer is a very basic and fundamental part of AI/ML workloads and is really important for students like us.

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

2 participants