Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't constant-fold DT_RESOURCE constants. #51875

Merged
merged 1 commit into from Oct 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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