aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/c/python_api.cc
diff options
context:
space:
mode:
authorGravatar Olivia Nordquist <nolivia@google.com>2017-10-31 16:43:46 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-10-31 16:47:44 -0700
commitf97e7c69b84dac8c3c8c78204d48816036b9bead (patch)
tree67646716fe3074bd9afeb25f5170d24e84e24d87 /tensorflow/c/python_api.cc
parent8e732a31246f52cd277536e1cb9bab7aa1807d60 (diff)
partially exposing the _set_attr and _get_attr method in python
PiperOrigin-RevId: 174113043
Diffstat (limited to 'tensorflow/c/python_api.cc')
-rw-r--r--tensorflow/c/python_api.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/tensorflow/c/python_api.cc b/tensorflow/c/python_api.cc
index 0fe85d5d2c..bddbcf689c 100644
--- a/tensorflow/c/python_api.cc
+++ b/tensorflow/c/python_api.cc
@@ -24,6 +24,19 @@ void AddControlInput(TF_Graph* graph, TF_Operation* op, TF_Operation* input) {
graph->graph.AddControlEdge(&input->node, &op->node);
}
+void SetAttr(TF_Graph* graph, TF_Operation* op, const char* attr_name,
+ TF_Buffer* attr_value_proto, TF_Status* status) {
+ AttrValue attr_val;
+ if (!attr_val.ParseFromArray(attr_value_proto->data,
+ attr_value_proto->length)) {
+ status->status =
+ tensorflow::errors::InvalidArgument("Invalid AttrValue proto");
+ }
+
+ mutex_lock l(graph->mu);
+ op->node.AddAttr(attr_name, attr_val);
+}
+
void SetRequestedDevice(TF_Graph* graph, TF_Operation* op, const char* device) {
mutex_lock l(graph->mu);
op->node.set_requested_device(device);