Skip to content

Commit d676de7

Browse files
committed
revert type rel relax and add check on dim
1 parent b8f2c3a commit d676de7

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/relay/op/nn/nn.cc

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -256,25 +256,11 @@ bool DensePackRel(const Array<Type>& types, int num_inputs, const Attrs& attrs,
256256
const DenseAttrs* param = attrs.as<DenseAttrs>();
257257
ICHECK(param != nullptr);
258258

259-
// Sicne the topi impl only supports 2D data, we want to enable the following check.
260-
// However, this function can be called when layout transform on inputs has not been
261-
// inserted yet during AlterOpLayout. In such cases, the input data can be packed,
262-
// i.e. data->shape.size() == 3.
263-
// ICHECK_EQ(data->shape.size(), 2)
259+
ICHECK_EQ(data->shape.size(), 2) << "Only 2D data is supported";
260+
ICHECK_EQ(weight->shape.size(), 3) << "Weight is not packed";
264261

265262
Array<tvm::PrimExpr> oshape = data->shape;
266-
if (weight->shape.size() == 3) {
267-
// The packed case, after AlterOpLayout is complete
268-
ICHECK_EQ(data->shape.size(), 2) << "Layout transform has been applied to weight but not to "
269-
"data. Only 2D data is supported.";
270-
oshape.Set((oshape.size() - 1), weight->shape[0] * weight->shape[2]);
271-
} else {
272-
// This code path hits when contrib_dense_pack is called but before layout transform
273-
// on inputs are inserted.
274-
ICHECK_EQ(weight->shape.size(), 2)
275-
<< "weight shape before layout transform is applied should be 2D.";
276-
oshape.Set((oshape.size() - 1), weight->shape[0] * weight->shape[1]);
277-
}
263+
oshape.Set(1, weight->shape[0] * weight->shape[2]);
278264

279265
DataType out_dtype = param->out_dtype;
280266
if (out_dtype.bits() == 0) {

0 commit comments

Comments
 (0)