From 3f147665b5ae1a121212345da442ef46fa9d9fa5 Mon Sep 17 00:00:00 2001 From: JiangZhaoh Date: Wed, 20 Nov 2019 06:31:22 +0000 Subject: [PATCH] fix lint and compile error --- src/operator/numpy/np_insert_op-inl.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/operator/numpy/np_insert_op-inl.h b/src/operator/numpy/np_insert_op-inl.h index f6e8c591798e..aa8df33e6e1b 100644 --- a/src/operator/numpy/np_insert_op-inl.h +++ b/src/operator/numpy/np_insert_op-inl.h @@ -162,8 +162,8 @@ struct InsertSingleIndexForward { } int64_t dest_idx; IType index = in_obj[0]; - if (index < 0) { - index += N; + if (static_cast(index) < 0) { + index += static_cast(N); } if (out_mid >= index && out_mid < index + numnew) { int idx_val = out_mid - index; @@ -271,8 +271,8 @@ struct SliceToIndices { MSHADOW_XINLINE static void Map(int i, IType* indices, int N, int start, int step) { indices[i] = start + i * step; - if (indices[i] < 0) { - indices[i] += N; + if (static_cast(indices[i]) < 0) { + indices[i] += static_cast(N); } } }; @@ -282,8 +282,8 @@ struct ObjToIndices { MSHADOW_XINLINE static void Map(int i, IType* indices, int N, const IType* obj) { indices[i] = obj[i]; - if (indices[i] < 0) { - indices[i] += N; + if (static_cast(indices[i]) < 0) { + indices[i] += static_cast(N); } } }; @@ -380,7 +380,7 @@ void NumpyInsertCompute(const nnvm::NodeAttrs& attrs, int N = arr.shape_[axis]; mxnet::TShape newshape(arr.shape_); size_t indices_len = 0; - int start, stop, step; + int start = 0, stop = 0, step = 0; // get and check indices from slice or sequence of ints if (inputs.size() == 3U) { @@ -405,7 +405,7 @@ void NumpyInsertCompute(const nnvm::NodeAttrs& attrs, indices_len = static_cast(seq_cnt); } - int numnew, index; + int numnew, index = 0; mxnet::TShape val_newshape(arr.shape_.ndim(), -1); for (int i = inputs[insert_::kValues].shape_.ndim() - 1, j = arr.shape_.ndim() - 1; i >= 0 || j >= 0; --i, --j) { @@ -543,10 +543,11 @@ void NumpyInsertCompute(const nnvm::NodeAttrs& attrs, Kernel, xpu>::Launch(s, outshape.Size(), outputs[insert_::kOut].dptr(), values.dptr(), arr.dptr(), - k_outshape, k_valshape, + k_outshape, k_valshape, N, inputs[insert_::kObj].dptr(), numnew, - val_strides, old_val_strides, arr_strides, out_strides, - arr.shape_.ndim(), values.shape_.ndim(), + val_strides, old_val_strides, + arr_strides, out_strides, + arr.shape_.ndim(), values.shape_.ndim(), outshape.ndim(), axis, false); }); }