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

wrong indices output using 'oneflow.max/min' when nan exists in tensor #10448

Open Redmept1on opened 3 months ago

Redmept1on commented 3 months ago

Summary

When nan is an element in tensor, the output of oneflow.max/min will have a value that does not correspond to indice.

Code to reproduce bug

for oneflow.max, if the values output is right, the indices should be indices=tensor([2, 2], dtype=oneflow.int64))

import oneflow as flow
import numpy as np

a = flow.tensor(np.array([[1, 2, 3], [float('nan'), 5, 6]]),dtype=flow.float32)

max_flow = flow.max(a,dim=1)
print(max_flow)

image

for oneflow.min, if the values output is right, the indices should be indices=tensor([0, 1], dtype=oneflow.int64))

import oneflow as flow
import numpy as np

a = flow.tensor(np.array([[1, 2, 3], [float('nan'), 5, 6]]),dtype=flow.float32)

min_flow = flow.min(a,dim=1)
print(min_flow)

image

System Information