Oneflow-Inc / oneflow

OneFlow is a deep learning framework designed to be user-friendly, scalable and efficient.
http://www.oneflow.org
Apache License 2.0
5.79k stars 658 forks source link

oneflow.amax perform differently between cpu and cuda when dim=1 #10473

Open Redmept1on opened 3 months ago

Redmept1on commented 3 months ago

Summary

oneflow.softmax perform differently between cpu and cuda when dim=1

Code to reproduce bug

import oneflow as flow
import numpy as np

x1 = flow.tensor(np.array([[float('inf'), 0, -1, float('nan'), 5]], dtype=np.float32))
x1 = x1.cuda()
y1 = flow.amax(x1,dim=1)
print(y1.device,y1)

x1 = flow.tensor(np.array([[float('inf'), 0, -1, float('nan'), 5]], dtype=np.float32))
x1 = x1.cpu()
y2 = flow.amax(x1,dim=1)
print(y2.device,y2)

image

System Information

Redmept1on commented 3 months ago

oneflow.amin has the same issue

import oneflow as flow
import numpy as np

x1 = flow.tensor(np.array([[float('inf'), 0, -1, float('nan'), 5]], dtype=np.float32))
x1 = x1.cuda()
y1 = flow.amin(x1,dim=1)
print(y1.device,y1)

x1 = flow.tensor(np.array([[float('inf'), 0, -1, float('nan'), 5]], dtype=np.float32))
x1 = x1.cpu()
y2 = flow.amin(x1,dim=1)
print(y2.device,y2)

image