Skip to content

Commit

Permalink
Raise an error when converting a TensorListReserve op with scalar ele…
Browse files Browse the repository at this point in the history
…ment_shape.

PiperOrigin-RevId: 297977316
Change-Id: I6f5006779504076bdd9f4094a8daad5a6d03b2c0
  • Loading branch information
haozha111 authored and tensorflower-gardener committed Feb 29, 2020
1 parent 9bb80be commit efd49e0
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,16 @@ struct ConvertTensorListInitOp : public OpConversionPattern<OpT> {

Value element_shape = operands[0];
Type shape_dtype = getElementTypeOrSelf(element_shape.getType());
// If the `element_shape` is a scalar, we know that it's dynamic shape
// and returns an error.
if (auto shaped_type = element_shape.getType().dyn_cast<ShapedType>()) {
if (shaped_type.getRank() == 0) {
op.emitError(
"requires element_shape to be 1D tensor during TF Lite "
"transformation pass");
return ConversionPattern::matchFailure();
}
}

DenseIntElementsAttr dense_elem_attr;
if (matchPattern(element_shape, m_Constant(&dense_elem_attr))) {
Expand Down

0 comments on commit efd49e0

Please sign in to comment.