docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
sdfg::math::tensor::SoftmaxNode Class Reference

#include <sdfg/data_flow/library_nodes/math/tensor/reduce_ops/softmax_node.h>

Inheritance diagram for sdfg::math::tensor::SoftmaxNode:
[legend]

Public Member Functions

 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)
void validate (const Function &function) const override
 Validate the code node's configuration.
passes::LibNodeExpander::ExpandOutcome expand (passes::LibNodeExpander::ExpandContext &context, Block &block) override
 Expand into nested maps with reduction logic.
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.
std::string identity (types::PrimitiveType primitive_type) const override
 Get the identity value for this reduction.
bool supports_integer_types () const override
 Check if this operation supports integer types.
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.
Public Member Functions inherited from sdfg::math::tensor::ReduceNode
 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.
const std::vector< int64_t > & axes () const
 Get the reduction axes.
bool keepdims () const
 Check if reduced dimensions are kept.
symbolic::SymbolSet symbols () const override
 Get all symbols used in this node.
void replace (const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
void replace (const symbolic::ExpressionMapping &replacements) override
virtual std::optional< structured_control_flow::ReductionOperation > reduction_operation () const
 Get the ReductionOperation for this reduction.
data_flow::PointerAccessType pointer_access_type (int input_idx) const override
 Describes what a pointer is used for.
std::string toStr () const override
 Convert node to string representation.
Public Member Functions inherited from sdfg::math::tensor::TensorNode
 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.
virtual void verify_data_types (const data_flow::DataFlowGraph &graph) const
 Called as part of validate.
void validate (const Function &function) const override
 Validate tensor node constraints.
types::PrimitiveType primitive_type (const data_flow::DataFlowGraph &graph) const
 Get the primitive type of this tensor operation.
Public Member Functions inherited from sdfg::math::MathNode
 MathNode (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 &implementation_type, bool side_effects=false)
 Construct a mathematical library node.
Public Member Functions inherited from sdfg::data_flow::LibraryNode
 LibraryNode (const LibraryNode &data_node)=delete
LibraryNode & operator= (const LibraryNode &)=delete
virtual ~LibraryNode ()=default
ElementType type_id () const override
 Returns the type of the element.
const LibraryNodeCode & code () const
 Get the operation code.
const ImplementationType & implementation_type () const
 Get the implementation type (const).
ImplementationType & implementation_type ()
 Get the implementation type (mutable).
void set_implementation_type (const ImplementationType &impl_type)
bool side_effect () const override
 Check if this node has side effects.
virtual symbolic::Expression flop () const
 Calculate floating point operations for this node.
PointerAccessType pointer_access_type (const Memlet &edge) const
virtual bool relocalize_operand (int input_idx, const math::tensor::TensorLayout &packed)
 Repoint the operand at input_idx to a locally staged buffer.
virtual bool can_relocalize_operand (int input_idx, const math::tensor::TensorLayout &packed) const
 Side-effect-free predicate mirroring relocalize_operand: whether the operand at input_idx can be repointed at the buffer view packed.
virtual std::optional< SubgroupAccess > operand_access (int input_idx, unsigned subgroup_size) const
 The elements one subgroup of subgroup_size lanes reads from the operand at input_idx, if the node declares them.
EdgeRemoveOption can_remove_out_edge (const data_flow::DataFlowGraph &graph, const Memlet *memlet) const override
 Is the edge in question removable, or will this make the node its an output on invalid?
EdgeRemoveOption can_remove_in_edge (const data_flow::DataFlowGraph &graph, const Memlet *memlet) const override
bool pointer_use_creates_side_effects (const DataFlowGraph &dataflow, const Function &func)
Public Member Functions inherited from sdfg::data_flow::CodeNode
 CodeNode (const CodeNode &data_node)=delete
CodeNode & operator= (const CodeNode &)=delete
const std::vector< std::string > & outputs () const
 Get output connector names (const).
const std::vector< std::string > & inputs () const
 Get input connector names (const).
std::vector< std::string > & outputs ()
 Get output connector names (mutable).
std::vector< std::string > & inputs ()
 Get input connector names (mutable).
const std::string & output (size_t index) const
 Get output connector name by index.
const std::string & input (size_t index) const
 Get input connector name by index.
bool has_constant_input (size_t index) const
 Check if an input is connected to a constant node.
Public Member Functions inherited from sdfg::data_flow::DataFlowNode
 DataFlowNode (const DataFlowNode &data_node)=delete
DataFlowNode & operator= (const DataFlowNode &)=delete
graph::Vertex vertex () const
 Get the graph vertex for this node.
const DataFlowGraph & get_parent () const
 Get the parent dataflow graph (const).
DataFlowGraph & get_parent ()
 Get the parent dataflow graph (mutable).
virtual bool update_edge_removed (const std::string &out_conn)
Public Member Functions inherited from sdfg::Element
 Element (size_t element_id, const DebugInfo &debug_info)
virtual ~Element ()=default
size_t element_id () const
const DebugInfo & debug_info () const
void set_debug_info (const DebugInfo &debug_info)
void add_metadata (const std::string &key, const std::string &value)
void remove_metadata (const std::string &key)
const std::string & metadata (const std::string &key) const
const std::string * metadata_if_exists (const std::string &key) const
const std::unordered_map< std::string, std::string > & metadata () const
std::string_view element_type () const
 Returns the type of the element as a human-readable string.

Additional Inherited Members

Static Public Member Functions inherited from sdfg::data_flow::LibraryNode
static bool classof (const Element &element)
Static Public Member Functions inherited from sdfg::data_flow::CodeNode
static bool classof (const Element &element)
 LLVM-style RTTI predicate: true if element is a CodeNode.
Static Public Member Functions inherited from sdfg::data_flow::DataFlowNode
static bool classof (const Element &element)
 LLVM-style RTTI predicate: true if element is a DataFlowNode.
Static Public Attributes inherited from sdfg::math::tensor::ReduceNode
static auto constexpr RESULT_PTR_IDX = 0
static auto constexpr X_INPUT_IDX = 1
Static Public Attributes inherited from sdfg::data_flow::CodeNode
static constexpr ElementType TypeGroup = ElementType::Tasklet | ElementType::LibraryNode
 Bitmask of all concrete ElementTypes that are CodeNodes.
Static Public Attributes inherited from sdfg::data_flow::DataFlowNode
static constexpr ElementType TypeGroup
 Bitmask of all concrete ElementTypes that are DataFlowNodes.
Protected Member Functions inherited from sdfg::math::tensor::ReduceNode
virtual passes::LibNodeExpander::ExpandOutcome expand_inner (passes::LibNodeExpander::AccessNodeExpand &expansion, structured_control_flow::Block &block, const data_flow::Memlet *iedge_input, const data_flow::Memlet *iedge_result, const std::vector< symbolic::Expression > &output_shape, const std::vector< int64_t > &sorted_axes)
Protected Member Functions inherited from sdfg::math::tensor::TensorNode
void validate_shape_matches (const std::vector< symbolic::Expression > &required_shape, const TensorLayout &layout, const std::string &name) const
Protected Member Functions inherited from sdfg::data_flow::LibraryNode
 LibraryNode (size_t element_id, const DebugInfo &debug_info, const graph::Vertex vertex, DataFlowGraph &parent, const LibraryNodeCode &code, const std::vector< std::string > &outputs, const std::vector< std::string > &inputs, const bool side_effect, const ImplementationType &implementation_type)
 Protected constructor for library nodes.
Protected Member Functions inherited from sdfg::data_flow::CodeNode
 CodeNode (size_t element_id, const DebugInfo &debug_info, const graph::Vertex vertex, DataFlowGraph &parent, const std::vector< std::string > &outputs, const std::vector< std::string > &inputs)
 Protected constructor for code nodes.
Protected Member Functions inherited from sdfg::data_flow::DataFlowNode
 DataFlowNode (size_t element_id, const DebugInfo &debug_info, const graph::Vertex vertex, DataFlowGraph &parent)
 Protected constructor for dataflow nodes.
Static Protected Member Functions inherited from sdfg::math::tensor::TensorNode
static data_flow::TaskletCode get_integer_minmax_tasklet (types::PrimitiveType prim_type, bool is_max)
 Get the appropriate tasklet code for min/max operations on integers.
Protected Attributes inherited from sdfg::math::tensor::ReduceNode
std::vector< symbolic::Expression > shape_
 Input tensor shape.
std::vector< int64_t > axes_
 Axes to reduce over.
bool keepdims_
 Whether to keep reduced dimensions with size 1.
Protected Attributes inherited from sdfg::data_flow::LibraryNode
LibraryNodeCode code_
 Operation identifier (e.g., "GEMM", "Add").
bool side_effect_
 Whether this node has side effects.
ImplementationType implementation_type_
 How to implement this node.
Protected Attributes inherited from sdfg::data_flow::CodeNode
std::vector< std::string > outputs_
 Names of output connectors.
std::vector< std::string > inputs_
 Names of input connectors.
Protected Attributes inherited from sdfg::Element
size_t element_id_
DebugInfo debug_info_
std::unordered_map< std::string, std::string > metadata_

Constructor & Destructor Documentation

◆ SoftmaxNode()

sdfg::math::tensor::SoftmaxNode::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 )

Member Function Documentation

◆ clone()

std::unique_ptr< data_flow::DataFlowNode > sdfg::math::tensor::SoftmaxNode::clone ( size_t element_id,
const graph::Vertex vertex,
data_flow::DataFlowGraph & parent ) const
overridevirtual

Clone this node for graph transformations.

Parameters
element_idNew element identifier for the clone
vertexNew graph vertex for the clone
parentParent graph for the clone
Returns
Unique pointer to the cloned node

Pure virtual function that must be implemented by derived classes to support graph transformations and optimizations.

Implements sdfg::data_flow::DataFlowNode.

◆ expand()

passes::LibNodeExpander::ExpandOutcome sdfg::math::tensor::SoftmaxNode::expand ( passes::LibNodeExpander::ExpandContext & context,
Block & block )
overridevirtual

Expand into nested maps with reduction logic.

Creates maps over non-reduced dimensions and reduction loops over reduced dimensions with appropriate initialization and accumulation.

Parameters
contextway to request isolation of node or add new blocks, loops etc.
blockthe block in which the node is contained
Returns
outcome of expand, created by context

Reimplemented from sdfg::math::tensor::ReduceNode.

◆ expand_reduction()

bool sdfg::math::tensor::SoftmaxNode::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 )
overridevirtual

Generate the actual reduction code.

Subclasses implement this to generate the specific reduction (sum, max, etc.)

Parameters
builderSDFG builder
analysis_managerAnalysis manager
bodySequence to add the reduction to
input_nameInput data name
output_nameOutput data name
input_typeInput data type
output_typeOutput data type
input_subsetInput data subset
output_subsetOutput data subset
Returns
True if reduction generation succeeded

Implements sdfg::math::tensor::ReduceNode.

◆ identity()

std::string sdfg::math::tensor::SoftmaxNode::identity ( types::PrimitiveType primitive_type) const
inlineoverridevirtual

Get the identity value for this reduction.

The identity value is used to initialize the accumulator. Examples:

  • Sum: "0"
  • Product: "1"
  • Max: "-inf" or minimum value
  • Min: "inf" or maximum value
Parameters
primitive_typeThe primitive type of the reduction element
Returns
Identity value as string expression

Implements sdfg::math::tensor::ReduceNode.

◆ supports_integer_types()

bool sdfg::math::tensor::SoftmaxNode::supports_integer_types ( ) const
inlineoverridevirtual

Check if this operation supports integer types.

Operations like add, sub, mul, div, min, max support both floating-point and integer types. Operations like exp, log, tanh, sigmoid only support floating-point types.

Returns
true if integer types are supported, false otherwise

Implements sdfg::math::tensor::TensorNode.

◆ validate()

void sdfg::math::tensor::SoftmaxNode::validate ( const Function & function) const
overridevirtual

Validate the code node's configuration.

Parameters
functionFunction context for validation

Ensures that:

  • No two access nodes connect to the same data for inputs/outputs

Reimplemented from sdfg::math::tensor::ReduceNode.


The documentation for this class was generated from the following file:
  • sdfg/include/sdfg/data_flow/library_nodes/math/tensor/reduce_ops/softmax_node.h