microsoft / knossos-ksc

Compiler with automatic differentiation
Other
45 stars 10 forks source link

Lowering of build using edsc features of MLIR (v2) #1030

Closed dcrc2 closed 2 years ago

dcrc2 commented 2 years ago

Updated version of #692, rebasing onto master.

Original description from #692:

This PR showcases the usage of MLIR edsc features in the lowering of a build node.

edsc - Embedded Domain Specific Concepts

We move away from using a series of create calls on the builder itself, i.e. old build lowering Instead, we set up a ScopedContext once with the correct insertion point. Then we can use a much simpler declarative interface to emit new operations. new build lowering

This PR is tested to work partially with LLVM commit f4013359b3da2c78e94a64245de8638460f96c1a. e.g. lowering of maths.ks works as expected ksc-mlir MLIR mlir/test/Programs/maths.ks. However, due to slight changes in the MLIR format all FileCheck tests are expected to fail. Creating new FileCheck tests is eased dramatically by using generate-test-checks.py

dcrc2 commented 2 years ago

Several tests were failing in #692 when trying to lower code using scf.for to LLVM. This requires a preparatory pass to convert SCF to std (eqivalent to mlir-opt --convert-scf-to-std --convert-std-to-llvm as described in users/ml/relu3.md). Having fixed this problem, the only failing test is now build.ks for which the expected output has changed.

dcrc2 commented 2 years ago

Test expectations are now updated and this PR is ready.