File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed
jaxlib/mosaic/dialect/tpu Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -119,12 +119,25 @@ LogicalResult MemRefSliceOp::verify() {
119119 // the canonicalizer, so we allow this when attributes are "unset" in the
120120 // target type. Note that MemRefType does not allow a null layout so we treat
121121 // the default identity affine map as an "unset" value instead.
122- return success (
123- (target_memory_space == nullptr ||
124- target_memory_space == source_type.getMemorySpace ()) &&
125- ((isa<AffineMapAttr>(target_layout) && target_layout.isIdentity ()) ||
126- target_type.getLayout () == source_type.getLayout ()) &&
127- getDynamicSizes ().size () == target_type.getNumDynamicDims ());
122+ bool is_target_memory_space_provided = target_memory_space != nullptr ;
123+ if (is_target_memory_space_provided &&
124+ target_memory_space != source_type.getMemorySpace ()) {
125+ return emitOpError (
126+ " Memory spaces must match if the target memory space is provided." );
127+ }
128+ bool is_target_layout_identity_map =
129+ isa<AffineMapAttr>(target_layout) && target_layout.isIdentity ();
130+ if (!is_target_layout_identity_map &&
131+ target_type.getLayout () != source_type.getLayout ()) {
132+ return emitOpError (
133+ " Layouts must match if the target layout is not an identity map." );
134+ }
135+ if (getDynamicSizes ().size () != target_type.getNumDynamicDims ()) {
136+ return emitOpError (
137+ " Number of provided dynamic dimensions sizes must match the number of "
138+ " dynamic dimensions in the target type." );
139+ }
140+ return success ();
128141}
129142
130143LogicalResult MemRefSliceOp::canonicalize (MemRefSliceOp op,
You can’t perform that action at this time.
0 commit comments