oneflow
oneflow copied to clipboard
oneflow.max/min perform differently between cpu and cuda.
Summary
oneflow.max/min perform differently between cpu and cuda.
Code to reproduce bug
oneflow.max
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.max(x1,dim=1)
print(y1)
x1 = flow.tensor(np.array([[float('inf'), 0, -1, float('nan'), 5]], dtype=np.float32))
x1 = x1.cpu()
y2 = flow.max(x1,dim=1)
print(y2)
oneflow.min
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.min(x1,dim=1)
print(y1)
x1 = flow.tensor(np.array([[float('inf'), 0, -1, float('nan'), 5]], dtype=np.float32))
x1 = x1.cpu()
y2 = flow.min(x1,dim=1)
print(y2)
System Information
- What is your OneFlow installation :dockerhub
- OS:Linux
- OneFlow version (run python3 -m oneflow --doctor):0.9.1.dev20231024+cu117
- Python version: 3.8
oneflow.median has the same 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.median(x1,dim=1)
print(y1)
x1 = flow.tensor(np.array([[float('inf'), 0, -1, float('nan'), 5]], dtype=np.float32))
x1 = x1.cpu()
y2 = flow.median(x1,dim=1)
print(y2)