Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix lint and compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
JiangZhaoh committed Nov 20, 2019
1 parent 97e01f5 commit 3f14766
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/operator/numpy/np_insert_op-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ struct InsertSingleIndexForward {
}
int64_t dest_idx;
IType index = in_obj[0];
if (index < 0) {
index += N;
if (static_cast<int64_t>(index) < 0) {
index += static_cast<IType>(N);
}
if (out_mid >= index && out_mid < index + numnew) {
int idx_val = out_mid - index;
Expand Down Expand Up @@ -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<int64_t>(indices[i]) < 0) {
indices[i] += static_cast<IType>(N);
}
}
};
Expand All @@ -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<int64_t>(indices[i]) < 0) {
indices[i] += static_cast<IType>(N);
}
}
};
Expand Down Expand Up @@ -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) {
Expand All @@ -405,7 +405,7 @@ void NumpyInsertCompute(const nnvm::NodeAttrs& attrs,
indices_len = static_cast<size_t>(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) {
Expand Down Expand Up @@ -543,10 +543,11 @@ void NumpyInsertCompute(const nnvm::NodeAttrs& attrs,
Kernel<InsertSingleIndexForward<req_type>, xpu>::Launch(s, outshape.Size(),
outputs[insert_::kOut].dptr<DType>(),
values.dptr<DType>(), arr.dptr<DType>(),
k_outshape, k_valshape,
k_outshape, k_valshape,
N, inputs[insert_::kObj].dptr<IType>(), 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);
});
}
Expand Down

0 comments on commit 3f14766

Please sign in to comment.