tensorflow/compiler/mlir/tensorflow/transforms/lower_tf.cc
// Infers ExpandDims op output type for the given input type `ty` and dimension
// to expand at the given `axis`.
Infers ExpandDims op output type for the given input type `ty` and dimension
to expand at the given `axis`.
Infers ExpandDims op output type for the given input type ` ty ` and dimension to expand at the given ` axis ` .
Type InferExpandDimsType(Type ty, int64_t axis, Builder *builder) {
  auto ranked_ty = ty.dyn_cast<RankedTensorType>();
  if (!ranked_ty) return ty;
  auto shape = llvm::to_vector<4>(ranked_ty.getShape());
  if (axis < 0) axis += ranked_ty.getRank() + 1;
  shape.insert(shape.begin() + axis, 1);
  return RankedTensorType::get(shape, ranked_ty.getElementType());
}
Type InferExpandDimsType ( Type ty , int64_t axis , Builder * builder ) { auto ranked_ty = ty . dyn_cast < RankedTensorType > ( ) ; if ( ! ranked_ty ) return ty ; auto shape = llvm :: to_vector < 4 > ( ranked_ty . getShape ( ) ) ; if ( axis < 0 ) axis += ranked_ty . getRank ( ) + 1 ; shape . insert ( shape . begin ( ) + axis , 1 ) ; return RankedTensorType :: get ( shape , ranked_ty . getElementType ( ) ) ; }
Infers ExpandDims op output type for the given input type `ty` and dimension
to expand at the given `axis`.
Infers ExpandDims op output type for the given input type ` ty ` and dimension to expand at the given ` axis ` .
// Unranked type.