Skip to content

Commit

Permalink
update symbol to json (apache#16948)
Browse files Browse the repository at this point in the history
* update symbol to json

add remove_amp_cast argument to keep same with symbol.save

* retrigger CI

Co-authored-by: JackieWu <wkcn@live.cn>
  • Loading branch information
2 people authored and Ubuntu committed Feb 19, 2020
1 parent ec3cb6a commit b982b15
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions python/mxnet/symbol/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1364,15 +1364,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

0 comments on commit b982b15

Please sign in to comment.