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

Add proper exception message for negative shape in array creation routines #14362

Merged
merged 1 commit into from
Mar 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/operator/tensor/init_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ inline bool InitShape(const nnvm::NodeAttrs& attrs,
CHECK_EQ(in_attrs->size(), 0U);
CHECK_EQ(out_attrs->size(), 1U);
if ((*out_attrs)[0].ndim() != 0 && param.shape.ndim() == 0) return true;
for (unsigned int i=0 ; i < param.shape.ndim() ; ++i) {
if (param.shape[i] < 0U) {
LOG(FATAL) << "Shape cannot contain negative values " << param.shape;
}
}
SHAPE_ASSIGN_CHECK(*out_attrs, 0, param.shape);
return true;
}
Expand Down