MLIR
20.0.0git
|
The BytecodeReader allows to load MLIR bytecode files, while keeping the state explicitly available in order to support lazy loading. More...
#include "mlir/Bytecode/BytecodeReader.h"
Classes | |
class | Impl |
This class is used to read a bytecode buffer and translate it into MLIR. More... | |
Public Member Functions | |
BytecodeReader (llvm::MemoryBufferRef buffer, const ParserConfig &config, bool lazyLoad, const std::shared_ptr< llvm::SourceMgr > &bufferOwnerRef={}) | |
Create a bytecode reader for the given buffer. More... | |
~BytecodeReader () | |
LogicalResult | readTopLevel (Block *block, llvm::function_ref< bool(Operation *)> lazyOps=[](Operation *) { return false;}) |
Read the operations defined within the given memory buffer, containing MLIR bytecode, into the provided block. More... | |
int64_t | getNumOpsToMaterialize () const |
Return the number of ops that haven't been materialized yet. More... | |
bool | isMaterializable (Operation *op) |
Return true if the provided op is materializable. More... | |
LogicalResult | materialize (Operation *op, llvm::function_ref< bool(Operation *)> lazyOpsCallback=[](Operation *) { return false;}) |
Materialize the provide operation. More... | |
LogicalResult | finalize (function_ref< bool(Operation *)> shouldMaterialize=[](Operation *) { return true;}) |
Finalize the lazy-loading by calling back with every op that hasn't been materialized to let the client decide if the op should be deleted or materialized. More... | |
The BytecodeReader allows to load MLIR bytecode files, while keeping the state explicitly available in order to support lazy loading.
The finalize
method must be called before destruction.
Definition at line 30 of file BytecodeReader.h.
|
explicit |
Create a bytecode reader for the given buffer.
If lazyLoad
is true, isolated regions aren't loaded eagerly.
Definition at line 2530 of file BytecodeReader.cpp.
References mlir::FileLineColLoc::get(), and mlir::ParserConfig::getContext().
BytecodeReader::~BytecodeReader | ( | ) |
Definition at line 2528 of file BytecodeReader.cpp.
References getNumOpsToMaterialize().
LogicalResult BytecodeReader::finalize | ( | function_ref< bool(Operation *)> | shouldMaterialize = [](Operation *) { return true; } | ) |
Finalize the lazy-loading by calling back with every op that hasn't been materialized to let the client decide if the op should be deleted or materialized.
The op is materialized if the callback returns true, deleted otherwise. The implementation of the callback must be thread-safe.
Definition at line 2559 of file BytecodeReader.cpp.
int64_t BytecodeReader::getNumOpsToMaterialize | ( | ) | const |
Return the number of ops that haven't been materialized yet.
Definition at line 2545 of file BytecodeReader.cpp.
Referenced by ~BytecodeReader().
bool BytecodeReader::isMaterializable | ( | Operation * | op | ) |
Return true if the provided op is materializable.
Definition at line 2549 of file BytecodeReader.cpp.
LogicalResult BytecodeReader::materialize | ( | Operation * | op, |
llvm::function_ref< bool(Operation *)> | lazyOpsCallback = [](Operation *) { return false; } |
||
) |
Materialize the provide operation.
The provided operation must be materializable. The lazyOps call back is invoked for every ops that can be lazy-loaded. This let the client decide if the op should be materialized immediately or delayed. !! Using this materialize withing an IR walk() can be confusing: make sure to use a PreOrder traversal !!
Definition at line 2553 of file BytecodeReader.cpp.
LogicalResult BytecodeReader::readTopLevel | ( | Block * | block, |
llvm::function_ref< bool(Operation *)> | lazyOps = [](Operation *) { return false; } |
||
) |
Read the operations defined within the given memory buffer, containing MLIR bytecode, into the provided block.
If the reader was created with lazyLoad
enabled, isolated regions aren't loaded eagerly. The lazyOps call back is invoked for every ops that can be lazy-loaded. This let the client decide if the op should be materialized immediately or delayed.
Definition at line 2540 of file BytecodeReader.cpp.