Skip to content

Commit

Permalink
[jit][edge] Return a no-op nullptr for UnionType on mobile for backwa…
Browse files Browse the repository at this point in the history
…rd compatibility. (pytorch#71341)

Summary:
Pull Request resolved: pytorch#71341

Old models containing UnionType need to be loaded even if they don't actually use Unions.
This is not the best solution, we need to catch this error on the compiler side instead, but before doing that we can land this first to at least mitigate model loading crash issues.
ghstack-source-id: 147056684

Test Plan:
CI
Verified with jaebong on his device locally.

Differential Revision: D33593276

fbshipit-source-id: fac4bc85c652974c7c10186a29f36e3e411865ad
  • Loading branch information
zhxchen17 authored and facebook-github-bot committed Jan 15, 2022
1 parent b7222e1 commit a138aad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions torch/csrc/jit/mobile/type_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ TypePtr TypeParser::parse() {
// other class starts with __torch__ following by custom names
return parseCustomType();
}
} else if (token == "Union") {
// TODO Union types are not supported on embedded runtime, and we need to
// generate compiler errors for users scripting UnionTypes. Right now
// for preserving backward compatibility we have to return a nullptr since
// it does not get involved in type reflection.
return nullptr;
} else {
TORCH_CHECK(
false,
Expand Down

0 comments on commit a138aad

Please sign in to comment.