Skip to content

Commit

Permalink
Add power, exponent, log ops large tensor support (apache#15794)
Browse files Browse the repository at this point in the history
* power, exponent, log ops

* lint

* Trigger notification

* Trigger notification

* Trigger notification
  • Loading branch information
ChaiBapchya authored and Rohit Kumar Srivastava committed Sep 25, 2019
1 parent 6a0d53c commit 4fb8a2e
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions tests/nightly/test_large_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,72 @@ def test_topk():
assert l.sum() == np.sum(np.arange(0, SMALL_Y))


def test_exponent_logarithm_operators():
a = 2*nd.ones(shape=(LARGE_X, SMALL_Y))
# exponent
result = nd.exp(a)
assert result[0][-1] == 7.389056
assert result.shape == a.shape

# exponent minus 1
result = nd.expm1(a)
assert result[0][-1] == 6.389056
assert result.shape == a.shape

# log2
result = nd.log2(a)
assert result[0][-1] == 1
assert result.shape == a.shape

# log10
result = nd.log10(a)
assert result[0][-1] == 0.30103
assert result.shape == a.shape

# log1p
result = nd.log1p(a)
assert result[0][-1] == 1.0986123
assert result.shape == a.shape

# log
result = nd.log(a)
assert result[0][-1] == 0.6931472
assert result.shape == a.shape


def test_power_operators():
a = 2*nd.ones(shape=(LARGE_X, SMALL_Y))
# sqrt
result = nd.sqrt(a)
assert result[0][-1] == 1.4142135
assert result.shape == a.shape

# rsqrt
result = nd.rsqrt(a)
assert result[0][-1] == 0.70710677
assert result.shape == a.shape

# cbrt
result = nd.cbrt(a)
assert result[0][-1] == 1.2599211
assert result.shape == a.shape

# rcbrt
result = nd.rcbrt(a)
assert result[0][-1] == 0.7937005
assert result.shape == a.shape

# square
result = nd.square(a)
assert result[0][-1] == 4
assert result.shape == a.shape

# reciprocal
result = nd.reciprocal(a)
assert result[0][-1] == 0.5
assert result.shape == a.shape


def test_sequence_mask():
# Sequence Mask input [max_sequence_length, batch_size, other_feature_dims]
# test with input batch_size = 2
Expand Down

0 comments on commit 4fb8a2e

Please sign in to comment.