Delete SchemaRegister.cpp, make flag operate on TypeDefault.cpp#46991
Delete SchemaRegister.cpp, make flag operate on TypeDefault.cpp#46991ezyang wants to merge 2 commits intogh/ezyang/858/basefrom
Conversation
This change is motivated by a problem bdhirsh observed which is that in internal builds that include both SchemaRegister.cpp and TypeDefault.cpp, some operators have their schemas defined multiple times. Instead of dumping schema registrations in multiple files, it seems better to just toggle how many schemas we write into TypeDefault.cpp. ljk53 observes that technically SchemaRegister.cpp is only needed by full-JIT frontend, and not by light interpreter (to resolve schema lookups). However, in practice, the registration file seems to be unconditionally loaded. This change will make it harder to do the optimization where we drop schemas in the light interpreter, but you probably want to architect this differently (similar to per-op registrations, DON'T do any registrations in ATen, and then write out the schema registrations in a separate library.) I took this opportunity to also simplify the TypeDefault generation logic by reworking things so that we only ever call with None argument when registering. Soon, we should be able to just split these files up entirely. Signed-off-by: Edward Z. Yang <ezyang@fb.com> [ghstack-poisoned]
…t.cpp" This change is motivated by a problem bdhirsh observed which is that in internal builds that include both SchemaRegister.cpp and TypeDefault.cpp, some operators have their schemas defined multiple times. Instead of dumping schema registrations in multiple files, it seems better to just toggle how many schemas we write into TypeDefault.cpp. ljk53 observes that technically SchemaRegister.cpp is only needed by full-JIT frontend, and not by light interpreter (to resolve schema lookups). However, in practice, the registration file seems to be unconditionally loaded. This change will make it harder to do the optimization where we drop schemas in the light interpreter, but you probably want to architect this differently (similar to per-op registrations, DON'T do any registrations in ATen, and then write out the schema registrations in a separate library.) I took this opportunity to also simplify the TypeDefault generation logic by reworking things so that we only ever call with None argument when registering. Soon, we should be able to just split these files up entirely. Signed-off-by: Edward Z. Yang <ezyang@fb.com> [ghstack-poisoned]
This change is motivated by a problem bdhirsh observed which is that in internal builds that include both SchemaRegister.cpp and TypeDefault.cpp, some operators have their schemas defined multiple times. Instead of dumping schema registrations in multiple files, it seems better to just toggle how many schemas we write into TypeDefault.cpp. ljk53 observes that technically SchemaRegister.cpp is only needed by full-JIT frontend, and not by light interpreter (to resolve schema lookups). However, in practice, the registration file seems to be unconditionally loaded. This change will make it harder to do the optimization where we drop schemas in the light interpreter, but you probably want to architect this differently (similar to per-op registrations, DON'T do any registrations in ATen, and then write out the schema registrations in a separate library.) I took this opportunity to also simplify the TypeDefault generation logic by reworking things so that we only ever call with None argument when registering. Soon, we should be able to just split these files up entirely. Signed-off-by: Edward Z. Yang <ezyang@fb.com> ghstack-source-id: f1e7c46 Pull Request resolved: #46991
💊 CI failures summary and remediationsAs of commit 819e9ab (more details on the Dr. CI page):
🚧 1 fixed upstream failure:These were probably caused by upstream breakages that were already fixed.
Please rebase on the
|
| args_str = ', '.join(map(str, args)) | ||
| # TODO: don't need dispatch is None shortly | ||
| dispatch_to_all_backends = dispatch is None or dispatch in KEYWORD_ALL_BACKENDS | ||
| dispatch_to_all_backends = dispatch is not None and dispatch in KEYWORD_ALL_BACKENDS |
There was a problem hiding this comment.
nit: we don't really need the is not None check since KEYWORD_ALL_BACKENDS doesn't contain None
There was a problem hiding this comment.
Actually we do, because KEYWORD_ALL_BACKENDS is typed as a dict from string to thing, so a None value woudn't be well typed 👍
| return { | ||
| 'schema_registrations': schema_registrations, | ||
| } | ||
| cpu_fm.write('SchemaRegister.cpp', computeSchemaRegister) |
There was a problem hiding this comment.
The old SchemaRegister.cpp file used the TORCH_LIBRARY_FRAGMENT_THIS_API.... macro instead of TORCH_LIBRARY, so merging all of the logic into TypeDefault.cpp means that we no longer use that macro.
Just checking, but I actually think that's fine in this case- right? That macro lets us add multiple blocks that use the same namespace. My guess as to why we originally used that macro in SchemaRegister.cpp is because of the fact that we explicitly had op registration blocks for aten in two files- and now we only have it in one.
(tldr; my round-about way of saying that this change is correct)
…rch#46991) Summary: Pull Request resolved: pytorch#46991 This change is motivated by a problem bdhirsh observed which is that in internal builds that include both SchemaRegister.cpp and TypeDefault.cpp, some operators have their schemas defined multiple times. Instead of dumping schema registrations in multiple files, it seems better to just toggle how many schemas we write into TypeDefault.cpp. ljk53 observes that technically SchemaRegister.cpp is only needed by full-JIT frontend, and not by light interpreter (to resolve schema lookups). However, in practice, the registration file seems to be unconditionally loaded. This change will make it harder to do the optimization where we drop schemas in the light interpreter, but you probably want to architect this differently (similar to per-op registrations, DON'T do any registrations in ATen, and then write out the schema registrations in a separate library.) I took this opportunity to also simplify the TypeDefault generation logic by reworking things so that we only ever call with None argument when registering. Soon, we should be able to just split these files up entirely. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Test Plan: Imported from OSS Reviewed By: ljk53 Differential Revision: D24593704 Pulled By: ezyang fbshipit-source-id: f01ea22a3999493da77b6e254d188da0ce9adf2f
Stack from ghstack:
This change is motivated by a problem bdhirsh observed which is
that in internal builds that include both SchemaRegister.cpp
and TypeDefault.cpp, some operators have their schemas defined
multiple times. Instead of dumping schema registrations in
multiple files, it seems better to just toggle how many schemas
we write into TypeDefault.cpp.
ljk53 observes that technically SchemaRegister.cpp is only needed by
full-JIT frontend, and not by light interpreter (to resolve schema
lookups). However, in practice, the registration file seems to be
unconditionally loaded. This change will make it harder to do the
optimization where we drop schemas in the light interpreter, but you
probably want to architect this differently (similar to per-op
registrations, DON'T do any registrations in ATen, and then write out
the schema registrations in a separate library.)
I took this opportunity to also simplify the TypeDefault generation
logic by reworking things so that we only ever call with None argument
when registering. Soon, we should be able to just split these
files up entirely.
Signed-off-by: Edward Z. Yang ezyang@fb.com
Differential Revision: D24593704