reminisce commented on a change in pull request #16621: [Numpy] Basic indexing 
in symbolic interface of DeepNumpy
URL: https://github.com/apache/incubator-mxnet/pull/16621#discussion_r350469321
 
 

 ##########
 File path: python/mxnet/symbol/numpy/_symbol.py
 ##########
 @@ -855,6 +972,51 @@ def broadcast_to(self, *args, **kwargs):
     def broadcast_like(self, *args, **kwargs):
         raise AttributeError('_Symbol object has no attribute broadcast_like')
 
+    def save(self, fname, remove_amp_cast=True):
+        """Saves symbol to a file.
+        You can also use pickle to do the job if you only work on python.
+        The advantage of `load`/`save` functions is that the file contents are 
language agnostic.
+        This means the model saved by one language binding can be loaded by a 
different
+        language binding of `MXNet`.
+        You also get the benefit of being able to directly load/save from 
cloud storage(S3, HDFS).
+        Parameters
+        ----------
+        fname : str
+            The name of the file.
+            - "s3://my-bucket/path/my-s3-symbol"
+            - "hdfs://my-bucket/path/my-hdfs-symbol"
+            - "/path-to/my-local-symbol"
+        remove_amp_cast : bool, optional
+            Whether to remove the amp_cast and amp_multicast operators, before 
saving the model.
+        See Also
+        --------
+        symbol.load : Used to load symbol from file.
+        """
+        if not isinstance(fname, string_types):
+            raise TypeError('fname need to be string')
+
+        handle = self.handle
+        if remove_amp_cast:
+            handle = SymbolHandle()
+            check_call(_LIB.MXSymbolRemoveAmpCast(self.handle, 
ctypes.byref(handle)))
+
+        processed_symbol = _Symbol(handle)
+        json_str = processed_symbol.save_json_string()
+        json_data = json.loads(json_str)
+        with open(fname, 'w') as file_out:
+            json.dump(json_data, file_out, indent=2, sort_keys=True)
 
 Review comment:
   If the attribute `is_output_list` is removed from the symbol, I think we can 
simply reuse the base class method?

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


With regards,
Apache Git Services

Reply via email to