docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
softmax_node.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace sdfg {
6namespace math {
7namespace tensor {
8
10
11class SoftmaxNode : public ReduceNode {
12public:
14 size_t element_id,
15 const DebugInfo& debug_info,
18 const std::vector<symbolic::Expression>& shape,
19 const std::vector<int64_t>& axes,
20 bool keepdims = false
21 );
22
23 void validate(const Function& function) const override;
24
26
31 const types::Tensor& input_type,
32 const types::Tensor& output_type,
33 const data_flow::Subset& input_subset,
34 const data_flow::Subset& output_subset
35 ) override;
36
37 std::string identity(types::PrimitiveType primitive_type) const override {
38 return "";
39 }
40
41 bool supports_integer_types() const override {
42 return false;
43 }
44
45 std::unique_ptr<data_flow::DataFlowNode>
46 clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const override;
47};
48
50
51} // namespace tensor
52} // namespace math
53} // 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.
Definition reduce_node.h:230
ReduceNode(size_t element_id, const DebugInfo &debug_info, const graph::Vertex vertex, data_flow::DataFlowGraph &parent, const data_flow::LibraryNodeCode &code, const std::vector< symbolic::Expression > &shape, const std::vector< int64_t > &axes, bool keepdims)
Construct a reduction node.
const std::vector< symbolic::Expression > & shape() const
Get the input tensor shape.
Definition reduce_node.h:123
const std::vector< int64_t > & axes() const
Get the reduction axes.
Definition reduce_node.h:131
bool keepdims() const
Check if reduced dimensions are kept.
Definition reduce_node.h:139
bool expand_reduction(passes::LibNodeExpander::AccessNodeExpand &expansion, builder::StructuredSDFGBuilder &builder, structured_control_flow::Sequence &body, const types::Tensor &input_type, const types::Tensor &output_type, const data_flow::Subset &input_subset, const data_flow::Subset &output_subset) override
Generate the actual reduction code.
void validate(const Function &function) const override
Validate the code node's configuration.
SoftmaxNode(size_t element_id, const DebugInfo &debug_info, const graph::Vertex vertex, data_flow::DataFlowGraph &parent, const std::vector< symbolic::Expression > &shape, const std::vector< int64_t > &axes, bool keepdims=false)
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.
bool supports_integer_types() const override
Check if this operation supports integer types.
Definition softmax_node.h:41
std::string identity(types::PrimitiveType primitive_type) const override
Get the identity value for this reduction.
Definition softmax_node.h:37
passes::LibNodeExpander::ExpandOutcome expand(passes::LibNodeExpander::ExpandContext &context, Block &block) override
Expand into nested maps with reduction logic.
types::PrimitiveType primitive_type(const data_flow::DataFlowGraph &graph) const
Get the primitive type of this tensor operation.
Definition lib_node_expander.h:45
Definition lib_node_expander.h:122
A control flow node representing a basic block with dataflow computations.
Definition block.h:42
A sequential container of control flow nodes.
Definition sequence.h:52
Definition tensor.h:13
Definition function_builder.h:10
symbolic::MultiExpression Subset
Type alias for a subset specification (array of symbolic expressions).
Definition memlet.h:103
StringEnum LibraryNodeCode
Definition library_node.h:65
boost::graph_traits< Graph >::vertex_descriptor Vertex
Definition graph.h:25
Definition arange_node.h:8
data_flow::LibraryNodeCode LibraryNodeType_Softmax("ml::Softmax")
ReduceNodeSerializer< SoftmaxNode > SoftmaxNodeSerializer
Definition softmax_node.h:49
Definition batched_gemm_node.h:12
PrimitiveType
Enumeration of all primitive data types supported by sdfglib.
Definition type.h:35
Definition analysis.h:7
Tensor reduction operation nodes.
Definition lib_node_expander.h:12