Simplify and enable pretty-parsing/printing of the uniform quantized types.
authorStella Laurenzo <laurenzo@google.com>
Fri, 19 Apr 2019 21:41:31 +0000 (14:41 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Wed, 24 Apr 2019 05:01:18 +0000 (22:01 -0700)
commit4292294a65e795a464070dbf290a44eb029904d6
tree846e3d66052e25b5bc7b20d48b7e48d9894b262c
parent0b47f740376e273a8be42fd0ae7b103623a61af5
Simplify and enable pretty-parsing/printing of the uniform quantized types.

    The per-layer format is now like:
      !quant.uniform<i8<-8:7>:f32, 9.987200e-01:127>
    and per-axis is:
      !quant.uniform<i8:f32:1, {2.0e+2,0.99872:120}>

    I used the following sed script to update the unit tests (invoked with commands like `sed -i -r -f fix_quant.sed $(find . -name '*.mlir')`).
    ---
    # Per-layer
    s|\!quant<"uniform\[([iu][0-9]+):([fb]+[0-9]+)\]\{([^\}]+)\}\s*">|!quant.uniform<\1:\2, \3>|g
    s|\!quant<"uniform\[([iu][0-9]+)\(([^\)]+)\):([fb]+[0-9]+)\]\{([^\}]+)\}\s*">|!quant.uniform<\1<\2>:\3, \4>|g

    # Per-axis
    s|\!quant<"uniform\[([iu][0-9]+):([fb]+[0-9]+)(:[0-9]+)?\]\{([^\}]+)\}\s*">|!quant.uniform<\1:\2\3, {\4}>|g
    s|\!quant<"uniform\[([iu][0-9]+)\(([^\)]+)\):([fb]+[0-9]+)(:[0-9]+)?\]\{([^\}]+)\}\s*">|!quant.uniform<\1<\2>:\3\4, {\5}>|g
    ---
    I fixed up the one file of error cases manually.
    Since this is a one time syntax fix, I am not persisting the script anywhere.

--

PiperOrigin-RevId: 244425331
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/Quantization/IR/TypeParser.cpp
mlir/test/FxpMathOps/lower-uniform-real-math-addew.mlir
mlir/test/FxpMathOps/lower-uniform-real-math-mulew.mlir
mlir/test/Quantization/canonicalize.mlir
mlir/test/Quantization/convert-const.mlir
mlir/test/Quantization/convert-fakequant.mlir
mlir/test/Quantization/parse-uniform-invalid.mlir
mlir/test/Quantization/parse-uniform.mlir