Add SourceView which doesn't own source text as base class of Source (#65309)

Summary:
This would save the cost copying text from stack to heap in some cases (like
parsing function schema during loading phase of libtorch.so)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/65309

Reviewed By: swolchok

Differential Revision: D31060315

Pulled By: gmagogsfm

fbshipit-source-id: 0caf7a688b40df52bb4388c5191d1a42351d6f1a
This commit is contained in:
gmagogsfm
2021-10-18 23:15:25 -07:00
committed by Facebook GitHub Bot
parent bff64e84cd
commit 147f7559b1
21 changed files with 174 additions and 90 deletions

View File

@ -18,12 +18,12 @@ def one(self, x: Tensor, y: Tensor) -> Tensor:
def forward(self, x: Tensor) -> Tensor:
return x
)JIT"};
static const auto parentForward = R"JIT(
static const std::string parentForward = R"JIT(
def forward(self, x: Tensor) -> Tensor:
return self.subMod.forward(x)
)JIT";
static const auto moduleInterfaceSrc = R"JIT(
static constexpr c10::string_view moduleInterfaceSrc = R"JIT(
class OneForward(ModuleInterface):
def one(self, x: Tensor, y: Tensor) -> Tensor:
pass