mirror of
https://github.com/pytorch/pytorch.git
synced 2026-11-20 09:04:25 +08:00
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:
committed by
Facebook Github Bot
parent
934fc28656
commit
f3a588fede
@@ -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());
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user