szha commented on a change in pull request #15063: Rename np_compat to np_shape
URL: https://github.com/apache/incubator-mxnet/pull/15063#discussion_r287552098
##########
File path: python/mxnet/util.py
##########
@@ -44,3 +45,195 @@ def get_gpu_memory(gpu_dev_id):
total_mem = ctypes.c_uint64(0)
check_call(_LIB.MXGetGPUMemoryInformation64(gpu_dev_id,
ctypes.byref(free_mem), ctypes.byref(total_mem)))
return free_mem.value, total_mem.value
+
+
+def set_np_shape(active):
+ """
+ Turns on/off NumPy shape semantics. This is turned off by default for
+ keeping backward compatibility.
+
+ Please note that this is designed as an infrastructure for the incoming
+ MXNet-NumPy operators. Legacy operators registered in the modules
+ `mx.nd` and `mx.sym` are not guaranteed to behave like their counterparts
+ in NumPy within this semantics.
+
+ Parameters
+ ----------
+ active : bool
+ Indicates whether to turn on/off NumPy shape semantics.
+
+ Returns
+ -------
+ A bool value indicating the previous state of NumPy shape semantics.
+
+ Example
+ -------
+ >>> import mxnet as mx
+ >>> prev_state = mx.set_np_shape(True)
+ >>> print(prev_state)
+ False
+ >>> print(mx.is_np_shape())
+ True
+ """
+ prev = ctypes.c_int()
+ check_call(_LIB.MXSetIsNumpyShape(ctypes.c_int(active),
ctypes.byref(prev)))
+ return bool(prev.value)
+
+
+def is_np_shape():
+ """
+ Checks whether the NumPy shape semantics is currently turned on.
Review comment:
same
----------------------------------------------------------------
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