piiswrong commented on a change in pull request #10989: [WIP] add gluon model 
summary
URL: https://github.com/apache/incubator-mxnet/pull/10989#discussion_r189050120
 
 

 ##########
 File path: python/mxnet/gluon/block.py
 ##########
 @@ -355,14 +357,68 @@ def load_params(self, filename, ctx=None, 
allow_missing=False,
                         name, filename, 
_brief_print_list(self._params.keys())))
             params[name]._load_init(loaded[name], ctx)
 
-
     def register_child(self, block, name=None):
         """Registers block as a child of self. :py:class:`Block` s assigned to 
self as
         attributes will be registered automatically."""
         if name is None:
             name = str(len(self._children))
         self._children[name] = block
 
+    def register_forward_pre_hook(self, hook):
+        r"""Registers a forward pre-hook on the block.
+
+        The hook function is called immediately before :func:`forward`.
+        It should not modify the input or output.
+
+        Parameters
+        ----------
+        hook : callable
+            The forward hook function of form `hook(block, input) -> None`.
+
+        Returns
+        -------
+        :class:`mxnet.gluon.utils.RemovableHandle`
+        """
+        handle = RemovableHandle(self._forward_pre_hooks)
 
 Review comment:
   How about the following design:
   ```
   handle = RemovableHandle()
   handle.register(self._forward_pre_hooks, hook)
   return handle
   
   ----
   handle.remove()
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to