tensorflow/compiler/mlir/hlo/lib/Dialect/mhlo/transforms/legalize_shape_computations.cc
// We assume that if one of the operands is a FromElements operation that means
// it is a shape computation.
We assume that if one of the operands is a FromElements operation that means
it is a shape computation.
We assume that if one of the operands is a FromElements operation that means it is a shape computation .
bool OpIsShapeComputation(Operation *op) {
  bool found_from_elements = false;
  for (auto operand : op->getOperands()) {
    auto shaped_ty = operand.getType().template cast<ShapedType>();
    if (!shaped_ty.hasRank() || shaped_ty.getRank() > 1) return false;
    if (auto from_elements =
            operand.template getDefiningOp<tensor::FromElementsOp>()) {
      found_from_elements = true;
      continue;
    }
  }
  return found_from_elements;
}
bool OpIsShapeComputation ( Operation * op ) { bool found_from_elements = false ; for ( auto operand : op -> getOperands ( ) ) { auto shaped_ty = operand . getType ( ) . template cast < ShapedType > ( ) ; if ( ! shaped_ty . hasRank ( ) || shaped_ty . getRank ( ) > 1 ) return false ; if ( auto from_elements = operand . template getDefiningOp < tensor :: FromElementsOp > ( ) ) { found_from_elements = true ; continue ; } } return found_from_elements ; }
We assume that if one of the operands is a FromElements operation that means
it is a shape computation.
We assume that if one of the operands is a FromElements operation that means it is a shape computation .