From 405c15516c3a052fbad33fa8fcb6cde84ebc97d8 Mon Sep 17 00:00:00 2001 From: Bert Maher Date: Sat, 28 Aug 2021 19:57:10 -0700 Subject: [PATCH] Parse int64 sizes/strides (#64076) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/64076 We were parsing sizes into int32s, so if you had a tensor with more than 2^32 elements, you couldn't represent it. ghstack-source-id: 136933273 Test Plan: parseIR with size of 4e9 Reviewed By: ZolotukhinM Differential Revision: D30521116 fbshipit-source-id: 1e28e462cba52d648e0e2acb4e234d86aae25a3e --- torch/csrc/jit/frontend/schema_type_parser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/torch/csrc/jit/frontend/schema_type_parser.cpp b/torch/csrc/jit/frontend/schema_type_parser.cpp index db1a1e8..b4e6ca8 100644 --- a/torch/csrc/jit/frontend/schema_type_parser.cpp +++ b/torch/csrc/jit/frontend/schema_type_parser.cpp @@ -235,7 +235,7 @@ TypePtr SchemaTypeParser::parseRefinedTensor() { const std::string& num = L.expect(TK_NUMBER).text(); // NOLINTNEXTLINE(cppcoreguidelines-init-variables) std::string::size_type num_len; - size_t stride = c10::stoi(num, &num_len); + auto stride = c10::stoll(num, &num_len); strides.push_back(stride); }); return; @@ -260,7 +260,7 @@ TypePtr SchemaTypeParser::parseRefinedTensor() { const std::string& num = L.expect(TK_NUMBER).text(); // NOLINTNEXTLINE(cppcoreguidelines-init-variables) std::string::size_type num_len; - size_t dim = c10::stoi(num, &num_len); + auto dim = c10::stoll(num, &num_len); dims.emplace_back(dim); }); if (seen_strides) { -- 2.7.4