bool MatchesLayoutInShape(const Shape& shape) const;
// Copies the layout from the given shape into this ShapeLayout. 'other_shape'
- // must be compatible with the ShapeLayout's shape.
+ // must be compatible with the ShapeLayout's shape, and 'other_shape' must
+ // have a layout (LayoutUtil::HasLayout).
tensorflow::Status CopyLayoutFromShape(const Shape& other_shape);
// Clears (Layout::Clear) all the Layouts stored in this object.
// set the layouts to what the hlo text says.
for (int p = 0; p < computation->num_parameters(); p++) {
const Shape& param_shape = computation->parameter_instruction(p)->shape();
- TF_CHECK_OK(module_->mutable_entry_computation_layout()
- ->mutable_parameter_layout(p)
- ->CopyLayoutFromShape(param_shape));
+ if (param_shape.has_layout()) {
+ module_->mutable_entry_computation_layout()
+ ->mutable_parameter_layout(p)
+ ->ResetLayout(param_shape.layout());
+ }
}
const Shape& result_shape = computation->root_instruction()->shape();
- TF_CHECK_OK(module_->mutable_entry_computation_layout()
- ->mutable_result_layout()
- ->CopyLayoutFromShape(result_shape));
+ if (result_shape.has_layout()) {
+ module_->mutable_entry_computation_layout()
+ ->mutable_result_layout()
+ ->ResetLayout(result_shape.layout());
+ }
}
return true;