bartekkuncer commented on code in PR #20983:
URL: https://github.com/apache/incubator-mxnet/pull/20983#discussion_r849407741


##########
python/mxnet/amp/lists/symbol_bf16.py:
##########
@@ -45,6 +51,7 @@
     'sqrt',
     'square',
     'tanh',
+    '_contrib_quantize_v2',

Review Comment:
   ```suggestion
       '_contrib_quantize_v2'
   ```
   Feel free to change it only if there will be any more important changes.



##########
include/mxnet/imperative.h:
##########
@@ -35,6 +35,14 @@
 #include "./ndarray.h"
 
 namespace mxnet {
+
+constexpr char OPT_CONSTRAINT_ATTR[] = "__opt_constraint__";
+enum class OptConstraint : int {
+  None       = 0,
+  DisableAMP = 1 << 0
+  // DisableQuantization = 1 << 1
+};
+

Review Comment:
   In my opinion it can stay here. At least for now.



##########
python/mxnet/gluon/block.py:
##########
@@ -1045,6 +1047,32 @@ def forward(self, x):
         `Hybridize - A Hybrid of Imperative and Symbolic Programming
         
<https://mxnet.apache.org/versions/master/api/python/docs/tutorials/packages/gluon/blocks/hybridize.html>`_
     """
+    class OptConstraint:
+        class Flag(enum.Flag):
+            DisableAMP = enum.auto()
+
+        def __init__(self, flag) -> None:
+            self.flag = flag
+            self.enter_state = None
+
+        def __enter__(self):
+            self.enter_state = 
HybridBlock.OptConstraint.Flag(get_optimization_constraints())
+            target_state = self.enter_state | self.flag
+            set_optimization_constraints(target_state)
+
+        def __exit__(self, ptype, value, trace):
+            set_optimization_constraints(self.enter_state)
+
+        @staticmethod
+        def disable_all():

Review Comment:
   Looking into the future? :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to