Switch op_hint.py to use _set_attr.
authorSkye Wanderman-Milne <skyewm@google.com>
Mon, 12 Mar 2018 18:43:57 +0000 (11:43 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Mon, 12 Mar 2018 18:47:52 +0000 (11:47 -0700)
This is in preparation for enabling the C API. Modifying an op's NodeDef
directly has no effect with the C API enabled.

PiperOrigin-RevId: 188754464

tensorflow/contrib/lite/python/op_hint.py

index 9a39712..7908689 100644 (file)
@@ -119,8 +119,10 @@ class OpHint(object):
 
   def _setattr(self, dest_op, name, value):
     tensor_value = _ops.convert_to_tensor(value)
-    dest_op.op.node_def.attr[name].tensor.CopyFrom(
-        tensor_value.op.node_def.attr["value"].tensor)
+    # pylint: disable=protected-access
+    dest_op.op._set_attr(name, _attr_value_pb2.AttrValue(
+        tensor=tensor_value.op.node_def.attr["value"].tensor))
+    # pylint: enable=protected-access
 
   def add_inputs(self, *args):
     """Add a sequence of inputs to the function invocation.