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

[MXNET-1382] Add the index_array operator #14638

Merged
merged 19 commits into from
May 25, 2019
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a9451cb
Implement the index_array operator
nickguletskii Apr 7, 2019
91e2052
Add index_array operator tests
nickguletskii Apr 7, 2019
1a4a0b6
Add index_array operator GPU tests
nickguletskii Apr 7, 2019
c58964a
Add the index_array operator to the Python docs autosummary
nickguletskii Apr 7, 2019
50c0c28
Add the author of the index_array operator to CONTRIBUTORS.md
nickguletskii Apr 7, 2019
df1f421
Make index_array compatible with zero-dim and zero-size arrays
nickguletskii Apr 30, 2019
e4152c6
Fix the index_array gradient checks in the unit tests
nickguletskii Apr 30, 2019
adb9f36
Add zero-dim and zero-size array tests for index_array
nickguletskii Apr 30, 2019
3eccb3c
Use mxnet::Tuple<int> instead of TShape for the axes parameter
nickguletskii Apr 30, 2019
a6b3cab
Fix incorrect array indexing in index_array
nickguletskii May 1, 2019
69bf4f6
Avoid copying the input shape array in the index_array shape function
nickguletskii May 13, 2019
be39798
Add unknown shape handling to index_array
nickguletskii May 13, 2019
445f758
Use SHAPE_ASSIGN_CHECK to assign the shape in index_array
nickguletskii May 13, 2019
972b05f
Remove the redundant index_array GPU tests from test_operator_gpu.py
nickguletskii May 13, 2019
3051d5e
Move the index_array tests into a single function (test_index_array)
nickguletskii May 13, 2019
3f8702a
Use @mx.use_np_compat instead of mx.np_compat in index_array op tests
nickguletskii May 13, 2019
496bad3
Remove the use of template specialization for IndexArrayForward
nickguletskii May 14, 2019
69a9969
Add the index_array operator to the AMP symbol list
nickguletskii May 22, 2019
ffde9b3
Retrigger CI
nickguletskii May 22, 2019
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
Prev Previous commit
Next Next commit
Remove the redundant index_array GPU tests from test_operator_gpu.py
  • Loading branch information
nickguletskii committed May 22, 2019
commit 972b05fc64eb5b5455b222f07f399b3bde55f343
62 changes: 0 additions & 62 deletions tests/python/gpu/test_operator_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2130,68 +2130,6 @@ def test_bilinear_sampler_versions():
if req_dict['grid'] is 'write':
assert_almost_equal(exe.grad_dict['grid'].asnumpy(), exe_list[ref_idx].grad_dict['grid'].asnumpy(), rtol=1e-3, atol=1e-5)

@with_seed()
def test_index_array_default():
for shape in [(10,), (7, 5, 29), (5, 7, 11, 13, 17, 19)]:
data = mx.symbol.Variable("data")
index_array = mx.sym.contrib.index_array(data)

input_array = np.ones(shape)
mgrid = np.mgrid[tuple(slice(0, x) for x in shape)]
expected = np.stack(mgrid, axis=-1)

check_symbolic_forward(index_array, [input_array], [expected])
check_symbolic_backward(index_array, [input_array], [np.ones(expected.shape)], [np.zeros_like(input_array)])

@with_seed()
def test_index_array_default_zero_dim():
with mx.np_compat(active=True):
data = mx.symbol.Variable("data")
index_array = mx.sym.contrib.index_array(data)

input_array = np.ones(())
expected = np.zeros((0,))

check_symbolic_forward(index_array, [input_array], [expected])
check_symbolic_backward(index_array, [input_array], [np.ones(expected.shape)], [np.zeros_like(input_array)])

@with_seed()
def test_index_array_default_zero_size():
with mx.np_compat(active=True):
data = mx.symbol.Variable("data")
index_array = mx.sym.contrib.index_array(data)

input_array = np.ones((0, 0, 0))
expected = np.zeros((0, 0, 0, 3))

check_symbolic_forward(index_array, [input_array], [expected])
check_symbolic_backward(index_array, [input_array], [np.ones(expected.shape)], [np.zeros_like(input_array)])

@with_seed()
def test_index_array_select_axes():
shape = (5, 7, 11, 13, 17, 19)
for axes in [(3,), (4, 1), (5, 1, 3), (-1,), (-5, -1, -3)]:
data = mx.symbol.Variable("data")
index_array = mx.sym.contrib.index_array(data, axes=axes)

input_array = np.ones(shape)
mgrid = np.mgrid[tuple(slice(0, x) for x in shape)]
expected = np.stack(mgrid, axis=-1)[..., axes]

check_symbolic_forward(index_array, [input_array], [expected])
check_symbolic_backward(index_array, [input_array], [np.ones(expected.shape)], [np.zeros_like(input_array)])

@with_seed()
def test_index_array_select_axes_zero_size():
with mx.np_compat(active=True):
data = mx.symbol.Variable("data")
index_array = mx.sym.contrib.index_array(data, axes=(2, 1))

input_array = np.ones((0, 0, 0, 0))
expected = np.zeros((0, 0, 2))

check_symbolic_forward(index_array, [input_array], [expected])
check_symbolic_backward(index_array, [input_array], [np.ones(expected.shape)], [np.zeros_like(input_array)])

# isolated execution bulking test function to be invoked with different env var settings
def _test_bulking_in_process(seed, time_per_iteration):
Expand Down