MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / UpdateDataFormat

Function UpdateDataFormat

tensorflow/compiler/mlir/tensorflow/ir/tf_ops.cc:379–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377// attributes besides `data_format` string.
378template <typename Op>
379LogicalResult 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`.

Callers 1

UpdateDataFormatMethod · 0.85

Calls 9

ShuffleRankedTensorTypeFunction · 0.85
data_formatMethod · 0.80
getContextMethod · 0.80
GetDataFormatPermutationFunction · 0.70
setAttrMethod · 0.65
getFunction · 0.50
emptyMethod · 0.45
setTypeMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected