docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
embedding_node.h
Go to the documentation of this file.
1#pragma once
2
4
6
7namespace sdfg {
8namespace math {
9namespace tensor {
10
12
34class EmbeddingNode : public TensorNode {
35private:
36 std::vector<symbolic::Expression> weight_shape_;
37 std::vector<symbolic::Expression> index_shape_;
38
39public:
41 size_t element_id,
42 const DebugInfo& debug_info,
45 const std::vector<symbolic::Expression>& weight_shape,
46 const std::vector<symbolic::Expression>& index_shape,
48 );
49
50 static auto constexpr RESULT_PTR_IDX = 0;
51 static auto constexpr W_INPUT_IDX = 1;
52 static auto constexpr INDEX_IDX = 2;
53
54 const std::vector<symbolic::Expression>& weight_shape() const;
55 const std::vector<symbolic::Expression>& index_shape() const;
56
57 void validate(const Function& function) const override;
58
59 symbolic::SymbolSet symbols() const override;
60
61 void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override;
62
63 void replace(const symbolic::ExpressionMapping& replacements) override;
64
65 bool supports_integer_types() const override;
66
69
70 std::unique_ptr<data_flow::DataFlowNode>
71 clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const override;
72
74};
75
77public:
78 nlohmann::json serialize(const data_flow::LibraryNode& library_node) override;
79
82 ) override;
83};
84
85} // namespace tensor
86} // namespace math
87} // namespace sdfg
Definition element.h:30
size_t element_id() const
const DebugInfo & debug_info() const
Definition function.h:43
Note: Even though the class references unique_ptr, it will never delete an SDFG it has a reference to...
Definition structured_sdfg_builder.h:44
Definition data_flow_graph.h:29
graph::Vertex vertex() const
Get the graph vertex for this node.
Base class for all library nodes in the dataflow graph.
Definition library_node.h:106
Definition embedding_node.h:76
nlohmann::json serialize(const data_flow::LibraryNode &library_node) override
Serialize a library node to JSON.
data_flow::LibraryNode & deserialize(const nlohmann::json &j, builder::StructuredSDFGBuilder &builder, structured_control_flow::Block &parent) override
Deserialize a library node from JSON.
bool supports_integer_types() const override
Check if this operation supports integer types.
const std::vector< symbolic::Expression > & index_shape() const
static auto constexpr W_INPUT_IDX
Definition embedding_node.h:51
static auto constexpr INDEX_IDX
Definition embedding_node.h:52
void validate(const Function &function) const override
Validate the code node's configuration.
void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
static auto constexpr RESULT_PTR_IDX
Definition embedding_node.h:50
EmbeddingNode(size_t element_id, const DebugInfo &debug_info, const graph::Vertex vertex, data_flow::DataFlowGraph &parent, const std::vector< symbolic::Expression > &weight_shape, const std::vector< symbolic::Expression > &index_shape, const data_flow::ImplementationType &impl_type=data_flow::ImplementationType_NONE)
symbolic::SymbolSet symbols() const override
Get all symbols used in this node.
data_flow::PointerAccessType pointer_access_type(int input_idx) const override
Describes what a pointer is used for.
void replace(const symbolic::ExpressionMapping &replacements) override
std::unique_ptr< data_flow::DataFlowNode > clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph &parent) const override
Clone this node for graph transformations.
passes::LibNodeExpander::ExpandOutcome expand(passes::LibNodeExpander::ExpandContext &context, structured_control_flow::Block &block) override
Expand this node into its internal operations.
const std::vector< symbolic::Expression > & weight_shape() const
TensorNode(size_t element_id, const DebugInfo &debug_info, const graph::Vertex vertex, data_flow::DataFlowGraph &parent, const data_flow::LibraryNodeCode &code, const std::vector< std::string > &outputs, const std::vector< std::string > &inputs, const data_flow::ImplementationType &impl_type)
Construct a tensor node.
Definition lib_node_expander.h:122
Base class for library node serialization.
Definition json_serializer.h:195
A control flow node representing a basic block with dataflow computations.
Definition block.h:42
SymEngine::RCP< const SymEngine::Basic > Expression
Reference-counted pointer to a symbolic expression (SymEngine Basic).
Definition symbolic.h:83
std::set< Symbol, SymEngine::RCPBasicKeyLess > SymbolSet
Ordered set of symbols.
Definition symbolic.h:95
SymEngine::map_basic_basic ExpressionMapping
Definition symbolic.h:109
Definition function_builder.h:10
StringEnum ImplementationType
Implementation type identifier for library nodes.
Definition library_node.h:75
StringEnum LibraryNodeCode
Definition library_node.h:65
ImplementationType ImplementationType_NONE
Default implementation type indicating no specific implementation.
Definition library_node.h:84
std::unique_ptr< PointerAccessMeta, PtrAccessDeleter > PointerAccessType
Definition pointer_metadata.h:32
boost::graph_traits< Graph >::vertex_descriptor Vertex
Definition graph.h:25
Definition arange_node.h:8
data_flow::LibraryNodeCode LibraryNodeType_Embedding("ml::Embedding")
Definition batched_gemm_node.h:12
Definition analysis.h:7
Definition lib_node_expander.h:12
Abstract base class for tensor library nodes.