[jit] Reclaim some binary size. (#68038)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/68038

Replace const std::function& to c10::function_ref because the former uses type erasure and adds 5-10 KB size overhead and adds another level of indirection to call the underlying functions. In contrast a non-owning c10::function_ref will just compile down to a raw function pointer which should be much smaller.
ghstack-source-id: 146670523

Test Plan: eyes

Reviewed By: iseeyuan, mrshenli

Differential Revision: D32264619

fbshipit-source-id: 558538fd882b8e1f4e72c4fd5e9d36d05f301e1e
This commit is contained in:
Zhengxu Chen
2022-01-07 11:19:15 -08:00
committed by Facebook GitHub Bot
parent dd1121435b
commit 0408449244
3 changed files with 4 additions and 3 deletions

View File

@ -307,7 +307,7 @@ struct SchemaParser {
int begin,
int sep,
int end,
const std::function<void()>& callback) {
c10::function_ref<void()> callback) {
auto r = L.cur().range;
if (begin != TK_NOTHING)
L.expect(begin);

View File

@ -402,7 +402,7 @@ void SchemaTypeParser::parseList(
int begin,
int sep,
int end,
const std::function<void()>& callback) {
c10::function_ref<void()> callback) {
auto r = L.cur().range;
if (begin != TK_NOTHING)
L.expect(begin);

View File

@ -3,6 +3,7 @@
#include <ATen/core/Macros.h>
#include <ATen/core/alias_info.h>
#include <ATen/core/jit_type.h>
#include <c10/util/FunctionRef.h>
#include <torch/csrc/jit/frontend/lexer.h>
namespace torch {
@ -28,7 +29,7 @@ struct TORCH_API SchemaTypeParser {
int begin,
int sep,
int end,
const std::function<void()>& callback);
c10::function_ref<void()> callback);
bool complete_tensor_types;
Lexer& L;