[go: nahoru, domu]

Skip to content

Commit

Permalink
[Grappler] Don't try to replace DT_VARIANT tensors with a constant.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 300155235
Change-Id: Ia84633c6a6428fdb5d17eeaf82a145fbc4c6155b
  • Loading branch information
tensorflower-gardener committed Mar 10, 2020
1 parent 5f6bcb4 commit 3a03164
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tensorflow/core/grappler/optimizers/constant_folding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,7 @@ Status ConstantFolding::ReplaceOperationWithConstantTensor(DataType dtype,
TensorProto* value,
NodeDef* node,
GraphDef* graph) {
if (dtype == DT_VARIANT) return Status::OK();
node->set_op("Const");
node->clear_attr();
(*node->mutable_attr())["dtype"].set_type(dtype);
Expand All @@ -1942,6 +1943,7 @@ Status ConstantFolding::ReplaceOperationWithConstant(
double value, const GraphProperties& properties,
const TensorShapeProto& shape, NodeDef* node, GraphDef* graph) {
const DataType dtype = GetDataTypeFromNodeOrProps(*node, properties);
if (dtype == DT_VARIANT) return Status::OK();
AttrValue tensor_attr;
Status s = CreateConstantTensorAttrValue(dtype, value, shape, &tensor_attr);
if (!s.ok()) {
Expand All @@ -1964,10 +1966,11 @@ Status ConstantFolding::SimplifyGraph(
// generalize to only restrict certain simplifications.
if (nodes_to_not_simplify->find(node->name()) ==
nodes_to_not_simplify->end()) {
if (HasTPUAttributes(optimized_graph->node(i))) {
if (HasTPUAttributes(*node)) {
nodes_to_not_simplify->insert(node->name());
continue;
}

TF_RETURN_IF_ERROR(
SimplifyNode(use_shape_info, node, optimized_graph, properties));
}
Expand Down

0 comments on commit 3a03164

Please sign in to comment.