Catch invalid scalar type when parsing tensors (#1518)
Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/1518 Fail non-fatally when encountering an unknown/unhandled `ScalarType` in a `.pte` file. As part of this: - Move the "types not supported yet" logic out of `scalar_type_util` and into `tensor_parser`, since that decision is an aspect of the runtime and not a fundamental aspect of `ScalarType`. - Remove the now-duplicate `sizeof_scalar_type` function, which is the same as the exsting `elementSize` function. Before this diff, `sizeof_scalar_type` did the "unsupported" checks that have now moved. - Add an `isValid()` function to let users of `ScalarType` know whether a given enum value is legit. This makes it possible to avoid the fatal error when calling `elementSize` on a bad value. - Add unit tests for the new `isValid()`. Reviewed By: larryliu0820 Differential Revision: D52451738 fbshipit-source-id: 88e47d7a3c688e3e2a68cc86114935c7ff6a73b5
D
Dave Bort committed
89958d27bce760ca714cfac02171a0db0aaf96ce
Parent: d869385
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 1/3/2024, 9:00:52 PM