summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSebastian Messmer <messmer@fb.com>2019-01-29 18:02:21 -0800
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2019-01-29 18:22:52 -0800
commit7c66ad7455ae7acf215e07a6d4dcd70736c77517 (patch)
treecae9560f61f3c96afd86b794ce1cb083dde9e66c /test
parent12f92f453bd059fd5e58a4e49f10e3de638f0019 (diff)
downloadpytorch-7c66ad7455ae7acf215e07a6d4dcd70736c77517.tar.gz
pytorch-7c66ad7455ae7acf215e07a6d4dcd70736c77517.tar.bz2
pytorch-7c66ad7455ae7acf215e07a6d4dcd70736c77517.zip
Add test case for calling c10 ops from pytorch
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/16062 Reviewed By: ezyang Differential Revision: D13628955 fbshipit-source-id: f6ed3f07db2675bd9ae9251da990ca7b8c963717
Diffstat (limited to 'test')
-rw-r--r--test/test_torch.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/test_torch.py b/test/test_torch.py
index e5304ef020..5b05cd6993 100644
--- a/test/test_torch.py
+++ b/test/test_torch.py
@@ -9968,6 +9968,16 @@ tensor([[[1., 1., 1., ..., 1., 1., 1.],
do_test(torch.tensor([[1, 2]]).data)
do_test(torch.tensor([[1, 2]]).detach())
+ def test_c10_layer_norm(self):
+ # test that we can call c10 ops and they return a reasonable result
+ X = torch.rand(5, 5, dtype=torch.float)
+ epsilon = 1e-4
+
+ expected_norm = torch.nn.functional.layer_norm(X, X.size()[1:], eps=epsilon)
+ actual_norm, actual_mean, actual_stdev = \
+ torch.ops.caffe2.layer_norm_dont_use_this_op_yet(torch.tensor(X), 1, epsilon)
+ torch.testing.assert_allclose(expected_norm, actual_norm)
+
# Functions to test negative dimension wrapping
METHOD = 1
INPLACE_METHOD = 2