This is an archive of the discontinued LLVM Phabricator instance.

Add MLIR interpreter framework
Needs ReviewPublic

Authored by logan on Jul 1 2022, 10:18 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

This commit introduces an MLIR interpreter framework. This interpreter framework allows multiple dialects register their op implementations. The interpreter traverses the SSACFG regions, manages the mapping between SSA names and evaluated values, and calls the op implementations with the evaluated values of the operands.

Diff Detail

Event Timeline

logan created this revision.Jul 1 2022, 10:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2022, 10:18 PM
logan requested review of this revision.Jul 1 2022, 10:18 PM
logan updated this revision to Diff 441868.Jul 1 2022, 11:02 PM

Reformat with clang-format.

ezhulenev added inline comments.
mlir/include/mlir/Interpreter/InterpreterOpInterface.h
38

Should it also provide an option to specify required alignment?

53
ezhulenev added inline comments.Jul 2 2022, 8:23 AM
mlir/include/mlir/Interpreter/InterpreterOpInterface.h
38

Or should it even do manual memory management? Can it be a wrapper around std::any? You’ll get type checks, and automatic object destruction, and correct handling of alignment, plus a small value optimization for avoiding heap allocations.

ezhulenev added inline comments.Jul 2 2022, 12:26 PM
mlir/include/mlir/Interpreter/InterpreterOpInterface.h
58

I think it should become something like ::tfrt::Value (https://github.com/tensorflow/runtime/blob/master/include/tfrt/host_context/value.h), because right now the assumption is that whoever creates EvalValueImpl owns the storage behind the pointer, and it's hard to find such place inside the interpret interface implementation. It can't go to heap either, because there is no way to tell when it should be destructed.