From 411f0d2800701c222ee0d045996d00c274917772 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 5 Mar 2021 09:27:18 -0800 Subject: [PATCH] Fix ResolveInputDynamismIntoPredVector to consider values dynamic on failure to resolve dynamism ResolveInputDynamismIntoPred correctly handles this. Dynamism computation could fail if the input depends on some unsupported ops like custom-call. In such cases, all elements for the input should conservatively be marked as dynamic and not static. PiperOrigin-RevId: 361161831 Change-Id: I7f6fcbd29fc1a2562af26d9682eaf1f02e11f6a7 --- tensorflow/compiler/tf2xla/xla_op_kernel.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tensorflow/compiler/tf2xla/xla_op_kernel.cc b/tensorflow/compiler/tf2xla/xla_op_kernel.cc index f2eb0382756..0a298b798be 100644 --- a/tensorflow/compiler/tf2xla/xla_op_kernel.cc +++ b/tensorflow/compiler/tf2xla/xla_op_kernel.cc @@ -266,11 +266,10 @@ Status XlaOpKernelContext::ResolveInputDynamismIntoPred(int index, bool* out) { xla::StatusOr dynamism_or_status = e.ResolveDynamism(client); if (!dynamism_or_status.ok()) { // When failed to resolve dynamism, conservatively consider the value - // dynamic. This could happen if the input depends on some ops like - // custom-call that is not supported generally for dynamism computation. + // dynamic. // // TODO(b/176993339): Support resolving dynamism across computations so - // resolving dynamism will not fail in those cases. + // resolving dynamism will not fail. *out = true; return Status::OK(); } @@ -297,12 +296,11 @@ Status XlaOpKernelContext::ResolveInputDynamismIntoPredVector( xla::StatusOr dynamism_or_status = e.ResolveDynamism(client); if (!dynamism_or_status.ok()) { // When failed to resolve dynamism, conservatively consider the value - // dynamic. This could happen if the input depends on some ops like - // custom-call that is not supported generally for dynamism computation. + // dynamic. // // TODO(b/176993339): Support resolving dynamism across computations so - // resolving dynamism will not fail in those cases. - out->resize(InputShape(index).num_elements(), true); + // resolving dynamism will not fail. + out->resize(InputShape(index).num_elements(), false); return Status::OK(); } Tensor dynamism = dynamism_or_status.ValueOrDie();