You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/05/22 21:31:52 UTC

[GitHub] piiswrong commented on a change in pull request #11001: [MXNET-374] handle row_sparse weight in parameter and trainer

piiswrong commented on a change in pull request #11001: [MXNET-374] handle row_sparse weight in parameter and trainer
URL: https://github.com/apache/incubator-mxnet/pull/11001#discussion_r190029296
 
 

 ##########
 File path: python/mxnet/gluon/parameter.py
 ##########
 @@ -194,8 +210,26 @@ def _check_and_get(self, arr_list, ctx):
             "because the later does not include Parameters of " \
             "nested child Blocks"%(self.name))
 
-    def _load_init(self, data, ctx):
+    def _get_row_sparse(self, arr_list, ctx, row_id):
+        """ Get row_sparse data from row_sparse parameters based on row_id. """
+        # get row sparse params based on row ids
+        if not isinstance(row_id, ndarray.NDArray):
+            raise TypeError("Cannot get 'row_sparse' Parameter %s with %s type. "
+                            "NDArray type is expected." % (self.name, type(row_id)))
+        if not self._trainer:
+            raise RuntimeError("Cannot get row_sparse data for Parameter '%s' when no " \
+                               "Trainer is created with it."%self.name)
+        results = self._check_and_get(arr_list, ctx)
+
+        # fetch row sparse params from the trainer
+        self._trainer._row_sparse_pull(self, results, row_id)
+        return results
+
+    def _load_init(self, data, ctx, cast_stype=False):
         """(Re)initializes by loading from data."""
+        if self._trainer and self._trainer._kv_initialized and self._trainer._update_on_kvstore:
+            raise RuntimeError("Cannot (Re)initialize Parameter '%s' when its Trainer " \
+                               "already initialized the parameter on KVStore."%(self.name))
 
 Review comment:
   message is cryptic. The reason is multi device training and update_on_kvstore is true.
   error message should describe the reason and suggest a solution

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services