zhreshold commented on a change in pull request #12412: Infer dtype in 
SymbolBlock import from input symbol
URL: https://github.com/apache/incubator-mxnet/pull/12412#discussion_r216452191
 
 

 ##########
 File path: python/mxnet/gluon/block.py
 ##########
 @@ -1053,13 +1054,20 @@ def __init__(self, outputs, inputs, params=None):
                     "SymbolBlock doesn't support Parameter '%s' because its 
storage " \
                     "type is 'row_sparse'." % j.name
 
-        for i in out.list_arguments():
-            if i not in input_names:
-                self.params.get(i, allow_deferred_init=True)
+        # Infer type of parameters. Without this, every parameter will be 
created with
+        # default type i.e., fp32
+        arg_params = out.list_arguments()
+        aux_params = out.list_auxiliary_states()
 
-        for i in out.list_auxiliary_states():
-            if i not in input_names:
-                self.params.get(i, grad_req='null', allow_deferred_init=True)
+        arg_types, aux_types = _infer_param_types(inputs[0], out, arg_params, 
aux_params)
 
 Review comment:
   also, I think the type inference should occur in `cast` as well, otherwise 
it's buggy when user is trying to cast dtype of a cascaded network with 
symbolBlock inside. 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to