[mlir][arith] Add expansion pattern for ext/trunc of bf16
authorRobert Suderman <suderman@google.com>
Thu, 6 Apr 2023 18:23:52 +0000 (18:23 +0000)
committerRobert Suderman <suderman@google.com>
Thu, 6 Apr 2023 18:24:02 +0000 (18:24 +0000)
commit8450bbf7f98d0de4b8df7b21835b3f15d25dfa2f
tree1f03dc58bc4fc1f8a0a42b5ab0e96f87a4843ef7
parentaee4399f58f4826180138fb294b6b0359c892709
[mlir][arith] Add expansion pattern for ext/trunc of bf16

bf16 has a trivial truncation/extension behavior with F32 that
can be described in elementary arith operations. Include some
expansions to efficiently convert including rounding towards
infinity for f32 to bf16 truncation.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D147585
mlir/include/mlir/Dialect/Arith/Transforms/Passes.h
mlir/include/mlir/Dialect/Arith/Transforms/Passes.td
mlir/lib/Dialect/Arith/Transforms/ExpandOps.cpp
mlir/test/Dialect/Arith/expand-ops.mlir
mlir/test/mlir-cpu-runner/expand-arith-ops.mlir [new file with mode: 0644]