barry-jin commented on a change in pull request #20559:
URL: https://github.com/apache/incubator-mxnet/pull/20559#discussion_r698622760



##########
File path: python/mxnet/gluon/block.py
##########
@@ -1635,6 +1637,47 @@ def reset_ctx(self, ctx):
         for p in params.values():
             p.reset_ctx(ctx)
 
+    def mark_vars(self, var_arrays):
+        """Mark the intermediate nodes
+
+        Parameters
+        ----------
+        vars: NDArrays or List[NDArrays] with nonempty 
deferredcomputation_entry_

Review comment:
       Could you follow the 
[example](https://github.com/apache/incubator-mxnet/blob/49c47380fac3c8c8e7ee8eb237000165e22828ef/python/mxnet/numpy/multiarray.py#L2621-L2645)
 to write the docstring for mark_vars? 

##########
File path: python/mxnet/gluon/block.py
##########
@@ -1635,6 +1637,47 @@ def reset_ctx(self, ctx):
         for p in params.values():
             p.reset_ctx(ctx)
 
+    def mark_vars(self, var_arrays):
+        """Mark the intermediate nodes
+
+        Parameters
+        ----------
+        vars: NDArrays or List[NDArrays] with nonempty 
deferredcomputation_entry_
+        """
+        if not self._active:
+            var_arrays = _as_list(var_arrays)
+            self._nleaf_vars.extend(var_arrays)
+        else:
+            prev_val = dc.set_deferred_compute(False)
+            var_arrays = _as_list(var_arrays)
+            # Prepare ctypes array types
+            import ctypes
+            var_handles_type = ctypes.c_void_p * len(var_arrays)
+            # Convert handles
+            var_handles = var_handles_type(*[arr.handle for arr in var_arrays])
+            check_call(_LIB.MXNDArrayMarkDCVariables(var_handles, 
len(var_arrays), len(self._nleaf_vars)))
+            self._nleaf_vars.extend(var_arrays)
+            dc.set_deferred_compute(prev_val)
+
+    def get_mark_vars(self, mark_ids):
+        """Retrieve the marked ndarrays according to the order they are marked
+
+        Parameters
+        ----------
+        mark_ids: int or List[int], the order by which the ndarray is marked

Review comment:
       Could you follow the 
[example](https://github.com/apache/incubator-mxnet/blob/49c47380fac3c8c8e7ee8eb237000165e22828ef/python/mxnet/numpy/multiarray.py#L2621-L2645)
 to write the docstring for get_mark_vars? 




-- 
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