From 30b1cbc1d862f8c5c1f91d0a9f048aef5771f9de Mon Sep 17 00:00:00 2001 From: Anirudh Date: Thu, 7 Mar 2019 19:29:32 -0800 Subject: [PATCH] add exception (#14362) --- 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; }