You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: rfcs/20201027-modular-tensorflow-graph-c-api.md
+47-39Lines changed: 47 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,12 +48,12 @@ When initializing, TensorFlow loads the plugin and registers a new graph optimiz
48
48
49
49
### Struct/Function/Object Overview
50
50
- Struct
51
-
- Struct that should be filled by the plugin: `P_OptimizerConfigFns`, `P_RegistrationParams`, `TF_OptimizerBuilder`
51
+
- Struct that should be filled by the plugin: `TP_OptimizerConfigFns`, `TP_RegistrationParams`, `TP_OptimizerBuilder`
52
52
- Struct that should be filled by the proper: `TF_GrapplerItem`, `TF_GraphProperties`, `TF_FunctionLibraryDefinition`
53
53
- Function
54
54
- Function that should be implemented by plugin:
55
55
- Creation/Deletion/Optimization function of optimizer.
56
-
-`P_MessageToBuffer`, `P_BufferToMessage`: Serialization/Deserialization of objects generated by protobuf.
56
+
-`plugin::MessageToBuffer`, `plugin::BufferToMessage`: Serialization/Deserialization of objects generated by protobuf.
57
57
-`TF_InitGraphPlugin`: Optimizer registration.
58
58
- (Optional)Util function for graph transformation.
59
59
- Object:
@@ -88,18 +88,18 @@ When initializing, TensorFlow loads the plugin and registers a new graph optimiz
88
88
89
89
After optimizing, plugin authors need to serialize the optimized `GraphDef` object into `TF_Buffer` as output.
90
90
91
-
Serialization function `MessageToBuffer` is already defined, desearization function `BufferToMessage` will be added in proper to convert plugin passed `TF_Buffer` back to proper's `GraphDef`. In plugin side, plugin authors need to define `P_MessageToBuffer` and `P_BufferToMessage`, which should be the same as those defined in proper, except the namespace of protobuf.
91
+
Serialization function `tensorflow::MessageToBuffer` is already defined, desearization function `tensorflow::BufferToMessage` will be added in proper to convert plugin passed `TF_Buffer` back to proper's `GraphDef`. In plugin side, plugin authors need to define `plugin::MessageToBuffer` and `plugin::BufferToMessage`, which should be the same as those defined in proper, except the namespace of protobuf. To be noticed, these two are internal defined functions, they are not a part of C API interface.
92
92
93
93
Proper:
94
94
```cpp
95
-
Status MessageToBuffer(const tensorflow::protobuf::MessageLite& in, TF_Buffer* out);
96
-
Status BufferToMessage(const TF_Buffer* in, tensorflow::protobuf::MessageLite& out);
95
+
Status tensorflow::MessageToBuffer(const tensorflow::protobuf::MessageLite& in, TF_Buffer* out);
96
+
Status tensorflow::BufferToMessage(const TF_Buffer* in, tensorflow::protobuf::MessageLite& out);
97
97
```
98
98
99
99
Plugin:
100
100
```cpp
101
-
Status P_MessageToBuffer(const plugin::protobuf::MessageLite& in, TF_Buffer* out);
102
-
Status P_BufferToMessage(const TF_Buffer* in, plugin::protobuf::MessageLite& out);
101
+
Status plugin::MessageToBuffer(const plugin::protobuf::MessageLite& in, TF_Buffer* out);
102
+
Status plugin::BufferToMessage(const TF_Buffer* in, plugin::protobuf::MessageLite& out);
103
103
```
104
104
105
105
* **Util functions**
@@ -109,8 +109,8 @@ When initializing, TensorFlow loads the plugin and registers a new graph optimiz
109
109
* **Registration**
110
110
1. Core TensorFlow links to plugin's dynamic library and loads the function `TF_InitGraphPlugin`.
111
111
2. In `TF_InitGraphPlugin`,
112
-
- Plugin populates `P_RegistrationParams`.
113
-
- Plugin creates an optimizer `TF_OptimizerBuilder` with creation/optimization/deletion functions.
112
+
- Plugin populates `TP_RegistrationParams`.
113
+
- Plugin populates `TP_OptimizerBuilder` with creation/optimization/deletion functions.
114
114
- Plugin calls `TF_RegisterOptimizer` to register the optimizer with params.
115
115
116
116
### Supported User Scenarios
@@ -130,13 +130,13 @@ Plugin graph optimization is targeting backend device specific optimization, and
130
130
131
131
***Configuring existing optimizers**
132
132
133
-
If pluggable graph optimizer is registered to a device type, e.g., GPU, its optional for plugin authors to provide a recommended configuration indicate whether some of existing optimizers in proper can be turned on/off, by populating flags in `P_RegistrationParams`.
133
+
If pluggable graph optimizer is registered to a device type, e.g., GPU, its optional for plugin authors to provide a recommended configuration indicate whether some of existing optimizers in proper can be turned on/off, by populating flags in `TP_RegistrationParams`.
0 commit comments