[Grappler:GenericLayoutOptimizer] Do not permute unknown output shapes

PiperOrigin-RevId: 263674724
This commit is contained in:
Eugene Zhulenev 2019-08-15 17:11:42 -07:00 committed by TensorFlower Gardener
parent 44a0f07543
commit 4225c4f697

View File

@ -335,11 +335,12 @@ Status Transposer::UpdateFanoutEdgesWithOp(TransposeContext* context,
if (op == kOpTranspose && output_shape_attr != nullptr) { if (op == kOpTranspose && output_shape_attr != nullptr) {
shape_attr_copy = *output_shape_attr; shape_attr_copy = *output_shape_attr;
for (int port : src_ports) { for (int port : src_ports) {
TF_RETURN_IF_ERROR(PermuteSingle( auto* shape = shape_attr_copy.mutable_list()->mutable_shape(port);
absl::StrCat("output shape attribute at port ", port, " in", if (shape->unknown_rank()) continue;
src_node->GetName()), TF_RETURN_IF_ERROR(
context->src_to_dst, PermuteSingle(absl::StrCat("output shape attribute at port ", port,
shape_attr_copy.mutable_list()->mutable_shape(port)->mutable_dim())); " in", src_node->GetName()),
context->src_to_dst, shape->mutable_dim()));
} }
context->graph_view->GetMutationBuilder()->AddOrUpdateNodeAttr( context->graph_view->GetMutationBuilder()->AddOrUpdateNodeAttr(
src_node, kAttrOutputShape, shape_attr_copy); src_node, kAttrOutputShape, shape_attr_copy);