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

added more tests to verify support for large vector #16477

Merged
merged 2 commits into from
Oct 17, 2019

Conversation

access2rohit
Copy link
Contributor

@access2rohit access2rohit commented Oct 14, 2019

Description

Added large vector support for following ops:
astype
cast
repeat
ceil
fix
floor
rint
round
trunk
arccos
arcsin
arctan
cos
degrees
radians
sin
tan

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Testing

Currently running full suite of tests. Will update description later.

@access2rohit access2rohit changed the title added more tests to verify support for large tensor added more tests to verify support for large vector Oct 14, 2019
@access2rohit
Copy link
Contributor Author

@mxnet-label-bot add [pr-awaiting-review]

@lanking520 lanking520 added the pr-awaiting-review PR is waiting for code review label Oct 14, 2019
@access2rohit
Copy link
Contributor Author

@anirudh2290 @ChaiBapchya @zheng-da this PR is ready for review

@access2rohit
Copy link
Contributor Author

test_large_vector.test_slice ... ok
test_large_vector.test_ndarray_zeros ... ok
test_large_vector.test_ndarray_ones ... ok
test_large_vector.test_ndarray_random_uniform ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=1144655568 to reproduce.
ok
test_large_vector.test_ndarray_random_randint ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=1684091458 to reproduce.
ok
test_large_vector.test_ndarray_empty ... ok
test_large_vector.test_elementwise ... ok
test_large_vector.test_clip ... ok
test_large_vector.test_argmin ... ok
test_large_vector.test_take ... ok
test_large_vector.test_slice_assign ... ok
test_large_vector.test_expand_dims ... ok
test_large_vector.test_squeeze ... ok
test_large_vector.test_broadcast_div ... ok
test_large_vector.test_Dense ... ok
test_large_vector.test_argsort ... ok
test_large_vector.test_sort ... ok
test_large_vector.test_topk ... ok
test_large_vector.test_mean ... ok
test_large_vector.test_ndarray_random_exponential ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=943611710 to reproduce.
ok
test_large_vector.test_ndarray_random_gamma ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=356755980 to reproduce.
ok
test_large_vector.test_ndarray_random_generalized_negative_binomial ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=178540928 to reproduce.
ok
test_large_vector.test_ndarray_random_multinomial ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=1062260943 to reproduce.
ok
test_large_vector.test_ndarray_random_negative_binomial ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=70590822 to reproduce.
ok
test_large_vector.test_ndarray_random_normal ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=765355435 to reproduce.
ok
test_large_vector.test_ndarray_random_poisson ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=1968108703 to reproduce.
ok
test_large_vector.test_ndarray_random_randn ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=1789819397 to reproduce.
ok
test_large_vector.test_ndarray_random_shuffle ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=698233837 to reproduce.
ok
test_large_vector.test_exponent_logarithm_operators ... ok
test_large_vector.test_power_operators ... ok
test_large_vector.test_sequence_mask ... ok
test_large_vector.test_sequence_reverse ... ok
test_large_vector.test_sequence_last ... ok
test_large_vector.test_layer_norm ... ok
test_large_vector.test_batchnorm ... ok
test_large_vector.test_add ... ok
test_large_vector.test_sub ... ok
test_large_vector.test_rsub ... ok
test_large_vector.test_neg ... ok
test_large_vector.test_mul ... ok
test_large_vector.test_div ... ok
test_large_vector.test_rdiv ... ok
test_large_vector.test_mod ... ok
test_large_vector.test_rmod ... ok
test_large_vector.test_imod ... ok
test_large_vector.test_pow ... ok
test_large_vector.test_rpow ... ok
test_large_vector.test_shape ... ok
test_large_vector.test_size ... ok
test_large_vector.test_copy ... ok
test_large_vector.test_copy_to ... ok
test_large_vector.test_zeros_like ... ok
test_large_vector.test_ones_like ... ok
test_large_vector.test_concat ... ok
test_large_vector.test_sum ... ok
test_large_vector.test_prod ... ok
test_large_vector.test_min ... ok
test_large_vector.test_max ... ok
test_large_vector.test_argmax ... ok
test_large_vector.test_iadd ... ok
test_large_vector.test_isub ... ok
test_large_vector.test_imul ... ok
test_large_vector.test_idiv ... ok
test_large_vector.test_eq ... ok
test_large_vector.test_neq ... ok
test_large_vector.test_lt ... ok
test_large_vector.test_lte ... ok
test_large_vector.test_gt ... ok
test_large_vector.test_gte ... ok
test_large_vector.test_slice_like ... ok
test_large_vector.test_slice_axis ... ok
test_large_vector.test_full ... ok
test_large_vector.test_astype ... ok
test_large_vector.test_cast ... ok
test_large_vector.test_repeat ... ok
test_large_vector.test_ceil ... ok
test_large_vector.test_fix ... ok
test_large_vector.test_floor ... ok
test_large_vector.test_rint ... ok
test_large_vector.test_round ... ok
test_large_vector.test_trunc ... ok
test_large_vector.test_arcsin ... ok
test_large_vector.test_arccos ... ok
test_large_vector.test_arctan ... ok
test_large_vector.test_sin ... ok
test_large_vector.test_cos ... ok
test_large_vector.test_tan ... ok
test_large_vector.test_radians ... ok
test_large_vector.test_degrees ... ok

@anirudh2290
Copy link
Member

randint not failing now ?

@ChaiBapchya
Copy link
Contributor

Randint has been flaky.
Tracked here #16172

def test_ceil():
x = create_input_for_rounding_ops()
y = nd.ceil(x)
assert y[LARGE_X//2-2] == -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this testing, can you add some comment here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as below

assert y[LARGE_X//2-2] == -1
assert y[LARGE_X//2-1] == 0
assert y[LARGE_X//2] == 0
assert y[LARGE_X//2+1] == 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a bunch of repeated code that can be reused in these 5 tests.

Copy link
Contributor Author

@access2rohit access2rohit Oct 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all different assertions that explain the difference between each of the rounding functions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a nice to have, not blocking on this. But this pattern can be refactored: create input, execute op, check output at specific indexes ( which happen to be same among all tests).

def test_fix():
x = create_input_for_rounding_ops()
y = nd.fix(x)
assert y[LARGE_X//2-2] == -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add some comment of what it is testing, here and for other tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't docs supposed to explain what a particular function is supposed to be doing? http://mxnet.incubator.apache.org/api/python/docs/api/ndarray/ndarray.html#mxnet.ndarray.fix

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my request is to explain the tests: why only these specific positions are checked as -1 or 0 , something to say x was this before we applied fix on it and what we get is expected because of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok got it. I will add comments explaining this. Good point

x = nd.array([0, 90, 180, 270, 360])
x = nd.tile(x, LARGE_X//5)
y = nd.radians(x)
assert_almost_equal(y[0].asnumpy(), 0, atol=1e-3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont both parameters have to be numpy ndarrays ?

Copy link
Contributor Author

@access2rohit access2rohit Oct 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.... this implementation worked too I can change it to following instead
assert np.abs(y[0].asnumpy() - 0) <= 1e-3
do you think this is better ?

Copy link
Member

@anirudh2290 anirudh2290 Oct 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its fine if it works. maybe broadcasting by default

@pengzhao-intel
Copy link
Contributor

@wuxun-zhang maybe take a look for new tests :)

expected_output = [-1, -1, 0, 0, 1]
assert_correctness_of_rounding_ops(y, LARGE_X//2, expected_output)

def test_rint():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have seen that internal functions starting with test_ can cause issues with nosetests, can you change the name to check_

Copy link
Contributor Author

@access2rohit access2rohit Oct 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate what kind of issues did you see ? Is there a previous github issue that I can look at, in order to understand why is it necessary to not have internal function names not starting with test_
I ran the the individual test and didn't see any issue:
test_large_vector.test_trigonometric_ops ... ok test_large_vector.test_rounding_ops ... ok

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nosetests generally looks for functions starting with "test_", thus this function could be mistaken for being a standalone test

@access2rohit
Copy link
Contributor Author

test_large_vector.test_rounding_ops ... ok test_large_vector.test_trigonometric_ops ... ok

This was referenced Oct 17, 2019
@access2rohit
Copy link
Contributor Author

test_large_vector.test_slice ... ok
test_large_vector.test_ndarray_zeros ... ok
test_large_vector.test_ndarray_ones ... ok
test_large_vector.test_ndarray_random_uniform ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=1451834425 to reproduce.
ok
test_large_vector.test_ndarray_random_randint ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=1363003807 to reproduce.
ok
test_large_vector.test_ndarray_empty ... ok
test_large_vector.test_elementwise ... ok
test_large_vector.test_clip ... ok
test_large_vector.test_argmin ... ok
test_large_vector.test_take ... ok
test_large_vector.test_slice_assign ... ok
test_large_vector.test_expand_dims ... ok
test_large_vector.test_squeeze ... ok
test_large_vector.test_broadcast_div ... ok
test_large_vector.test_Dense ... ok
test_large_vector.test_argsort ... ok
test_large_vector.test_sort ... ok
test_large_vector.test_topk ... ok
test_large_vector.test_mean ... ok
test_large_vector.test_ndarray_random_exponential ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=1039862763 to reproduce.
ok
test_large_vector.test_ndarray_random_gamma ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=1078928503 to reproduce.
ok
test_large_vector.test_ndarray_random_generalized_negative_binomial ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=209368341 to reproduce.
ok
test_large_vector.test_ndarray_random_multinomial ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=750746329 to reproduce.
ok
test_large_vector.test_ndarray_random_negative_binomial ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=147292392 to reproduce.
ok
test_large_vector.test_ndarray_random_normal ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=1438617810 to reproduce.
ok
test_large_vector.test_ndarray_random_poisson ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=1956074936 to reproduce.
ok
test_large_vector.test_ndarray_random_randn ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=171582080 to reproduce.
ok
test_large_vector.test_ndarray_random_shuffle ... [DEBUG] Setting test np/mx/python random seeds, use MXNET_TEST_SEED=1205411016 to reproduce.
ok
test_large_vector.test_exponent_logarithm_operators ... ok
test_large_vector.test_power_operators ... ok
test_large_vector.test_sequence_mask ... ok
test_large_vector.test_sequence_reverse ... ok
test_large_vector.test_sequence_last ... ok
test_large_vector.test_layer_norm ... ok
test_large_vector.test_batchnorm ... ok
test_large_vector.test_add ... ok
test_large_vector.test_sub ... ok
test_large_vector.test_rsub ... ok
test_large_vector.test_neg ... ok
test_large_vector.test_mul ... ok
test_large_vector.test_div ... ok
test_large_vector.test_rdiv ... ok
test_large_vector.test_mod ... ok
test_large_vector.test_rmod ... ok
test_large_vector.test_imod ... ok
test_large_vector.test_pow ... ok
test_large_vector.test_rpow ... ok
test_large_vector.test_shape ... ok
test_large_vector.test_size ... ok
test_large_vector.test_copy ... ok
test_large_vector.test_copy_to ... ok
test_large_vector.test_zeros_like ... ok
test_large_vector.test_ones_like ... ok
test_large_vector.test_concat ... ok
test_large_vector.test_sum ... ok
test_large_vector.test_prod ... ok
test_large_vector.test_min ... ok
test_large_vector.test_max ... ok
test_large_vector.test_argmax ... ok
test_large_vector.test_iadd ... ok
test_large_vector.test_isub ... ok
test_large_vector.test_imul ... ok
test_large_vector.test_idiv ... ok
test_large_vector.test_eq ... ok
test_large_vector.test_neq ... ok
test_large_vector.test_lt ... ok
test_large_vector.test_lte ... ok
test_large_vector.test_gt ... ok
test_large_vector.test_gte ... ok
test_large_vector.test_slice_like ... ok
test_large_vector.test_slice_axis ... ok
test_large_vector.test_full ... ok
test_large_vector.test_astype ... ok
test_large_vector.test_cast ... ok
test_large_vector.test_repeat ... ok
test_large_vector.test_rounding_ops ... ok
test_large_vector.test_trigonometric_ops ... ok


Ran 77 tests in 3950.523s

OK

@access2rohit
Copy link
Contributor Author

access2rohit commented Oct 17, 2019

@mxnet-label-bot add [pr-awaiting-merge]

@lanking520 lanking520 added the pr-awaiting-merge Review and CI is complete. Ready to Merge label Oct 17, 2019
@aaronmarkham aaronmarkham merged commit bf57ff8 into apache:master Oct 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-merge Review and CI is complete. Ready to Merge pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants