| 269 | } |
| 270 | |
| 271 | Status LayoutConstraints::SetResultLayout(const Shape& shape_with_layout, |
| 272 | bool dfs) { |
| 273 | VLOG(3) << "SetResultLayout : " |
| 274 | << ShapeUtil::HumanStringWithLayout(shape_with_layout); |
| 275 | |
| 276 | const ShapeLayout* curr_shape_layout = ResultLayout(); |
| 277 | if (curr_shape_layout != nullptr) { |
| 278 | if (!curr_shape_layout->MatchesLayoutInShape( |
| 279 | shape_with_layout, /*minor_to_major_only=*/true)) { |
| 280 | return FailedPrecondition( |
| 281 | "Result of computation %s already has the layout constraint %s, " |
| 282 | "cannot add incompatible constraint %s", |
| 283 | computation_->name(), curr_shape_layout->ToString(), |
| 284 | ShapeUtil::HumanStringWithLayout(shape_with_layout)); |
| 285 | } |
| 286 | // New constraint matches existing constraint. Nothing to do. |
| 287 | return Status::OK(); |
| 288 | } |
| 289 | result_constraint_.reset( |
| 290 | new ResultLayoutConstraint(ShapeLayout(shape_with_layout), dfs)); |
| 291 | added_constraints_.push_back(result_constraint_.get()); |
| 292 | |
| 293 | return Status::OK(); |
| 294 | } |
| 295 | |
| 296 | Status LayoutConstraints::SetInstructionLayout( |
| 297 | const Shape& shape_with_layout, const HloInstruction* instruction, |
no test coverage detected