From c8d60ccc1ea49254fa5fb3c2d3a4cfac9a00e443 Mon Sep 17 00:00:00 2001 From: qiuzhongya Date: Fri, 2 Aug 2024 14:33:29 +0800 Subject: [PATCH] fix bug --- .../kernel/ascend/opapi/aclnn/cummax_aclnn_kernel.cc | 11 +++++------ .../kernel/ascend/opapi/aclnn/cummax_aclnn_kernel.h | 1 + .../ascend/opapi/aclnn/cummin_ext_aclnn_kernel.cc | 11 +++++------ .../ascend/opapi/aclnn/cummin_ext_aclnn_kernel.h | 1 + tests/st/ops/test_ops_cummax.py | 2 +- tests/st/ops/test_ops_cummin.py | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mindspore/ops/kernel/ascend/opapi/aclnn/cummax_aclnn_kernel.cc b/mindspore/ops/kernel/ascend/opapi/aclnn/cummax_aclnn_kernel.cc index e70743de078..741736b6bdd 100644 --- a/mindspore/ops/kernel/ascend/opapi/aclnn/cummax_aclnn_kernel.cc +++ b/mindspore/ops/kernel/ascend/opapi/aclnn/cummax_aclnn_kernel.cc @@ -22,17 +22,16 @@ namespace kernel { void CummaxAscend::GetWorkSpaceInfo(const std::vector &inputs, const std::vector &outputs) { - auto axis = transform::ConvertKernelTensor(inputs[kIndex1]); - GetWorkspaceForResize(inputs[kIndex0], axis, outputs[kIndex0], outputs[kIndex1]); + axis_ = transform::ConvertKernelTensor(inputs[kIndex1]); + auto input_shape = inputs[kIndex0]->GetShape()->GetShapeVector(); + axis_ = axis_ < 0 ? axis_ + SizeToLong(input_shape.size()) : axis_; + GetWorkspaceForResize(inputs[kIndex0], axis_, outputs[kIndex0], outputs[kIndex1]); } bool CummaxAscend::Launch(const std::vector &inputs, const std::vector &workspace, const std::vector &outputs, void *stream_ptr) { MS_EXCEPTION_IF_NULL(stream_ptr); - auto axis = transform::ConvertKernelTensor(inputs[kIndex1]); - auto input_shape = inputs[kIndex0]->GetShape()->GetShapeVector(); - axis = axis < 0 ? axis + SizeToLong(input_shape.size()) : axis; - RunOp(stream_ptr, workspace, inputs[kIndex0], axis, outputs[kIndex0], outputs[kIndex1]); + RunOp(stream_ptr, workspace, inputs[kIndex0], axis_, outputs[kIndex0], outputs[kIndex1]); return true; } diff --git a/mindspore/ops/kernel/ascend/opapi/aclnn/cummax_aclnn_kernel.h b/mindspore/ops/kernel/ascend/opapi/aclnn/cummax_aclnn_kernel.h index a91ba724ee7..de09bd82bd8 100644 --- a/mindspore/ops/kernel/ascend/opapi/aclnn/cummax_aclnn_kernel.h +++ b/mindspore/ops/kernel/ascend/opapi/aclnn/cummax_aclnn_kernel.h @@ -33,6 +33,7 @@ class CummaxAscend : public AclnnKernelMod { void GetWorkSpaceInfo(const std::vector &inputs, const std::vector &outputs) override; private: + int64_t axis_; DEFINE_GET_WORKSPACE_FOR_RESIZE() }; } // namespace kernel diff --git a/mindspore/ops/kernel/ascend/opapi/aclnn/cummin_ext_aclnn_kernel.cc b/mindspore/ops/kernel/ascend/opapi/aclnn/cummin_ext_aclnn_kernel.cc index dbd41108e11..9e08b315145 100644 --- a/mindspore/ops/kernel/ascend/opapi/aclnn/cummin_ext_aclnn_kernel.cc +++ b/mindspore/ops/kernel/ascend/opapi/aclnn/cummin_ext_aclnn_kernel.cc @@ -22,17 +22,16 @@ namespace kernel { void CumminExtAscend::GetWorkSpaceInfo(const std::vector &inputs, const std::vector &outputs) { - auto dim = transform::ConvertKernelTensor(inputs[kIndex1]); - GetWorkspaceForResize(inputs[kIndex0], dim, outputs[kIndex0], outputs[kIndex1]); + dim_ = transform::ConvertKernelTensor(inputs[kIndex1]); + auto input_shape = inputs[kIndex0]->GetShape()->GetShapeVector(); + dim_ = dim_ < 0 ? dim_ + SizeToLong(input_shape.size()) : dim_; + GetWorkspaceForResize(inputs[kIndex0], dim_, outputs[kIndex0], outputs[kIndex1]); } bool CumminExtAscend::Launch(const std::vector &inputs, const std::vector &workspace, const std::vector &outputs, void *stream_ptr) { MS_EXCEPTION_IF_NULL(stream_ptr); - auto dim = transform::ConvertKernelTensor(inputs[kIndex1]); - auto input_shape = inputs[kIndex0]->GetShape()->GetShapeVector(); - dim = dim < 0 ? dim + SizeToLong(input_shape.size()) : dim; - RunOp(stream_ptr, workspace, inputs[kIndex0], dim, outputs[kIndex0], outputs[kIndex1]); + RunOp(stream_ptr, workspace, inputs[kIndex0], dim_, outputs[kIndex0], outputs[kIndex1]); return true; } diff --git a/mindspore/ops/kernel/ascend/opapi/aclnn/cummin_ext_aclnn_kernel.h b/mindspore/ops/kernel/ascend/opapi/aclnn/cummin_ext_aclnn_kernel.h index 5694fe84fdd..d940a9b04c3 100644 --- a/mindspore/ops/kernel/ascend/opapi/aclnn/cummin_ext_aclnn_kernel.h +++ b/mindspore/ops/kernel/ascend/opapi/aclnn/cummin_ext_aclnn_kernel.h @@ -33,6 +33,7 @@ class CumminExtAscend : public AclnnKernelMod { void GetWorkSpaceInfo(const std::vector &inputs, const std::vector &outputs) override; private: + int64_t dim_; DEFINE_GET_WORKSPACE_FOR_RESIZE() }; } // namespace kernel diff --git a/tests/st/ops/test_ops_cummax.py b/tests/st/ops/test_ops_cummax.py index 4393048b326..559d659a5de 100644 --- a/tests/st/ops/test_ops_cummax.py +++ b/tests/st/ops/test_ops_cummax.py @@ -40,7 +40,7 @@ def cummax_vmap_func(x, axis): return ops.vmap(cummax_forward_func, in_axes=(0, None), out_axes=(0, None))(x, axis) -@pytest.mark.level1 +@pytest.mark.level0 @pytest.mark.env_onecard @pytest.mark.platform_arm_ascend_training @pytest.mark.parametrize('mode', ['pynative', 'KBK']) diff --git a/tests/st/ops/test_ops_cummin.py b/tests/st/ops/test_ops_cummin.py index 0df157c6a63..df23fc7788a 100644 --- a/tests/st/ops/test_ops_cummin.py +++ b/tests/st/ops/test_ops_cummin.py @@ -40,7 +40,7 @@ def cummin_vmap_func(x, axis): return ops.vmap(cummin_forward_func, in_axes=(0, None), out_axes=(0, None))(x, axis) -@pytest.mark.level1 +@pytest.mark.level0 @pytest.mark.env_onecard @pytest.mark.platform_arm_ascend_training @pytest.mark.parametrize('mode', ['pynative', 'KBK']) -- Gitee