add len to nativeResolver (#15488)

Summary:
(otherwise len is not resolvable using torch::jit::compile)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15488

Differential Revision: D13539991

Pulled By: zdevito

fbshipit-source-id: 3ba85fa7b1adb163f9229c568f7997d22321903d
This commit is contained in:
Zachary DeVito
2018-12-21 16:44:19 -08:00
committed by Facebook Github Bot
parent 934fc28656
commit f3a588fede
3 changed files with 8 additions and 0 deletions
+6
View File
@@ -16,6 +16,8 @@ TEST(TorchScriptTest, CanCompileMultipleFunctions) {
a += a
i += 1
return a
def test_len(a : List[int]):
return len(a)
)JIT");
auto a = torch::ones(1);
auto b = torch::ones(1);
@@ -26,4 +28,8 @@ TEST(TorchScriptTest, CanCompileMultipleFunctions) {
ASSERT_TRUE(
0x200 == module->run_method("test_while", a, b).toTensor().item<int64_t>());
at::IValue list = std::vector<int64_t>({3, 4});
ASSERT_EQ(2, module->run_method("test_len", list).toInt());
}