You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_elemwise.py 645 B

1234567891011121314151617181920212223
  1. # -*- coding: utf-8 -*-
  2. import numpy as np
  3. import megengine.functional as F
  4. from megengine import tensor
  5. from megengine.module import Elemwise
  6. def test_module_elemwise():
  7. def test_func(method, *inps):
  8. elemwise = Elemwise(method)
  9. outputs = elemwise(*inps)
  10. return outputs.numpy()
  11. x = np.random.rand(100).astype("float32")
  12. y = np.random.rand(100).astype("float32")
  13. x, y = tensor(x), tensor(y)
  14. np.testing.assert_almost_equal(
  15. test_func("h_swish", x), F.hswish(x).numpy(), decimal=6
  16. )
  17. np.testing.assert_almost_equal(
  18. test_func("add", x, y), F.add(x, y).numpy(), decimal=6
  19. )