Browse Source

!26266 Fix LessEqual

Merge pull request !26266 from zuochuanyong/fix_less_than_gpu
tags/v1.6.0
i-robot Gitee 4 years ago
parent
commit
4dc5beb839
2 changed files with 7 additions and 4 deletions
  1. +1
    -1
      mindspore/ccsrc/backend/kernel_compiler/gpu/cuda_impl/broadcast_impl.cu
  2. +6
    -3
      tests/st/ops/gpu/test_lessequal_op.py

+ 1
- 1
mindspore/ccsrc/backend/kernel_compiler/gpu/cuda_impl/broadcast_impl.cu View File

@@ -88,7 +88,7 @@ struct LessEqualFunc<half> {
template <>
struct LessEqualFunc<float> {
__device__ __host__ __forceinline__ bool operator()(const float &lhs, const float &rhs) {
return std::abs(lhs - rhs) < 1e-9 ? true : (lhs < rhs);
return lhs <= rhs;
}
};



+ 6
- 3
tests/st/ops/gpu/test_lessequal_op.py View File

@@ -59,10 +59,13 @@ def test_lessequal():
x7 = Tensor(np.array([[1, 2, 3]]).astype(np.int8))
y7 = Tensor(np.array([[2]]).astype(np.int8))
expect7 = np.array([[True, True, False]])
x8 = Tensor(np.array([[6.67054e-10, 6.67054e-10]]).astype(np.float32))
y8 = Tensor(np.array([[0, 6.67054e-10]]).astype(np.float32))
expect8 = np.array([[False, True]])

x = [x, x1, x2, x3, x4, x5, x6, x7]
y = [y, y1, y2, y3, y4, y5, y6, y7]
expect = [expect, expect1, expect2, expect3, expect4, expect5, expect6, expect7]
x = [x, x1, x2, x3, x4, x5, x6, x7, x8]
y = [y, y1, y2, y3, y4, y5, y6, y7, y8]
expect = [expect, expect1, expect2, expect3, expect4, expect5, expect6, expect7, expect8]

context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU")
lessequal = Net()


Loading…
Cancel
Save