Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

update symbol to json #16948

Merged
merged 2 commits into from
Feb 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions python/mxnet/symbol/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1366,15 +1366,20 @@ def save(self, fname, remove_amp_cast=True):
else:
check_call(_LIB.MXSymbolSaveToFile(self.handle, c_str(fname)))

def tojson(self):
def tojson(self, remove_amp_cast=True):
"""Saves symbol to a JSON string.

See Also
--------
symbol.load_json : Used to load symbol from JSON string.
"""
json_str = ctypes.c_char_p()
check_call(_LIB.MXSymbolSaveToJSON(self.handle, ctypes.byref(json_str)))
if remove_amp_cast:
handle = SymbolHandle()
check_call(_LIB.MXSymbolRemoveAmpCast(self.handle, ctypes.byref(handle)))
check_call(_LIB.MXSymbolSaveToJSON(handle, ctypes.byref(json_str)))
else:
check_call(_LIB.MXSymbolSaveToJSON(self.handle, ctypes.byref(json_str)))
return py_str(json_str.value)

@staticmethod
Expand Down