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
Copy file name to clipboardexpand all lines: rfcs/20201027-modular-tensorflow-graph-c-api.md
+79-73
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ When initializing, TensorFlow loads the plugin and registers a new graph optimiz
44
44
45
45
### Struct/Function/Object Overview
46
46
- Struct
47
-
- Struct that should be filled by the plugin: `TP_OptimizerConfigFns`, `TP_Optimizer`, `TP_OptimizerRegistrationParams`
47
+
- Struct that should be filled by the plugin: `TP_OptimizerConfigs`, `TP_Optimizer`, `TP_OptimizerRegistrationParams`
48
48
- Struct that should be filled by the proper: `TF_GrapplerItem`, `TF_GraphProperties`, `TF_FunctionLibraryDefinition`
49
49
- Function
50
50
- Function that should be implemented by plugin:
@@ -66,7 +66,7 @@ When initializing, TensorFlow loads the plugin and registers a new graph optimiz
66
66
67
67
* **Registration**
68
68
1. Core TensorFlow links to plugin's dynamic library and loads the function `TF_InitGraphPlugin`.
69
-
2. In `TF_InitGraphPlugin`, plugin populates `TP_OptimizerRegistrationParams`, including `TP_OptimizerConfigFns` and `TP_Optimizer`.
69
+
2. In `TF_InitGraphPlugin`, plugin populates `TP_OptimizerRegistrationParams`, including `TP_OptimizerConfigs` and `TP_Optimizer`.
70
70
71
71
* **TF_Buffer and protobuf class**
72
72
@@ -140,7 +140,7 @@ This section describes user scenarios for plugin graph optimizer.
140
140
141
141
### Front-end python use case
142
142
143
-
Flag `use_plugin_optimizers` is provided for front-end python users to control the plugin graph optimizers.
143
+
Flag `use_plugin_optimizers` is provided for front-end python users to turn on/off the plugin graph optimizers.
144
144
```python
145
145
## TF-1.x
146
146
>> from tensorflow.core.protobuf import rewriter_config_pb2
@@ -151,26 +151,28 @@ Flag `use_plugin_optimizers` is provided for front-end python users to control t
151
151
```
152
152
153
153
This API can be used to:
154
-
* Turn on/off all registered plugin graph optimizers. By default, the registered optimizers are turned on, users can turn off them. If the registered optimizers are turned on and the graph device type is matched with registered device type, they would be runnning.
154
+
* Turn on/off all registered plugin graph optimizers. By default, the registered optimizers are turned on if they are successfully registered, users can turn off them. If the registered optimizers are turned on and the graph device type is matched with registered device type, they would be runnning.
155
155
* Use recommended configuration of existing optimizers.
156
-
If pluggable graph optimizer is registered to a device type, e.g., GPU, it is 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_OptimizerRegistrationParams`.
156
+
If pluggable graph optimizer is registered to a device type, e.g., GPU, plugin authors can provide a recommended configuration indicate whether some of existing optimizers in proper can be turned on/off, by populating flags in `TP_OptimizerConfigs`. If user turns on the optimizer, the recommended configuration is automatically applied. Otherwise user-set configuration is used.
If user turns on the optimizer, the recommended configuration is automatically applied. If optimizers are turned off, default configuration is used.
171
-
172
-
When multiple plugins are registered and running for a graph, an error would be raised if their recommended configurations are different. Users should unload one of the plugins or disable plugin optimizers to resolve the conflict.
167
+
When multiple plugins are successfully registered and running for a graph, their recommended configurations may differ with each other. If any of the config has turned off the optimizer, the optimizer will be disabled. The following table lists all possible scenarios. In the table, plugin's config is represented by tristates, `ON` means turn on optimizer, `OFF` means turn off optimzier, and `DEFAULT` means uses proper's config.
| ON | ON/DEFAULT | ON/DEFAULT | **ON**| The optimizer is enabled. |
172
+
| ON | OFF | OFF | **OFF**| The optimizer is disabled, unless users manually unload the plugin. Grappler prints warnings to remind users that config has been changed based on plugin's config.|
173
+
| ON | ON/DEFAULT | OFF | **OFF**| The optimizer is disabled if at least one plugin turns off it. Grappler prints warnings to remind users that config has been changed based on plugin's config, and potention performance regression may happen due to the conflict configs.|
174
+
| ON | OFF | ON/DEFAULT | **OFF**| Same as previous scenario.|
175
+
| OFF | ON/DEFAULT/OFF | ON/DEFAULT/OFF | **OFF**| The optimizer is always disabled when user turns off it. |
174
176
175
177
### Versioning Strategy and Stability
176
178
@@ -191,35 +193,42 @@ This API can be used to:
191
193
extern "C" {
192
194
#endif
193
195
196
+
// TF_TriState is the C API typedef for tri-state.
197
+
typedef enum TF_TriState {
198
+
TF_TriState_Default = 0,
199
+
TF_TriState_Off,
200
+
TF_TriState_On,
201
+
} TF_TriState;
202
+
194
203
// Flags indicating whether existing optimizers should be turned on/off.
195
204
// It's optional for plugin to set functions to return true/false. If not
0 commit comments