From 0ef7df8f63e52c86d073064125559bba70fd4e1e Mon Sep 17 00:00:00 2001 From: Anirudh Acharya Date: Thu, 7 Mar 2019 16:32:00 -0800 Subject: [PATCH] add exception --- src/operator/tensor/init_op.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/operator/tensor/init_op.h b/src/operator/tensor/init_op.h index 680431dfecd1..fe1a1f62954a 100644 --- a/src/operator/tensor/init_op.h +++ b/src/operator/tensor/init_op.h @@ -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; }