Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions test/test_jit_einsum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import torch
from common import TestCase


class TestEinsum(TestCase):
def test_jit(self):

def fn(x, y):
return torch.einsum('i,j->ij', x, y)

jit_fn = torch.jit.trace(fn, (torch.ones(2), torch.ones(3)), check_trace=False)

x = torch.randn(2)
y = torch.randn(3)
expected = fn(x, y)
actual = jit_fn(x, y)
self.assertLess(torch.abs(actual - expected) < 1e-6)
2 changes: 1 addition & 1 deletion torch/csrc/jit/tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void addInputs(Node *n, const char * name, bool value) { detail::g
void addInputs(Node *n, const char * name, double value) { detail::genericAddInput(n, value); }
void addInputs(Node *n, const char * name, const at::Scalar& value) { detail::genericAddInput(n, value); }
void addInputs(Node *n, const char * name, const at::Tensor& value) { n->addInput(getValueTrace(value)); }
void addInputs(Node *n, const char * name, const std::string& value) { detail::badArgType(); }
void addInputs(Node *n, const char * name, const std::string& value) { detail::genericAddInput(n, value); }
void addInputs(Node *n, const char * name, const at::SparseTensorRef& value) { detail::badArgType(); }

void addInputs(Node *n, const char * name, at::TensorList value) {
Expand Down