diff --git a/mindspore/ccsrc/frontend/operator/prim_structures.cc b/mindspore/ccsrc/frontend/operator/prim_structures.cc index 1d1e6376d0f37b6c8986016c234ae2c642ced135..cc53f9aa2288eb35abe6b9d35a3884ce4bae4552 100644 --- a/mindspore/ccsrc/frontend/operator/prim_structures.cc +++ b/mindspore/ccsrc/frontend/operator/prim_structures.cc @@ -150,11 +150,12 @@ AbstractBasePtr InferImplMakeSlice(const AnalysisEnginePtr &, const PrimitivePtr for (size_t index = 0; index < args_size; index++) { MS_EXCEPTION_IF_NULL(args_spec_list[index]); if (!args_spec_list[index]->isa() && !args_spec_list[index]->isa()) { - MS_LOG(EXCEPTION) << "MakeSlice eval " << index << " parameter is neither AbstractScalar nor AbstractNone."; + MS_EXCEPTION(TypeError) << "MakeSlice eval " << index << " parameter is neither AbstractScalar nor AbstractNone."; } if (args_spec_list[index]->isa() && !dyn_cast(args_spec_list[index])->BuildValue()->isa()) { - MS_LOG(EXCEPTION) << "MakeSlice eval " << index << " parameter is an AbstractScalar, but is not an int32 number."; + MS_EXCEPTION(TypeError) << "MakeSlice eval " << index + << " parameter is an AbstractScalar, but is not an int32 number."; } } // Slice: start, end, step diff --git a/tests/ut/python/ops/test_tuple_slice.py b/tests/ut/python/ops/test_tuple_slice.py index 1475c177f4a0440498916eb64f8d6760bf8952dd..bfa573b8dfeeef2e90cc81cb180948c6201cf085 100644 --- a/tests/ut/python/ops/test_tuple_slice.py +++ b/tests/ut/python/ops/test_tuple_slice.py @@ -114,13 +114,13 @@ test_cases = [ test_cases_for_verify_exception = [ ('SliceStartCross', { - 'block': (NetWork_3(), {'exception': RuntimeError}), + 'block': (NetWork_3(), {'exception': TypeError}), 'desc_inputs': [Tensor(np.ones([2, 3, 4], np.int32)), Tensor(np.zeros([2, 3, 4], np.int32)), Tensor(np.ones([2, 3, 4], np.int32))], }), ('SliceStepZero', { - 'block': (NetWork_3(), {'exception': RuntimeError}), + 'block': (NetWork_3(), {'exception': TypeError}), 'desc_inputs': [Tensor(np.ones([2, 3, 4], np.int32)), Tensor(np.zeros([2, 3, 4], np.int32)), Tensor(np.ones([2, 3, 4], np.int32))],