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

daisytuner / sdfglib / 20896124135

11 Jan 2026 01:43PM UTC coverage: 62.33% (-0.07%) from 62.402%
20896124135

push

github

web-flow
Merge pull request #423 from daisytuner/copilot/extend-tensor-nodes-conv

Add ConvNode compatible with ONNX Conv operator with n-dimensional expansion and custom validation

329 of 554 new or added lines in 21 files covered. (59.39%)

2 existing lines in 2 files now uncovered.

15413 of 24728 relevant lines covered (62.33%)

88.61 hits per line

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

9.3
/src/data_flow/library_nodes/call_node.cpp
1
#include "sdfg/data_flow/library_nodes/call_node.h"
2

3
namespace sdfg {
4
namespace data_flow {
5

6
CallNode::CallNode(
7
    size_t element_id,
8
    const DebugInfo& debug_info,
9
    const graph::Vertex vertex,
10
    data_flow::DataFlowGraph& parent,
11
    const std::string& callee_name,
12
    const std::vector<std::string>& outputs,
13
    const std::vector<std::string>& inputs
14
)
15
    : LibraryNode(
2✔
16
          element_id,
2✔
17
          debug_info,
2✔
18
          vertex,
2✔
19
          parent,
2✔
20
          LibraryNodeType_Call,
2✔
21
          outputs,
2✔
22
          inputs,
2✔
23
          true,
2✔
24
          data_flow::ImplementationType_NONE
2✔
25
      ),
2✔
26
      callee_name_(callee_name) {}
2✔
27

28
const std::string& CallNode::callee_name() const { return this->callee_name_; }
×
29

30
bool CallNode::is_void(const Function& sdfg) const { return outputs_.empty() || outputs_.at(0) != "_ret"; }
×
31

32
bool CallNode::is_indirect_call(const Function& sdfg) const {
×
33
    auto& type = sdfg.type(this->callee_name_);
×
34
    return dynamic_cast<const types::Pointer*>(&type) != nullptr;
×
35
}
×
36

37
void CallNode::validate(const Function& function) const {
×
NEW
38
    LibraryNode::validate(function);
×
39

40
    if (!function.exists(this->callee_name_)) {
×
41
        throw InvalidSDFGException("CallNode: Function '" + this->callee_name_ + "' does not exist.");
×
42
    }
×
43
    auto& type = function.type(this->callee_name_);
×
44
    if (!dynamic_cast<const types::Function*>(&type) && !dynamic_cast<const types::Pointer*>(&type)) {
×
45
        throw InvalidSDFGException("CallNode: '" + this->callee_name_ + "' is not a function or pointer.");
×
46
    }
×
47

48
    if (auto func_type = dynamic_cast<const types::Function*>(&type)) {
×
49
        if (!function.is_external(this->callee_name_)) {
×
50
            throw InvalidSDFGException("CallNode: Function '" + this->callee_name_ + "' must be declared.");
×
51
        }
×
52
        if (!func_type->is_var_arg() && inputs_.size() != func_type->num_params()) {
×
53
            throw InvalidSDFGException(
×
54
                "CallNode: Number of inputs does not match number of function parameters. Expected " +
×
55
                std::to_string(func_type->num_params()) + ", got " + std::to_string(inputs_.size())
×
56
            );
×
57
        }
×
58
        if (!this->is_void(function) && outputs_.size() < 1) {
×
59
            throw InvalidSDFGException(
×
60
                "CallNode: Non-void function must have at least one output to store the return value."
×
61
            );
×
62
        }
×
63
    }
×
64
}
×
65

66
symbolic::SymbolSet CallNode::symbols() const { return {symbolic::symbol(this->callee_name_)}; }
×
67

68
std::unique_ptr<data_flow::DataFlowNode> CallNode::
69
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const {
×
70
    return std::make_unique<CallNode>(element_id, debug_info_, vertex, parent, callee_name_, outputs_, inputs_);
×
71
}
×
72

73
void CallNode::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {}
×
74

75
nlohmann::json CallNodeSerializer::serialize(const data_flow::LibraryNode& library_node) {
×
76
    const CallNode& node = static_cast<const CallNode&>(library_node);
×
77

78
    nlohmann::json j;
×
79
    j["code"] = node.code().value();
×
80
    j["callee_name"] = node.callee_name();
×
81
    j["outputs"] = node.outputs();
×
82
    j["inputs"] = node.inputs();
×
83

84
    return j;
×
85
}
×
86

87
data_flow::LibraryNode& CallNodeSerializer::deserialize(
88
    const nlohmann::json& j, builder::StructuredSDFGBuilder& builder, structured_control_flow::Block& parent
89
) {
×
90
    assert(j.contains("code"));
×
91
    assert(j.contains("callee_name"));
×
92
    assert(j.contains("outputs"));
×
93
    assert(j.contains("inputs"));
×
94
    assert(j.contains("debug_info"));
×
95

96
    auto code = j["code"].get<std::string>();
×
97
    if (code != LibraryNodeType_Call.value()) {
×
98
        throw InvalidSDFGException("Invalid library node code");
×
99
    }
×
100

101
    sdfg::serializer::JSONSerializer serializer;
×
102
    DebugInfo debug_info = serializer.json_to_debug_info(j["debug_info"]);
×
103

104
    std::string callee_name = j["callee_name"].get<std::string>();
×
105
    auto outputs = j["outputs"].get<std::vector<std::string>>();
×
106
    auto inputs = j["inputs"].get<std::vector<std::string>>();
×
107

108
    return builder.add_library_node<CallNode>(parent, debug_info, callee_name, outputs, inputs);
×
109
}
×
110

111
CallNodeDispatcher::CallNodeDispatcher(
112
    codegen::LanguageExtension& language_extension,
113
    const Function& function,
114
    const data_flow::DataFlowGraph& data_flow_graph,
115
    const CallNode& node
116
)
117
    : codegen::LibraryNodeDispatcher(language_extension, function, data_flow_graph, node) {}
×
118

119
void CallNodeDispatcher::dispatch_code(
120
    codegen::PrettyPrinter& stream,
121
    codegen::PrettyPrinter& globals_stream,
122
    codegen::CodeSnippetFactory& library_snippet_factory
123
) {
×
124
    auto& node = static_cast<const CallNode&>(node_);
×
125

126
    if (!node.is_void(function_)) {
×
127
        stream << node.outputs().at(0) << " = ";
×
128
    }
×
129
    if (node.is_indirect_call(function_)) {
×
130
        auto& graph = node.get_parent();
×
131

132
        // Collect return memlet
133
        const data_flow::Memlet* ret_memlet = nullptr;
×
134
        for (auto& oedge : graph.out_edges(node)) {
×
135
            if (oedge.src_conn() == "_ret") {
×
136
                ret_memlet = &oedge;
×
137
                break;
×
138
            }
×
139
        }
×
140

141
        // Collect input memlets
142
        std::unordered_map<std::string, const data_flow::Memlet*> input_memlets;
×
143
        for (auto& iedge : graph.in_edges(node)) {
×
144
            input_memlets[iedge.dst_conn()] = &iedge;
×
145
        }
×
146

147
        // Cast callee to function pointer type
148
        std::string func_ptr_type;
×
149

150
        // Return type
151
        if (ret_memlet) {
×
152
            auto& ret_type = ret_memlet->result_type(function_);
×
153
            func_ptr_type = language_extension_.declaration("", ret_type) + " (*)";
×
154
        } else {
×
155
            func_ptr_type = "void (*)";
×
156
        }
×
157

158
        // Parameters
159
        func_ptr_type += "(";
×
160
        for (size_t i = 0; i < node.inputs().size(); i++) {
×
161
            auto memlet_in = input_memlets.find(node.inputs().at(i));
×
162
            assert(memlet_in != input_memlets.end());
×
163
            auto& in_type = memlet_in->second->result_type(function_);
×
164
            func_ptr_type += language_extension_.declaration("", in_type);
×
165
            if (i < node.inputs().size() - 1) {
×
166
                func_ptr_type += ", ";
×
167
            }
×
168
        }
×
169
        func_ptr_type += ")";
×
170

171
        if (this->language_extension_.language() == "C") {
×
172
            stream << "((" << func_ptr_type << ") " << node.callee_name() << ")" << "(";
×
173
        } else if (this->language_extension_.language() == "C++") {
×
174
            stream << "reinterpret_cast<" << func_ptr_type << ">(" << node.callee_name() << ")" << "(";
×
175
        }
×
176
    } else {
×
177
        stream << this->language_extension_.external_prefix() << node.callee_name() << "(";
×
178
    }
×
179
    for (size_t i = 0; i < node.inputs().size(); ++i) {
×
180
        stream << node.inputs().at(i);
×
181
        if (i < node.inputs().size() - 1) {
×
182
            stream << ", ";
×
183
        }
×
184
    }
×
185
    stream << ")" << ";";
×
186
    stream << std::endl;
×
187
}
×
188

189
} // namespace data_flow
190
} // 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