Skip to content

Commit

Permalink
fix the rest of TShape constructor errors (apache#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-haibin-lin authored May 19, 2017
1 parent 2881185 commit 3bcb9f2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/operator/tensor/elemwise_binary_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void BinaryComputeRspRsp(const nnvm::NodeAttrs& attrs,
// need to subtract the number of common rows
unsigned int num_rows_l = lhs.aux_shape(rowsparse::kIdx).Size();
unsigned int num_rows_r = rhs.aux_shape(rowsparse::kIdx).Size();
output.CheckAndAlloc({TShape({num_rows_l + num_rows_r})});
output.CheckAndAlloc({mshadow::Shape1(num_rows_l + num_rows_r)});
mshadow::Stream<xpu> *s = ctx.get_stream<xpu>();
MSHADOW_TYPE_SWITCH(output.dtype(), DType, {
MSHADOW_TYPE_SWITCH(lhs.aux_type(rowsparse::kIdx), IType, {
Expand Down
6 changes: 3 additions & 3 deletions src/operator/tensor/elemwise_unary_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void CastStorageDnsCsrImpl(mshadow::Stream<xpu> *s, const TBlob& dns, NDArray* c
NDARRAY_IDX_TYPE_SWITCH(csr->aux_type(csr::kIdx), CType, { // col idx type
const index_t num_rows = dns.shape_[0];
const index_t num_cols = dns.shape_[1];
csr->CheckAndAllocAuxData(csr::kIndPtr, TShape({num_rows+1}));
csr->CheckAndAllocAuxData(csr::kIndPtr, mshadow::Shape1(num_rows+1));
IType* indptr = csr->aux_data(csr::kIndPtr).dptr<IType>();
DType* dns_data = dns.dptr<DType>();
mxnet_op::Kernel<FillCsrIndPtr, xpu>::Launch(s, num_rows, indptr,
Expand All @@ -432,8 +432,8 @@ void CastStorageDnsCsrImpl(mshadow::Stream<xpu> *s, const TBlob& dns, NDArray* c
indptr[i+1] += indptr[i];
}
// allocate column idx array and value array
csr->CheckAndAllocAuxData(csr::kIdx, TShape({static_cast<index_t>(indptr[num_rows])}));
csr->CheckAndAllocData(TShape({static_cast<index_t>(indptr[num_rows])}));
csr->CheckAndAllocAuxData(csr::kIdx, mshadow::Shape1(static_cast<index_t>(indptr[num_rows])));
csr->CheckAndAllocData(mshadow::Shape1(static_cast<index_t>(indptr[num_rows])));
// fill col_idx and value arrays of the csr
mxnet_op::Kernel<FillCsrColIdxAndVals, xpu>::Launch(s, num_rows,
csr->data().dptr<DType>(), csr->aux_data(csr::kIdx).dptr<CType>(),
Expand Down
2 changes: 1 addition & 1 deletion src/operator/tensor/indexing_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void SparseEmbeddingOpBackwardDnsDnsRsp(const nnvm::NodeAttrs& attrs,
<< "embedding input index and gradient row sparse type doesn't match!";
// Alloc dense output
unsigned int num_rows = output.shape()[0];
output.CheckAndAlloc({TShape({num_rows})});
output.CheckAndAlloc({mshadow::Shape1(num_rows)});
MSHADOW_TYPE_SWITCH(output.dtype(), DType, {
NDARRAY_IDX_TYPE_SWITCH(idx.dtype(), IType, {
MXNET_ASSIGN_REQ_SWITCH(req[1], req_type, {
Expand Down
2 changes: 1 addition & 1 deletion src/operator/tensor/matrix_op-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ void DotCsrDnsRspImpl(const OpContext& ctx,
for (int i = 0; i < static_cast<int>(indptr_l.Size())-1; ++i) {
if (indptr[i] < indptr[i+1]) ++nnr;
}
ret->CheckAndAlloc({TShape({nnr})});
ret->CheckAndAlloc({mshadow::Shape1(nnr)});
// fill in row_idx_out (single thread)
const TBlob data_out = ret->data();
const TBlob row_idx_out = ret->aux_data(rowsparse::kIdx);
Expand Down
6 changes: 3 additions & 3 deletions tests/cpp/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ NDArray RspND(const TShape shape, const Context ctx, const std::vector<TEST_ITYP
index_t num_rows = idx.size();
index_t num_cols = vals.size() / idx.size();
// create index NDArray
NDArray index = RspIdxND(TShape({num_rows}), ctx, idx);
NDArray index = RspIdxND(mshadow::Shape1(num_rows), ctx, idx);
CHECK_EQ(vals.size() % idx.size(), 0);
// create value NDArray
NDArray data = DnsND(TShape({num_rows, num_cols}), ctx, vals);
NDArray data = DnsND(mshadow::Shape2(num_rows, num_cols), ctx, vals);
// create result nd
NDArray nd(kRowSparseStorage, shape, ctx, false, mshadow::default_type_flag,
{}, {TShape({num_rows})});
{}, {mshadow::Shape1(num_rows)});
// assign values
NDArray nd_aux = nd.AuxNDArray(0);
NDArray nd_data = nd.DataNDArray();
Expand Down

0 comments on commit 3bcb9f2

Please sign in to comment.