mindspore-ai / mindspore

MindSpore is a new open source deep learning training/inference framework that could be used for mobile, edge and cloud scenarios.
https://gitee.com/mindspore/mindspore
Apache License 2.0
4.31k stars 709 forks source link

[Bug] mindspore.ops.amax/amin perform differently between cpu and gpu when axis=1 #275

Closed Redmept1on closed 7 months ago

Redmept1on commented 7 months ago

Environment

Hardware Environment(Ascend/GPU/CPU):

/device gpu
/device cpu

Software Environment:

Describe the current behavior

mindspore.ops.amax/min perform differently between cpu and gpu when axis=1

Describe the expected behavior

get the same result

Steps to reproduce the issue

amax

from mindspore import set_context
import mindspore.ops as ops
import mindspore as mind
import numpy as np

set_context(device_target="CPU")
x1 = mind.tensor(np.array([[float('inf'), 0, -1, float('nan'), 5]], dtype=np.float32))
y1 = ops.amax(x1,axis=1)
print(y1)

set_context(device_target="GPU")
x2 = mind.tensor(np.array([[float('inf'), 0, -1, float('nan'), 5]], dtype=np.float32))
y2 = ops.amax(x2,axis=1)
print(y2)

image

amin

from mindspore import set_context
import mindspore.ops as ops
import mindspore as mind
import numpy as np

set_context(device_target="CPU")
x1 = mind.tensor(np.array([[float('inf'), 0, -1, float('nan'), 5]], dtype=np.float32))
y1 = ops.amin(x1,axis=1)
print(y1)

set_context(device_target="GPU")
x2 = mind.tensor(np.array([[float('inf'), 0, -1, float('nan'), 5]], dtype=np.float32))
y2 = ops.amin(x2,axis=1)
print(y2)

image