• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daisytuner / sdfglib / 20561540736

29 Dec 2025 12:13AM UTC coverage: 40.366% (+1.4%) from 38.976%
20561540736

push

github

web-flow
Merge pull request #409 from daisytuner/lib-nodes-refactor

restructures library nodes

14298 of 45900 branches covered (31.15%)

Branch coverage included in aggregate %.

259 of 388 new or added lines in 19 files covered. (66.75%)

28 existing lines in 2 files now uncovered.

12247 of 19861 relevant lines covered (61.66%)

89.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

45.0
/src/data_flow/library_nodes/math/tensor/elementwise_ops/elu_node.cpp
1
#include "sdfg/data_flow/library_nodes/math/tensor/elementwise_ops/elu_node.h"
2

3
#include "sdfg/analysis/analysis.h"
4
#include "sdfg/builder/structured_sdfg_builder.h"
5

6
#include "sdfg/analysis/scope_analysis.h"
7

8
#include "sdfg/data_flow/library_nodes/math/cmath/cmath_node.h"
9

10
namespace sdfg {
11
namespace math {
12
namespace tensor {
13

14
EluNode::EluNode(
4✔
15
    size_t element_id,
16
    const DebugInfo& debug_info,
17
    const graph::Vertex vertex,
18
    data_flow::DataFlowGraph& parent,
19
    const std::vector<symbolic::Expression>& shape
20
)
21
    : ElementWiseUnaryNode(element_id, debug_info, vertex, parent, LibraryNodeType_Elu, shape) {
4✔
22
    this->inputs_.push_back("alpha");
4!
23
}
4✔
24

25
bool EluNode::expand_operation(
4✔
26
    builder::StructuredSDFGBuilder& builder,
27
    analysis::AnalysisManager& analysis_manager,
28
    structured_control_flow::Sequence& body,
29
    const std::string& input_name,
30
    const std::string& output_name,
31
    const types::IType& input_type,
32
    const types::IType& output_type,
33
    const data_flow::Subset& subset
34
) {
35
    // Add code
36
    auto& code_block = builder.add_block(body);
4!
37
    auto& input_node = builder.add_access(code_block, input_name);
4!
38
    auto& output_node_exp = builder.add_access(code_block, output_name);
4!
39
    auto& output_node_sub = builder.add_access(code_block, output_name);
4!
40
    auto& output_node_mul = builder.add_access(code_block, output_name);
4!
41

42
    types::Scalar desc(types::PrimitiveType::Float);
4✔
43

44
    // 1. exp(x)
45
    {
46
        auto& tasklet =
4✔
47
            builder.add_library_node<math::cmath::CMathNode>(code_block, code_block.debug_info(), "expf", 1);
4!
48
        builder.add_computational_memlet(code_block, input_node, tasklet, "_in1", subset, input_type);
4!
49
        builder.add_computational_memlet(code_block, tasklet, "_out", output_node_exp, subset, output_type);
4!
50
    }
51
    // 2. x - 1.0f
52
    {
53
        auto& one_node = builder.add_constant(code_block, "1.0f", types::Scalar(output_type.primitive_type()));
4!
54
        auto& tasklet = builder.add_tasklet(code_block, data_flow::TaskletCode::fp_sub, "_out", {"_in1", "_in2"});
4!
55
        builder.add_computational_memlet(code_block, output_node_exp, tasklet, "_in1", subset, output_type);
4!
56
        builder.add_computational_memlet(code_block, one_node, tasklet, "_in2", {}, desc);
4!
57
        builder.add_computational_memlet(code_block, tasklet, "_out", output_node_sub, subset, output_type);
4!
58
    }
59
    // 3. alpha * x
60
    {
61
        auto& tasklet = builder.add_tasklet(code_block, data_flow::TaskletCode::fp_mul, "_out", {"_in1", "_in2"});
4!
62
        builder.add_computational_memlet(code_block, output_node_sub, tasklet, "_in1", subset, output_type);
4!
63
        builder.add_computational_memlet(code_block, tasklet, "_out", output_node_mul, subset, output_type);
4!
64

65
        // Find alpha node
66
        auto& graph = this->get_parent();
4!
67
        const data_flow::Memlet* alpha_memlet = nullptr;
4✔
68
        for (auto& in_edge : graph.in_edges(*this)) {
8!
69
            if (in_edge.dst_conn() == "alpha") {
4!
70
                alpha_memlet = &in_edge;
×
71
                break;
×
72
            }
73
        }
74

75
        data_flow::AccessNode* alpha_node = nullptr;
4✔
76
        if (alpha_memlet) {
4!
NEW
77
            auto& src = dynamic_cast<const data_flow::AccessNode&>(alpha_memlet->src());
×
NEW
78
            if (auto const_node = dynamic_cast<const data_flow::ConstantNode*>(&src)) {
×
NEW
79
                alpha_node = &builder.add_constant(code_block, const_node->data(), const_node->type());
×
NEW
80
            } else {
×
NEW
81
                alpha_node = &builder.add_access(code_block, src.data());
×
82
            }
NEW
83
            builder.add_computational_memlet(
×
NEW
84
                code_block, *alpha_node, tasklet, "_in2", alpha_memlet->subset(), alpha_memlet->base_type()
×
85
            );
86
        } else {
×
87
            alpha_node = &builder.add_constant(code_block, "1.0f", desc);
4!
88
            builder.add_computational_memlet(code_block, *alpha_node, tasklet, "_in2", {}, desc);
4!
89
        }
90
    }
91

92
    return true;
93
}
4✔
94

95
std::unique_ptr<data_flow::DataFlowNode> EluNode::
96
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const {
×
NEW
97
    return std::unique_ptr<
×
NEW
98
        data_flow::DataFlowNode>(new EluNode(element_id, this->debug_info(), vertex, parent, this->shape_));
×
99
}
×
100

101
} // namespace tensor
102
} // namespace math
103
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc