mseth10 commented on a change in pull request #19386:
URL: https://github.com/apache/incubator-mxnet/pull/19386#discussion_r523384918



##########
File path: python/mxnet/gluon/block.py
##########
@@ -1147,32 +1168,47 @@ def hybridize(self, active=True, backend=None, 
backend_opts=None, clear=True, **
             Whether to turn hybrid on or off.
         backend : str
             The name of backend, as registered in `SubgraphBackendRegistry`, 
default None
-        backend_opts : dict of user-specified options to pass to the backend 
for partitioning, optional
-            Passed on to `PrePartition` and `PostPartition` functions of 
`SubgraphProperty`
-        clear : clears any previous optimizations
-        static_alloc : bool, default False
+        clear : bool, default True
+            Clears any previous optimizations
+        static_alloc : optional bool, default False
             Statically allocate memory to improve speed. Memory usage may 
increase.
-        static_shape : bool, default False
+        static_shape : optional bool, default False
             Optimize for invariant input shapes between iterations. Must also
             set static_alloc to True. Change of input shapes is still allowed
             but slower.
+        inline_limit : optional int, default 2
+            Maximum number of operators that can be inlined.
+        forward_bulk_size : optional int, default None
+            Segment size of bulk execution during forward pass.
+        backward_bulk_size : optional int, default None
+            Segment size of bulk execution during forward pass.
+        **kwargs:  optional
+            Backend options.
         """
+        if len(kwargs) > 0:
+            self._backend_opts = kwargs
 
         self._backend = backend
-        if backend_opts is not None:
-            assert isinstance(backend_opts, dict), \
-            "HybridBlock hybridize requires backend_opts to be a dictionary."
-            self._backend_opts = backend_opts
 
         self._active = active
-        self._flags = list(kwargs.items())
+        self._flags = [("static_alloc", static_alloc), ("static_shape", 
static_shape),
+                       ("inline_limit", inline_limit)]
+        if forward_bulk_size is not None:
+            self._flags.append(("forward_bulk_size", forward_bulk_size))
+        if backward_bulk_size is not None:
+            self._flags.append(("backward_bulk_size", backward_bulk_size))
         if clear:
             self._clear_cached_op()
         if active and self._forward_hooks or self._forward_pre_hooks:
             warnings.warn('"{block}" is being hybridized while still having 
forward hook/pre-hook. '
                           'If "{block}" is a child of HybridBlock, the hooks 
will not take effect.'
                           .format(block=self))
-        super(HybridBlock, self).hybridize(active, **kwargs)
+        super(HybridBlock, self).hybridize(active,

Review comment:
       Should we explicitly specify args for Block.hybridize as well now that 
we have done it here?
   
https://github.com/apache/incubator-mxnet/blob/09d0cc8418cddefddf3f03aeeb1cbeb1fd4cbafa/python/mxnet/gluon/block.py#L658-L662

##########
File path: example/extensions/lib_subgraph/README.md
##########
@@ -107,15 +107,15 @@ The `optimize_for` API takes at least 1 argument, 
`backend` which is a string th
 For the Gluon API, `hybridize` can be called on HybridBlocks to partition the 
internal CachedOp Symbol.
 
 ```python
-block.hybridize(backend=None, backend_opts=None, clear=True, **kwargs)
+block.hybridize(backend=None, clear=True, **kwargs)
 ```
 
-The `hybridize` function prepares the HybridBlock to be converted into a 
backend symbol. The `backend` argument is a string that identifies which 
backend that will partition the model. The `backend_opts` are other 
user-specified options (as a Python dictionary of strings mapped to strings) 
that will be passed to the backend partitioning APIs. The `clear` argument 
defaults to `True` and clears any previous optimizations done on the block. If 
you want to chain optimizations together, set `clear` to `False`. The actual 
partitioning takes place during the forward pass. If you want to use 
`hybridize` to chain multiple optimizations, be sure to execute a forward pass 
after each call to `hybridize`. 
+The `hybridize` function prepares the HybridBlock to be converted into a 
backend symbol. The `backend` argument is a string that identifies which 
backend that will partition the model. `**kwargs` are other user-specified 
options (as a Python dictionary of strings mapped to strings) that will be 
passed to the backend partitioning APIs. The `clear` argument defaults to 
`False`, so it will chain optimizations together. If you want to clear clear 
any previous optimizations done on the block, set `clear` to `True`. The actual 
partitioning takes place during the forward pass. If you want to use 
`hybridize` to chain multiple optimizations, be sure to execute a forward pass 
after each call to `hybridize`.

Review comment:
       nit: clear clear -> clear




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

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


Reply via email to