Skip to content
Permalink
Browse files Browse the repository at this point in the history
Don't constant-fold DT_RESOURCE constants.
PiperOrigin-RevId: 391803952
Change-Id: I0ea3ec31d3e7dfda0f03b4027a237f08d00a3091
  • Loading branch information
tensorflower-gardener committed Aug 19, 2021
1 parent a813a3f commit 7731e8d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tensorflow/core/common_runtime/constant_folding.cc
Expand Up @@ -30,6 +30,7 @@ limitations under the License.
#include "tensorflow/core/framework/log_memory.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/framework/types.pb.h"
#include "tensorflow/core/graph/algorithm.h"
#include "tensorflow/core/graph/node_builder.h"
#include "tensorflow/core/graph/subgraph.h"
Expand Down Expand Up @@ -223,7 +224,8 @@ bool IsConstantFoldable(
std::unordered_map<const Node*, std::vector<Tensor>>*
shape_replacement_map) {
if (n->IsConstant()) {
return true;
// Skip constant folding resources as they cannot be deep copied.
return n->output_type(0) != DT_RESOURCE;
}
if (MaybeReplaceShapeOp(n, shape_map, shape_replacement_map)) {
return true;
Expand Down

0 comments on commit 7731e8d

Please sign in to comment.