@@ -4265,8 +4265,15 @@ ParseResult TransferReadOp::parse(OpAsmParser &parser, OperationState &result) {
42654265 if (!permMapAttr) {
42664266 permMap = getTransferMinorIdentityMap (shapedType, vectorType);
42674267 if (!permMap) {
4268- return parser.emitError (
4269- typesLoc, " failed to create a minor identity map, source rank is less than required for vector rank" );
4268+ int64_t elementVectorRank = 0 ;
4269+ VectorType elementVectorType =
4270+ llvm::dyn_cast<VectorType>(shapedType.getElementType ());
4271+ if (elementVectorType)
4272+ elementVectorRank += elementVectorType.getRank ();
4273+ if (shapedType.getRank () < vectorType.getRank () - elementVectorRank)
4274+ return parser.emitError (typesLoc,
4275+ " expected a custom permutation_map when source "
4276+ " rank is less than required for vector rank" );
42704277 }
42714278 result.attributes .set (permMapAttrName, AffineMapAttr::get (permMap));
42724279 } else {
@@ -4677,8 +4684,15 @@ ParseResult TransferWriteOp::parse(OpAsmParser &parser,
46774684 if (!permMapAttr) {
46784685 permMap = getTransferMinorIdentityMap (shapedType, vectorType);
46794686 if (!permMap) {
4680- return parser.emitError (
4681- typesLoc, " failed to create a minor identity map, result rank is less than required for vector rank" );
4687+ int64_t elementVectorRank = 0 ;
4688+ VectorType elementVectorType =
4689+ llvm::dyn_cast<VectorType>(shapedType.getElementType ());
4690+ if (elementVectorType)
4691+ elementVectorRank += elementVectorType.getRank ();
4692+ if (shapedType.getRank () < vectorType.getRank () - elementVectorRank)
4693+ return parser.emitError (typesLoc,
4694+ " expected a custom permutation_map when result "
4695+ " rank is less than required for vector rank" );
46824696 }
46834697 result.attributes .set (permMapAttrName, AffineMapAttr::get (permMap));
46844698 } else {
0 commit comments