samskalicky commented on a change in pull request #15969: Partitioning Gluon 
HybridBlocks
URL: https://github.com/apache/incubator-mxnet/pull/15969#discussion_r374268783
 
 

 ##########
 File path: python/mxnet/gluon/block.py
 ##########
 @@ -954,6 +955,22 @@ def _build_cache(self, *args):
             unused = ', '.join(list(param_names - set(used_param_names)))
             warnings.warn("Parameter %s is not used by any computation. "
                           "Is this intended?"%unused, stacklevel=4)
+        if self._backend:
+            arg_array = []
+            ctx = args[0].context
+            try:
+                for name in out.list_arguments():
+                    if name in data_names.keys():
+                        arg_array.append(args[data_names[name]])
+                    else:
+                        arg_array.append(params.get(name).data())
+
+            except DeferredInitializationError:
 
 Review comment:
   @leezu This is not always guaranteed to work. The input shapes may not be 
enough to infer shapes through the model. And the shapes inferred may not the 
be the same as the actual shapes used at inference time. 
   
   Some backends may not be ok with this. They may error out saying the shapes 
presented at partition time do not match those at runtime. So the safe approach 
is either to provide the exact shapes at partition time, or not at all. 
   
   

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


With regards,
Apache Git Services

Reply via email to