if (constraints->OperandBufferForwarded(instruction, operand_no)) {
continue;
}
+ // Skip operands with non-array shapes.
+ if (!ShapeUtil::IsArray(instruction->operand(operand_no)->shape())) {
+ continue;
+ }
Shape operand_shape(
row_major_shape(instruction->operand(operand_no)->shape()));
TF_RETURN_IF_ERROR(constraints->SetOperandLayout(
<< ")";
VLOG(2) << " ComputationLayout = " << computation_layout.ToString();
+ // Clear existing layouts of the instructions. All layouts must be assigned by
+ // the LayoutAssignment pass, except for Infeed, Outfeed, Parameters and the
+ // computation result. The latter two are specified in computation_layout, so
+ // we only need to keep the existing layouts for Infeed and Outfeed. Clearing
+ // the layouts here avoids hiding potential bugs in the layout assignment pass
+ // that may accidently use the existing layout.
+ for (HloInstruction* instruction : computation->instructions()) {
+ if (instruction->opcode() == HloOpcode::kInfeed ||
+ instruction->opcode() == HloOpcode::kOutfeed) {
+ continue;
+ }
+ LayoutUtil::ClearLayout(instruction->mutable_shape());
+ }
+
// Construct LayoutConstraints with all layout constraints of the computation.
LayoutConstraints constraints(points_to_analysis, computation);