Skip to content

Commit

Permalink
[OpPerf] Fixes the issue when you pass NDArray to run_perf_test (apac…
Browse files Browse the repository at this point in the history
…he#17508)

* Fix typeError

Fixes the issue when you pass NDArray to the opperf. It errors out 
```
run_performance_test(nd.gather_nd, inputs=[{"data": (2, 22), "indices":nd.random_uniform(low=0,high=1,shape=(1,2))}], run_backward=T
rue, warmup=1, runs=1)
TypeError: isinstance() arg 2 must be a type or tuple of types
```

* Fix unexpected keyword argument 'ctx' error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/incubator-mxnet/benchmark/opperf/utils/benchmark_utils.py", line 133, in run_performance_test
    args_list, kwargs_list = _prepare_op_inputs(inputs, run_backward, dtype, ctx)
  File "/home/ubuntu/incubator-mxnet/benchmark/opperf/utils/benchmark_utils.py", line 50, in _prepare_op_inputs
    attach_grad=run_backward)
  File "/home/ubuntu/incubator-mxnet/benchmark/opperf/utils/ndarray_utils.py", line 120, in get_mx_ndarray
    tensor = in_tensor.as_in_context(ctx=ctx).astype(dtype=dtype)
TypeError: as_in_context() got an unexpected keyword argument 'ctx'
  • Loading branch information
ChaiBapchya authored and Ubuntu committed Feb 19, 2020
1 parent 033fba9 commit 4c9567c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions benchmark/opperf/utils/ndarray_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def get_mx_ndarray(ctx, in_tensor, dtype, initializer, attach_grad=True):
tensor = nd.array(in_tensor, ctx=ctx, dtype=dtype)
elif isinstance(in_tensor, np.ndarray):
tensor = nd.array(in_tensor, ctx=ctx, dtype=dtype)
elif isinstance(in_tensor, mx.ndarray):
tensor = in_tensor.as_in_context(ctx=ctx).astype(dtype=dtype)
elif isinstance(in_tensor, nd.NDArray):
tensor = in_tensor.as_in_context(ctx).astype(dtype=dtype)
else:
raise ValueError("Invalid input type for creating input tensor. Input can be tuple() of shape or Numpy Array or"
" MXNet NDArray. Given - ", in_tensor)
Expand Down

0 comments on commit 4c9567c

Please sign in to comment.