oneflow icon indicating copy to clipboard operation
oneflow copied to clipboard

oneflow.max/min perform differently between cpu and cuda.

Open Redempt1onzzZZ opened this issue 1 year ago • 1 comments

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)

image

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)

image

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

Redempt1onzzZZ avatar Apr 01 '24 03:04 Redempt1onzzZZ

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)

image

Redempt1onzzZZ avatar Apr 01 '24 03:04 Redempt1onzzZZ