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

daisytuner / sdfglib / 17523565363

05 Sep 2025 11:40AM UTC coverage: 59.145% (+0.09%) from 59.057%
17523565363

push

github

web-flow
Schedule type extension (#221)

* Initial Draft

* Simplify schedule type class for serialization

* string ref

* fix and = operator

60 of 72 new or added lines in 19 files covered. (83.33%)

4 existing lines in 2 files now uncovered.

9274 of 15680 relevant lines covered (59.15%)

115.92 hits per line

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

0.0
/src/data_flow/library_nodes/math/ml/dropout.cpp
1
#include "sdfg/data_flow/library_nodes/math/ml/dropout.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
namespace sdfg {
9
namespace math {
10
namespace ml {
11

12
DropoutNode::DropoutNode(
×
13
    size_t element_id, const DebugInfo& debug_info, const graph::Vertex vertex, data_flow::DataFlowGraph& parent
14
)
15
    : MathNode(
×
16
          element_id,
×
17
          debug_info,
×
18
          vertex,
×
19
          parent,
×
20
          LibraryNodeType_Dropout,
21
          {"output", "mask"},
×
22
          {"data"},
×
23
          data_flow::ImplementationType_NONE
24
      ) {}
×
25

26
void DropoutNode::validate(const Function& function) const {
×
27
    // TODO: Implement
28
}
×
29

30
bool DropoutNode::expand(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager) {
×
31
    auto& dataflow = this->get_parent();
×
32
    auto& block = static_cast<structured_control_flow::Block&>(*dataflow.get_parent());
×
33
    if (dataflow.in_degree(*this) != 1 || dataflow.out_degree(*this) != 2) {
×
34
        return false;
×
35
    }
36
    auto& scope_analysis = analysis_manager.get<analysis::ScopeAnalysis>();
×
37
    auto& parent = static_cast<structured_control_flow::Sequence&>(*scope_analysis.parent_scope(&block));
×
38
    int index = parent.index(block);
×
39
    auto& transition = parent.at(index).second;
×
40

41
    auto& input = this->inputs_.at(0);
×
42
    auto& output_data = this->outputs_.at(0);
×
43
    auto& output_mask = this->outputs_.at(1);
×
44

45
    auto& iedge = *dataflow.in_edges(*this).begin();
×
46
    auto oedge_output = &(*dataflow.out_edges(*this).begin());
×
47
    auto oedge_mask = &(*(++dataflow.out_edges(*this).begin()));
×
48
    if (oedge_output->src_conn() != "output") {
×
49
        std::swap(oedge_output, oedge_mask);
×
50
    }
×
51

52
    // Checks if legal
53
    auto& input_node = static_cast<data_flow::AccessNode&>(iedge.src());
×
54
    auto& output_node_output = static_cast<data_flow::AccessNode&>(oedge_output->dst());
×
55
    auto& output_node_mask = static_cast<data_flow::AccessNode&>(oedge_mask->dst());
×
56
    if (dataflow.in_degree(input_node) != 0 || dataflow.out_degree(output_node_output) != 0 ||
×
57
        dataflow.out_degree(output_node_mask) != 0) {
×
58
        return false;
×
59
    }
60

61
    // Add new graph after the current block
62
    auto& new_sequence = builder.add_sequence_before(parent, block, transition.assignments(), block.debug_info());
×
63

64
    // Add maps
65
    auto& begin_subsets_out = oedge_output->begin_subset();
×
66
    auto& end_subsets_out = oedge_output->end_subset();
×
67
    data_flow::Subset new_subset;
×
68
    structured_control_flow::Sequence* last_scope = &new_sequence;
×
69
    structured_control_flow::Map* last_map = nullptr;
×
70
    for (size_t i = 0; i < begin_subsets_out.size(); i++) {
×
71
        auto& dim_begin = begin_subsets_out[i];
×
72
        auto& dim_end = end_subsets_out[i];
×
73

74
        std::string indvar_str = builder.find_new_name("_i");
×
75
        builder.add_container(indvar_str, types::Scalar(types::PrimitiveType::UInt64));
×
76

77
        auto indvar = symbolic::symbol(indvar_str);
×
78
        auto init = dim_begin;
×
79
        auto update = symbolic::add(indvar, symbolic::one());
×
80
        auto condition = symbolic::Lt(indvar, symbolic::add(dim_end, symbolic::one()));
×
81
        last_map = &builder.add_map(
×
82
            *last_scope,
×
83
            indvar,
84
            condition,
85
            init,
86
            update,
NEW
87
            structured_control_flow::ScheduleType_Sequential::create(),
×
88
            {},
×
89
            block.debug_info()
×
90
        );
91
        last_scope = &last_map->root();
×
92

93
        new_subset.push_back(indvar);
×
94
    }
×
95

96
    // output = data, mask = 1
97
    {
98
        auto& code_block = builder.add_block(*last_scope, {}, block.debug_info());
×
99
        auto& input_node_new = builder.add_access(code_block, input_node.data(), input_node.debug_info());
×
100
        auto& output_node_output_new =
×
101
            builder.add_access(code_block, output_node_output.data(), output_node_output.debug_info());
×
102
        auto& output_node_mask_new =
×
103
            builder.add_access(code_block, output_node_mask.data(), output_node_mask.debug_info());
×
104

105
        auto& tasklet_output = builder.add_tasklet(code_block, data_flow::assign, "_out", {"_in"}, block.debug_info());
×
106
        builder.add_computational_memlet(
×
107
            code_block, input_node_new, tasklet_output, "_in", new_subset, iedge.base_type(), block.debug_info()
×
108
        );
109
        builder.add_computational_memlet(
×
110
            code_block,
×
111
            tasklet_output,
×
112
            "_out",
×
113
            output_node_output_new,
×
114
            new_subset,
115
            oedge_output->base_type(),
×
116
            block.debug_info()
×
117
        );
118

119
        auto& tasklet_mask = builder.add_tasklet(code_block, data_flow::assign, "_out", {"1"}, block.debug_info());
×
120
        builder.add_computational_memlet(
×
121
            code_block,
×
122
            tasklet_mask,
×
123
            "_out",
×
124
            output_node_mask_new,
×
125
            new_subset,
126
            oedge_mask->base_type(),
×
127
            block.debug_info()
×
128
        );
129
    }
130

131
    // Clean up block
132
    builder.remove_memlet(block, iedge);
×
133
    builder.remove_memlet(block, *oedge_output);
×
134
    builder.remove_memlet(block, *oedge_mask);
×
135
    builder.remove_node(block, input_node);
×
136
    builder.remove_node(block, output_node_output);
×
137
    builder.remove_node(block, output_node_mask);
×
138
    builder.remove_node(block, *this);
×
139
    builder.remove_child(parent, index + 1);
×
140

141
    return true;
×
142
}
×
143

144
std::unique_ptr<data_flow::DataFlowNode> DropoutNode::
145
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const {
×
146
    return std::unique_ptr<data_flow::DataFlowNode>(new DropoutNode(element_id, this->debug_info(), vertex, parent));
×
147
}
×
148

149
} // namespace ml
150
} // namespace math
151
} // 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