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

daisytuner / sdfglib / 20561412006

29 Dec 2025 12:03AM UTC coverage: 40.369% (+1.4%) from 38.976%
20561412006

Pull #409

github

web-flow
Merge d082d4d04 into eec4d6f74
Pull Request #409: restructures library nodes

14299 of 45900 branches covered (31.15%)

Branch coverage included in aggregate %.

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

27 existing lines in 1 file now uncovered.

12248 of 19861 relevant lines covered (61.67%)

89.05 hits per line

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

0.0
/include/sdfg/data_flow/library_nodes/math/tensor/reduce_node.h
1
#pragma once
2

3
#include "sdfg/data_flow/library_nodes/math/math_node.h"
4

5
#include "sdfg/codegen/dispatchers/block_dispatcher.h"
6
#include "sdfg/serializer/json_serializer.h"
7

8
namespace sdfg {
9
namespace math {
10
namespace tensor {
11

12
class ReduceNode : public math::MathNode {
13
protected:
14
    std::vector<symbolic::Expression> shape_;
15
    std::vector<int64_t> axes_;
16
    bool keepdims_;
17

18
public:
19
    ReduceNode(
20
        size_t element_id,
21
        const DebugInfo& debug_info,
22
        const graph::Vertex vertex,
23
        data_flow::DataFlowGraph& parent,
24
        const data_flow::LibraryNodeCode& code,
25
        const std::vector<symbolic::Expression>& shape,
26
        const std::vector<int64_t>& axes,
27
        bool keepdims
28
    );
29

NEW
30
    const std::vector<symbolic::Expression>& shape() const { return shape_; }
×
31

NEW
32
    const std::vector<int64_t>& axes() const { return axes_; }
×
33

NEW
34
    bool keepdims() const { return keepdims_; }
×
35

36
    symbolic::SymbolSet symbols() const override;
37

38
    void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override;
39

40
    void validate(const Function& function) const override;
41

42
    bool expand(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager) override;
43

44
    virtual bool expand_reduction(
45
        builder::StructuredSDFGBuilder& builder,
46
        analysis::AnalysisManager& analysis_manager,
47
        structured_control_flow::Sequence& body,
48
        const std::string& input_name,
49
        const std::string& output_name,
50
        const types::IType& input_type,
51
        const types::IType& output_type,
52
        const data_flow::Subset& input_subset,
53
        const data_flow::Subset& output_subset
54
    ) = 0;
55

56
    virtual std::string identity() const = 0;
57
};
58

59
template<typename T>
60
class ReduceNodeSerializer : public serializer::LibraryNodeSerializer {
61
public:
NEW
62
    nlohmann::json serialize(const data_flow::LibraryNode& library_node) override {
×
NEW
63
        const ReduceNode& reduce_node = static_cast<const ReduceNode&>(library_node);
×
NEW
64
        nlohmann::json j;
×
65

NEW
66
        j["code"] = reduce_node.code().value();
×
67

NEW
68
        serializer::JSONSerializer serializer;
×
NEW
69
        j["shape"] = nlohmann::json::array();
×
NEW
70
        for (auto& dim : reduce_node.shape()) {
×
NEW
71
            j["shape"].push_back(serializer.expression(dim));
×
72
        }
73

NEW
74
        j["axes"] = reduce_node.axes();
×
NEW
75
        j["keepdims"] = reduce_node.keepdims();
×
76

NEW
77
        return j;
×
NEW
78
    }
×
79

NEW
80
    data_flow::LibraryNode& deserialize(
×
81
        const nlohmann::json& j, builder::StructuredSDFGBuilder& builder, structured_control_flow::Block& parent
82
    ) override {
83
        // Assertions for required fields
NEW
84
        assert(j.contains("element_id"));
×
NEW
85
        assert(j.contains("code"));
×
NEW
86
        assert(j.contains("debug_info"));
×
NEW
87
        assert(j.contains("shape"));
×
NEW
88
        assert(j.contains("axes"));
×
NEW
89
        assert(j.contains("keepdims"));
×
90

NEW
91
        auto code = j["code"].get<std::string>();
×
92

NEW
93
        std::vector<symbolic::Expression> shape;
×
NEW
94
        for (const auto& dim : j["shape"]) {
×
NEW
95
            shape.push_back(symbolic::parse(dim.get<std::string>()));
×
96
        }
97

NEW
98
        std::vector<int64_t> axes = j["axes"].get<std::vector<int64_t>>();
×
NEW
99
        bool keepdims = j["keepdims"].get<bool>();
×
100

101
        // Extract debug info using JSONSerializer
NEW
102
        sdfg::serializer::JSONSerializer serializer;
×
NEW
103
        DebugInfo debug_info = serializer.json_to_debug_info(j["debug_info"]);
×
104

NEW
105
        return static_cast<ReduceNode&>(builder.add_library_node<T>(parent, debug_info, shape, axes, keepdims));
×
NEW
106
    }
×
107
};
108

109
} // namespace tensor
110
} // namespace math
111
} // 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

© 2026 Coveralls, Inc