This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tosa] Add tosa.negate lowerings for quantized cases
ClosedPublic

Authored by rsuderman on Apr 23 2021, 10:01 PM.

Details

Summary

Quantized negation can be performed using higher bits operations.
Minimal bits are picked to perform the operation.

Diff Detail

Event Timeline

rsuderman created this revision.Apr 23 2021, 10:01 PM
rsuderman requested review of this revision.Apr 23 2021, 10:01 PM
hanchung accepted this revision.Apr 26 2021, 12:56 AM
hanchung added inline comments.
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
167–170

why not keeping the same behavior as before, ie, use -args[0]?

172–221

I saw this in the spec

assert(in_t == aint8_t || input_zp == 0) // Zero point only for asymmetric int8
assert(in_t == aint8_t || output_zp == 0) // Zero point only for asymmetric int8

should we check if they are int8 or it's already checked in the op verifier?

182–184

How about not using std::abs in the declaration so we can use the variable below (to create zpDiffValue)?

This revision is now accepted and ready to land.Apr 26 2021, 12:56 AM
rsuderman updated this revision to Diff 341032.Apr 27 2021, 5:13 PM

Fixed for hanchung@ comments

rsuderman marked 3 inline comments as done.Apr 27 2021, 5:15 PM
rsuderman added inline comments.
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
167–170

I wanted to avoid the signed vs signless problem we have been experiencing recently. Moving to SubIOp avoids this. Likely I will fix this to a proper negate operation once it is plumbed through.

172–221

It should be covered by the verifiers. Also, as the aint_8 and int_8 are only distinguished by the operation attributes, its easier to just check zero point values and perform the necessary math.

This revision was landed with ongoing or failed builds.Apr 27 2021, 5:22 PM
This revision was automatically updated to reflect the committed changes.
rsuderman marked 2 inline comments as done.