File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ class MlirBridgePass : public MlirOptimizationPass {
3131
3232 bool IsEnabled (const ConfigProto& config_proto) const override {
3333 return config_proto.experimental ().enable_mlir_bridge () ||
34+ config_proto.experimental ().mlir_bridge_rollout () ==
35+ tensorflow::ConfigProto::Experimental::
36+ MLIR_BRIDGE_ROLLOUT_ENABLED ||
3437 tensorflow::GetMlirCommonFlags ()->tf_mlir_enable_mlir_bridge ==
3538 tensorflow::ConfigProto::Experimental::
3639 MLIR_BRIDGE_ROLLOUT_ENABLED ;
@@ -50,7 +53,10 @@ class MlirBridgeV1CompatPass : public MlirV1CompatOptimizationPass {
5053
5154 bool IsEnabled (const ConfigProto& config_proto) const override {
5255 return config_proto.experimental ().enable_mlir_bridge () ||
53- GetMlirCommonFlags ()->tf_mlir_enable_mlir_bridge ==
56+ config_proto.experimental ().mlir_bridge_rollout () ==
57+ tensorflow::ConfigProto::Experimental::
58+ MLIR_BRIDGE_ROLLOUT_ENABLED ||
59+ tensorflow::GetMlirCommonFlags ()->tf_mlir_enable_mlir_bridge ==
5460 tensorflow::ConfigProto::Experimental::
5561 MLIR_BRIDGE_ROLLOUT_ENABLED ;
5662 }
Original file line number Diff line number Diff line change @@ -948,7 +948,12 @@ def config(self):
948948 if self ._log_device_placement is not None :
949949 config .log_device_placement = self ._log_device_placement
950950
951- config .experimental .enable_mlir_bridge = pywrap_tfe .TF_IsMlirBridgeEnabled ()
951+ is_mlir_bridge_enabled = pywrap_tfe .TF_IsMlirBridgeEnabled ()
952+ config .experimental .mlir_bridge_rollout = is_mlir_bridge_enabled
953+ if (is_mlir_bridge_enabled ==
954+ config_pb2 .ConfigProto .Experimental .MLIR_BRIDGE_ROLLOUT_ENABLED ):
955+ config .experimental .enable_mlir_bridge = True
956+
952957 if self ._enable_mlir_graph_optimization is not None :
953958 config .experimental .enable_mlir_graph_optimization = (
954959 self ._enable_mlir_graph_optimization )
Original file line number Diff line number Diff line change @@ -214,14 +214,23 @@ def testLogDevicePlacement(self):
214214 def testEnableMlirBridge (self ):
215215 # Default value of enable_mlir_bridge is false.
216216 self .assertFalse (context .context ().config .experimental .enable_mlir_bridge )
217+ self .assertEqual (
218+ context .context ().config .experimental .mlir_bridge_rollout ,
219+ config_pb2 .ConfigProto .Experimental .MLIR_BRIDGE_ROLLOUT_UNSPECIFIED )
217220
218221 # Tests enabling mlir bridge.
219222 config .enable_mlir_bridge ()
220223 self .assertTrue (context .context ().config .experimental .enable_mlir_bridge )
224+ self .assertEqual (
225+ context .context ().config .experimental .mlir_bridge_rollout ,
226+ config_pb2 .ConfigProto .Experimental .MLIR_BRIDGE_ROLLOUT_ENABLED )
221227
222228 # Tests disabling mlir bridge.
223229 config .disable_mlir_bridge ()
224230 self .assertFalse (context .context ().config .experimental .enable_mlir_bridge )
231+ self .assertEqual (
232+ context .context ().config .experimental .mlir_bridge_rollout ,
233+ config_pb2 .ConfigProto .Experimental .MLIR_BRIDGE_ROLLOUT_DISABLED )
225234
226235 @reset_eager
227236 def testEnableMlirGraphOptimization (self ):
Original file line number Diff line number Diff line change @@ -580,8 +580,10 @@ PYBIND11_MODULE(_pywrap_tfe, m) {
580580
581581 // MLIR Logic
582582 m.def (" TF_IsMlirBridgeEnabled" , [] {
583- return tensorflow::GetMlirCommonFlags ()->tf_mlir_enable_mlir_bridge ==
584- tensorflow::ConfigProto::Experimental::MLIR_BRIDGE_ROLLOUT_ENABLED ;
583+ // Since python protobuf enums are integers, cast to an integer before
584+ // returning the enum to python.
585+ return static_cast <int32_t >(
586+ tensorflow::GetMlirCommonFlags ()->tf_mlir_enable_mlir_bridge );
585587 });
586588 m.def (" TF_EnableMlirBridge" , [](bool enabled) {
587589 tensorflow::GetMlirCommonFlags ()->tf_mlir_enable_mlir_bridge =
You can’t perform that action at this time.
0 commit comments