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

Commit

Permalink
add to set_np
Browse files Browse the repository at this point in the history
  • Loading branch information
JiangZhaoh committed Apr 28, 2020
1 parent db48912 commit 838d7b8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion benchmark/python/einsum/benchmark_einsum.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ def test_np_einsum():


if __name__ == "__main__":
npx.set_np()
npx.set_np(dtype=False)
test_np_einsum()
2 changes: 1 addition & 1 deletion benchmark/python/ffi/benchmark_ffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def show_results(results):
import numpy as onp
from mxnet import np as dnp

mx.npx.set_np()
mx.npx.set_np(dtype=False)
packages = {
"onp": {
"module": onp,
Expand Down
4 changes: 2 additions & 2 deletions python/mxnet/gluon/data/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def __len__(self):

def _thread_worker_initializer(active_shape, active_array):
"""Initializer for ThreadPool."""
set_np(shape=active_shape, array=active_array)
set_np(shape=active_shape, array=active_array, dtype=False)


_worker_dataset = None
Expand All @@ -418,7 +418,7 @@ def _worker_initializer(dataset, active_shape, active_array):
# can be passed as argument
global _worker_dataset
_worker_dataset = dataset
set_np(shape=active_shape, array=active_array)
set_np(shape=active_shape, array=active_array, dtype=False)

def _worker_fn(samples, batchify_fn, dataset=None):
"""Function for processing data in worker process."""
Expand Down
6 changes: 3 additions & 3 deletions python/mxnet/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ def _set_np_array(active):
return cur_state


def set_np(shape=True, array=True):
def set_np(shape=True, array=True, dtype=True):
"""Setting NumPy shape and array semantics at the same time.
It is required to keep NumPy shape semantics active while activating NumPy array semantics.
Deactivating NumPy shape semantics while NumPy array semantics is still active is not allowed.
Expand Down Expand Up @@ -843,12 +843,12 @@ def set_np(shape=True, array=True):
raise ValueError('NumPy Shape semantics is required in using NumPy array semantics.')
_set_np_array(array)
set_np_shape(shape)
#set_np_default_dtype(dtype)
set_np_default_dtype(dtype)


def reset_np():
"""Deactivate NumPy shape and array and deafult dtype semantics at the same time."""
set_np(shape=False, array=False)
set_np(shape=False, array=False, dtype=False)


_CUDA_SUCCESS = 0
Expand Down

0 comments on commit 838d7b8

Please sign in to comment.