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 Embedding | getInstVector (const Instruction &I) const |
Computes and returns the embedding for a given instruction in the function F. | |
LLVM_ABI Embedding | getBBVector (const BasicBlock &BB) const |
Computes and returns the embedding for a given basic block in the function F. | |
LLVM_ABI Embedding | getFunctionVector () const |
Computes and returns the embedding for the current function. | |
virtual void | invalidateEmbeddings () |
Invalidate embeddings if cached. |
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) |
Embedding | computeEmbeddings () const |
Function to compute embeddings. | |
Embedding | computeEmbeddings (const BasicBlock &BB) const |
Function to compute the embedding for a given basic block. | |
virtual Embedding | computeEmbeddings (const Instruction &I) const =0 |
Function to compute the embedding for a given instruction. |
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 |
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.
|
inlineprotected |
Definition at line 536 of file IR2Vec.h.
References ArgWeight, Dimension, F, LLVM_ABI, OpcWeight, TypeWeight, and Vocab.
Referenced by llvm::ir2vec::FlowAwareEmbedder::FlowAwareEmbedder(), and llvm::ir2vec::SymbolicEmbedder::SymbolicEmbedder().
|
virtualdefault |
|
protected |
Function to compute embeddings.
Definition at line 167 of file IR2Vec.cpp.
References computeEmbeddings(), llvm::depth_first(), Dimension, and F.
Referenced by computeEmbeddings(), computeEmbeddings(), getBBVector(), getFunctionVector(), and getInstVector().
|
protected |
Function to compute the embedding for a given basic block.
Definition at line 179 of file IR2Vec.cpp.
References computeEmbeddings(), Dimension, I, and llvm::BasicBlock::instructionsWithoutDebug().
|
protectedpure virtual |
|
static |
Factory method to create an Embedder object.
Definition at line 156 of file IR2Vec.cpp.
References F, llvm::FlowAware, llvm::Symbolic, and Vocab.
Referenced by llvm::IR2VecPrinterPass::run().
|
inline |
Computes and returns the embedding for a given basic block in the function F.
Definition at line 566 of file IR2Vec.h.
References computeEmbeddings(), and LLVM_ABI.
Computes and returns the embedding for the current function.
Definition at line 571 of file IR2Vec.h.
References computeEmbeddings(), and LLVM_ABI.
|
inline |
Computes and returns the embedding for a given instruction in the function F.
Definition at line 560 of file IR2Vec.h.
References computeEmbeddings(), I, and LLVM_ABI.
|
inlinevirtual |
Invalidate embeddings if cached.
The embeddings may not be relevant anymore when the IR changes due to transformations. In such cases, the cached embeddings should be invalidated to ensure correctness/recomputation. This is a no-op for SymbolicEmbedder but removes all the cached entries in FlowAwareEmbedder.
Reimplemented in llvm::ir2vec::FlowAwareEmbedder.
|
protected |
Definition at line 534 of file IR2Vec.h.
Referenced by Embedder().
Dimension of the vector representation; captured from the input vocabulary.
Definition at line 530 of file IR2Vec.h.
Referenced by computeEmbeddings(), computeEmbeddings(), and Embedder().
Definition at line 526 of file IR2Vec.h.
Referenced by computeEmbeddings(), create(), Embedder(), llvm::ir2vec::FlowAwareEmbedder::FlowAwareEmbedder(), llvm::ir2vec::SymbolicEmbedder::SymbolicEmbedder(), and ~Embedder().
|
protected |
Weights for different entities (like opcode, arguments, types) in the IR instructions to generate the vector representation.
Definition at line 534 of file IR2Vec.h.
Referenced by Embedder().
|
protected |
Definition at line 534 of file IR2Vec.h.
Referenced by Embedder().
|
protected |
Definition at line 527 of file IR2Vec.h.
Referenced by create(), Embedder(), llvm::ir2vec::FlowAwareEmbedder::FlowAwareEmbedder(), llvm::ir2vec::SymbolicEmbedder::SymbolicEmbedder(), and ~Embedder().