Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9456bcf

Browse files
Add the ability to verify assumptions about layout assignment after propagation
is done. PiperOrigin-RevId: 158696212
1 parent b085231 commit 9456bcf

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

tensorflow/compiler/xla/service/layout_assignment.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,9 @@ Status LayoutAssignment::AssignLayouts(const LayoutConstraints& constraints,
12651265
TF_RETURN_IF_ERROR(SetFusionLayouts(instruction));
12661266
}
12671267

1268+
// Execute extra verification step once the layout has been finalized.
1269+
TF_RETURN_IF_ERROR(Verify(instruction));
1270+
12681271
// Verify all layouts in the shape have been set.
12691272
TF_RET_CHECK(LayoutUtil::HasLayout(instruction->shape()));
12701273
}

tensorflow/compiler/xla/service/layout_assignment.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ class LayoutAssignment : public HloPassInterface {
246246
const ResultLayoutConstraint& layout_constraint,
247247
LayoutConstraints* constraints);
248248

249+
// Called after layouts of an instruction have been finalized to allow
250+
// subclasses to check for platform specific assumptions.
251+
virtual Status Verify(const HloInstruction* instruction) {
252+
return Status::OK();
253+
}
254+
249255
// Propagates a buffer layout constraint into the operands that use it.
250256
Status PropagateBufferConstraintToUses(
251257
const BufferLayoutConstraint& layout_constraint,

0 commit comments

Comments
 (0)