mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[jit][edge] Migrate to TypeFactory for jit types on mobile (#71516)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/71516 Mobile should be able to contruct dynamic types by default. ghstack-source-id: 147498365 Test Plan: CI. **-48KB** binary size reduction for igios BSB. UMBEX link: https://www.internalfb.com/intern/unigraph/explorer/?jsgq_traversal_spec=%7B%22builds%22%3A[%22bsb%3A422553426218394%5Cu0040base%22%2C%22bsb%3A422553426218394%5Cu0040diff%22]%7D&unigraph_project=UnigraphProjectMbex&is_mbex_redirected Reviewed By: iseeyuan Differential Revision: D33673958 fbshipit-source-id: 8600c04ae929283681971aae264d3774188df9cd (cherry picked from commit 64ebcec09e69d2eff64fdbf926fb43d3b67f99b2)
This commit is contained in:
committed by
PyTorch MergeBot
parent
e5794974cb
commit
fe277b8717
@ -108,7 +108,11 @@ std::pair<IValue, IValue> getFunctionTuple(
|
||||
static const std::string torch_prefix("__torch__");
|
||||
static const std::string class_prefix("__torch__.torch.classes");
|
||||
|
||||
for (const TypePtr& t : mobile_code.types_) {
|
||||
for (const TypePtr& ty : mobile_code.types_) {
|
||||
auto t = ty;
|
||||
if (auto dyn = t->castRaw<c10::DynamicType>()) {
|
||||
t = dyn->fallback();
|
||||
}
|
||||
std::string type_str = t->annotation_str();
|
||||
if (t->kind() == TypeKind::TupleType) {
|
||||
TORCH_CHECK(
|
||||
@ -216,9 +220,13 @@ std::pair<IValue, IValue> getFunctionTuple(
|
||||
arg.type()->annotation_str(type_printer) => mangled unique name of the
|
||||
module/submodule
|
||||
*/
|
||||
auto arg_type = arg.type();
|
||||
if (auto dyn = arg_type->castRaw<c10::DynamicType>()) {
|
||||
arg_type = dyn->fallback();
|
||||
}
|
||||
argTables.emplace_back(Table({
|
||||
{"name", arg.name()},
|
||||
{"type", arg.type()->annotation_str(type_printer)},
|
||||
{"type", arg_type->annotation_str(type_printer)},
|
||||
{"default_value", arg.default_value()},
|
||||
}));
|
||||
}
|
||||
|
Reference in New Issue
Block a user