Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TOSA] Refactor: Use tosaCastTensorToType() function to create tosa.cast
* Previously, in Torch to TOSA, there are 3 ways to create tosa.cast op: - `rewriter.create<tosa::CastOp>()` - `tosa::promoteType()` - `tosa::tosaCastTensorToType()` * This commit combines the three APIs above into `tosa::tosaCastTensorToType()` with the following features: - Checking whether source and destination element types are the same before casting. If they are same, skip the cast. - Custom float to integer cast behavior added from this PR: #3946 TLDR: PyTorch's and TOSA's float to integer casting behaviors are different (round to zero vs round to nearest, respectively), which requires a custom casting here. - Future `TODO`: add a --strict mode which includes `checkValidityOfCast()` to ensure that the casting pairs follow TOSA specifications. * Update LIT tests. Signed-off-by: Justin Ngo <justin.ngo@arm.com> Change-Id: I2aef3c79d8f2d98b93e671d5b815b8eab33e697e
- Loading branch information