Introduce a new C API entrypoint to set a 'func' attribute on an op
authorA. Unique TensorFlower <gardener@tensorflow.org>
Wed, 17 Jan 2018 03:02:15 +0000 (19:02 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Wed, 17 Jan 2018 03:05:41 +0000 (19:05 -0800)
description.

PiperOrigin-RevId: 182146876

tensorflow/c/c_api.cc
tensorflow/c/c_api.h

index bc19044fa27549fde7c66ef249a0743136d555bd..ead36506f0a88e929b3ba9a8346cbb06a1949bcb 100644 (file)
@@ -1201,6 +1201,13 @@ void TF_SetAttrTypeList(TF_OperationDescription* desc, const char* attr_name,
                      reinterpret_cast<const DataType*>(values), num_values));
 }
 
+void TF_SetAttrFunc(TF_OperationDescription* desc, const char* attr_name,
+                    const char* value, size_t length) {
+  tensorflow::NameAttrList func_name;
+  func_name.set_name(std::string(value, value + length));
+  desc->node_builder.Attr(attr_name, func_name);
+}
+
 void TF_SetAttrShape(TF_OperationDescription* desc, const char* attr_name,
                      const int64_t* dims, int num_dims) {
   PartialTensorShape shape;
index 6f1c0606c11c0e102a8b5dcab4ee61fcc36d8b16..7a3bb4770801361c4db7ea0edd44219b694dc0ea 100644 (file)
@@ -511,6 +511,11 @@ TF_CAPI_EXPORT extern void TF_SetAttrTypeList(TF_OperationDescription* desc,
                                               const char* attr_name,
                                               const TF_DataType* values,
                                               int num_values);
+// Set a 'func' attribute to the specified name.
+// `value` must point to a string of length `length` bytes.
+TF_CAPI_EXPORT extern void TF_SetAttrFunc(TF_OperationDescription* desc,
+                                          const char* attr_name,
+                                          const char* value, size_t length);
 
 // Set `num_dims` to -1 to represent "unknown rank".  Otherwise,
 // `dims` points to an array of length `num_dims`.  `dims[i]` must be