| 377 | // attributes besides `data_format` string. |
| 378 | template <typename Op> |
| 379 | LogicalResult UpdateDataFormat(StringRef data_format, Op *op) { |
| 380 | auto perm = GetDataFormatPermutation(op->data_format(), data_format); |
| 381 | if (perm.empty()) return failure(); |
| 382 | |
| 383 | // Update data format attribute. |
| 384 | op->setAttr("data_format", StringAttr::get(data_format, op->getContext())); |
| 385 | |
| 386 | // Update types for all layout sensitive results. |
| 387 | auto layout_sensitive = cast<LayoutSensitiveInterface>(op->getOperation()); |
| 388 | for (unsigned idx : layout_sensitive.GetLayoutDependentResults()) { |
| 389 | OpResult result = op->getOperation()->getResult(idx); |
| 390 | result.setType(ShuffleRankedTensorType(result.getType(), perm)); |
| 391 | } |
| 392 | |
| 393 | return success(); |
| 394 | } |
| 395 | |
| 396 | // Default implementation for folding operand transpose into the operation. |
| 397 | // See `FoldOperandsTransposeInterface::FoldOperandsPermutation`. |
no test coverage detected