LLVM 22.0.0git
|
Embedder provides the interface to generate embeddings (vector representations) for instructions, basic blocks, and functions. More...
#include "llvm/Analysis/IR2Vec.h"
Public Member Functions | |
virtual | ~Embedder ()=default |
LLVM_ABI const InstEmbeddingsMap & | getInstVecMap () const |
Returns a map containing instructions and the corresponding embeddings for the function F if it has been computed. | |
LLVM_ABI const BBEmbeddingsMap & | getBBVecMap () const |
Returns a map containing basic block and the corresponding embeddings for the function F if it has been computed. | |
LLVM_ABI const Embedding & | getBBVector (const BasicBlock &BB) const |
Returns the embedding for a given basic block in the function F if it has been computed. | |
LLVM_ABI const Embedding & | getFunctionVector () const |
Computes and returns the embedding for the current function. | |
Static Public Member Functions | |
static LLVM_ABI std::unique_ptr< Embedder > | create (IR2VecKind Mode, const Function &F, const Vocabulary &Vocab) |
Factory method to create an Embedder object. | |
Protected Member Functions | |
LLVM_ABI | Embedder (const Function &F, const Vocabulary &Vocab) |
void | computeEmbeddings () const |
Function to compute embeddings. | |
virtual void | computeEmbeddings (const BasicBlock &BB) const =0 |
Function to compute the embedding for a given basic block. | |
Protected Attributes | |
const Function & | F |
const Vocabulary & | Vocab |
const unsigned | Dimension |
Dimension of the vector representation; captured from the input vocabulary. | |
const float | OpcWeight |
Weights for different entities (like opcode, arguments, types) in the IR instructions to generate the vector representation. | |
const float | TypeWeight |
const float | ArgWeight |
Embedding | FuncVector |
BBEmbeddingsMap | BBVecMap |
InstEmbeddingsMap | InstVecMap |
Embedder provides the interface to generate embeddings (vector representations) for instructions, basic blocks, and functions.
The vector representations are generated using IR2Vec algorithms.
The Embedder class is an abstract class and it is intended to be subclassed for different IR2Vec algorithms like Symbolic and Flow-aware.
|
protected |
Definition at line 155 of file IR2Vec.cpp.
|
virtualdefault |
|
protected |
Function to compute embeddings.
It generates embeddings for all the instructions and basic blocks in the function F.
Definition at line 198 of file IR2Vec.cpp.
References BBVecMap, computeEmbeddings(), llvm::depth_first(), F, FuncVector, and llvm::GlobalValue::isDeclaration().
Referenced by computeEmbeddings(), getBBVecMap(), getBBVector(), getFunctionVector(), and getInstVecMap().
|
protectedpure virtual |
Function to compute the embedding for a given basic block.
Specific to the kind of embeddings being computed.
|
static |
Factory method to create an Embedder object.
Definition at line 160 of file IR2Vec.cpp.
References F, llvm::FlowAware, llvm::Symbolic, and Vocab.
Referenced by llvm::IR2VecPrinterPass::run().
const BBEmbeddingsMap & Embedder::getBBVecMap | ( | ) | const |
Returns a map containing basic block and the corresponding embeddings for the function F if it has been computed.
If not, it computes the embeddings for the function and returns the map.
Definition at line 177 of file IR2Vec.cpp.
References BBVecMap, computeEmbeddings(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty().
const Embedding & Embedder::getBBVector | ( | const BasicBlock & | BB | ) | const |
Returns the embedding for a given basic block in the function F if it has been computed.
If not, it computes the embedding for the basic block and returns it.
Definition at line 183 of file IR2Vec.cpp.
References BBVecMap, computeEmbeddings(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find().
Computes and returns the embedding for the current function.
Definition at line 191 of file IR2Vec.cpp.
References computeEmbeddings(), and FuncVector.
const InstEmbeddingsMap & Embedder::getInstVecMap | ( | ) | const |
Returns a map containing instructions and the corresponding embeddings for the function F if it has been computed.
If not, it computes the embeddings for the function and returns the map.
Definition at line 171 of file IR2Vec.cpp.
References computeEmbeddings(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty(), and InstVecMap.
|
mutableprotected |
Definition at line 347 of file IR2Vec.h.
Referenced by computeEmbeddings(), getBBVecMap(), and getBBVector().
Definition at line 334 of file IR2Vec.h.
Referenced by computeEmbeddings(), and create().
|
mutableprotected |
Definition at line 346 of file IR2Vec.h.
Referenced by computeEmbeddings(), and getFunctionVector().
|
mutableprotected |
Definition at line 348 of file IR2Vec.h.
Referenced by getInstVecMap().
|
protected |
|
protected |