OmarAzizi commented on code in PR #20188:
URL: https://github.com/apache/tvm/pull/20188#discussion_r3875377184
##########
python/tvm/relax/frontend/onnx/onnx_frontend.py:
##########
@@ -2173,6 +2173,23 @@ def _impl_v13(cls, bb, inputs, attr, params):
axis = tuple([int(x) for x in axis.data.numpy()])
return cls._squeeze(bb, data, axis)
+ @classmethod
+ def _check_squeeze_axes_are_unit_dims(cls, data, axes):
+ """Raise if any axis to be squeezed has a statically known extent
other than 1."""
+ rank = _get_known_tensor_rank(data)
+ if rank is None:
+ return
+ ty = data.ty
+ if not (isinstance(ty, relax.TensorType) and isinstance(ty.shape,
relax.ShapeExpr)):
+ return
+ for axis in _normalize_constant_axes(list(axes), rank, "Squeeze"):
+ extent = ty.shape.values[axis]
+ if isinstance(extent, tirx.IntImm) and int(extent.value) != 1:
Review Comment:
You're welcome.
Correct me if I'm worng, but regarding a runtime assertion I don't see
`assert_op` used in any frontend and `match_cast` only used to bind symbolic
vars, never to assert a value. The usual pattern is to reject an import when a
value isn't a compile-time constant. Should I do that here as well?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]