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

daisytuner / docc / 26812260585

02 Jun 2026 08:49AM UTC coverage: 60.823% (-0.05%) from 60.869%
26812260585

Pull #725

github

web-flow
Merge eceff48b9 into cd25c9278
Pull Request #725: Tensor node backport

599 of 1255 new or added lines in 51 files covered. (47.73%)

541 existing lines in 46 files now uncovered.

35094 of 57699 relevant lines covered (60.82%)

11078.43 hits per line

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

55.42
/sdfg/src/data_flow/library_nodes/math/tensor/tensor_node.cpp
1
#include "sdfg/data_flow/library_nodes/math/tensor/tensor_node.h"
2

3
#include "daisy_rtl/primitive_types.h"
4
#include "sdfg/types/tensor.h"
5

6
namespace sdfg {
7
namespace math {
8
namespace tensor {
9

10
types::PrimitiveType
NEW
11
deserialize_quantization(const nlohmann::json& j, const std::string& field_name, types::PrimitiveType default_value) {
×
NEW
12
    auto it = j.find(field_name);
×
NEW
13
    QuantizationType quantization = default_value;
×
NEW
14
    if (it != j.end()) {
×
NEW
15
        quantization = it->get<types::PrimitiveType>();
×
NEW
16
    }
×
NEW
17
    return quantization;
×
NEW
18
}
×
19

20
TensorNode::TensorNode(
21
    size_t element_id,
22
    const DebugInfo& debug_info,
23
    const graph::Vertex vertex,
24
    data_flow::DataFlowGraph& parent,
25
    const data_flow::LibraryNodeCode& code,
26
    const std::vector<std::string>& outputs,
27
    const std::vector<std::string>& inputs,
28
    const data_flow::ImplementationType& impl_type
29
)
30
    : MathNode(element_id, debug_info, vertex, parent, code, outputs, inputs, impl_type, true) {}
643✔
31

32
void TensorNode::validate(const Function& function) const {
523✔
33
    MathNode::validate(function);
523✔
34

35
    auto& graph = this->get_parent();
523✔
36

37
    // Validate that all memlets have the same primitive type
38
    types::PrimitiveType prim_type = primitive_type(graph);
523✔
39

40
    // Check if this operation supports integer types
41
    if (!supports_integer_types() && types::is_integer(prim_type)) {
523✔
42
        throw InvalidSDFGException(
1✔
43
            "TensorNode: This operation does not support integer types. Found type: " +
1✔
44
            std::string(types::primitive_type_to_string(prim_type))
1✔
45
        );
1✔
46
    }
1✔
47
}
523✔
48

49
types::PrimitiveType TensorNode::primitive_type(const data_flow::DataFlowGraph& graph) const {
544✔
50
    types::PrimitiveType result_type = types::PrimitiveType::Void;
544✔
51
    bool first = true;
544✔
52

53
    // Check all input edges
54
    for (auto& iedge : graph.in_edges(*this)) {
1,872✔
55
        types::PrimitiveType edge_type;
1,872✔
56
        edge_type = iedge.base_type().primitive_type();
1,872✔
57

58
        if (first) {
1,872✔
59
            result_type = edge_type;
544✔
60
            first = false;
544✔
61
        } else if (result_type != edge_type) {
1,328✔
62
            throw InvalidSDFGException(
1✔
63
                "TensorNode: All input memlets must have the same primitive type. Found " +
1✔
64
                std::string(types::primitive_type_to_string(result_type)) + " and " +
1✔
65
                std::string(types::primitive_type_to_string(edge_type))
1✔
66
            );
1✔
67
        }
1✔
68
    }
1,872✔
69

70
    // Check all output edges
71
    for (auto& oedge : graph.out_edges(*this)) {
543✔
UNCOV
72
        types::PrimitiveType edge_type;
×
UNCOV
73
        edge_type = oedge.base_type().primitive_type();
×
74

UNCOV
75
        if (first) {
×
76
            result_type = edge_type;
×
77
            first = false;
×
UNCOV
78
        } else if (result_type != edge_type) {
×
79
            throw InvalidSDFGException(
×
80
                "TensorNode: All output memlets must have the same primitive type. Found " +
×
81
                std::string(types::primitive_type_to_string(result_type)) + " and " +
×
82
                std::string(types::primitive_type_to_string(edge_type))
×
83
            );
×
84
        }
×
UNCOV
85
    }
×
86

87
    if (first) {
543✔
88
        throw InvalidSDFGException("TensorNode: No edges found to determine primitive type");
×
89
    }
×
90

91
    return result_type;
543✔
92
}
543✔
93

94
data_flow::TaskletCode TensorNode::get_integer_minmax_tasklet(types::PrimitiveType prim_type, bool is_max) {
5✔
95
    bool is_signed = types::is_signed(prim_type);
5✔
96
    if (is_max) {
5✔
97
        return is_signed ? data_flow::TaskletCode::int_smax : data_flow::TaskletCode::int_umax;
5✔
98
    } else {
5✔
99
        return is_signed ? data_flow::TaskletCode::int_smin : data_flow::TaskletCode::int_umin;
×
100
    }
×
101
}
5✔
102

103
void TensorNode::validate_shape_matches(
104
    const std::vector<symbolic::Expression>& required_shape, const TensorLayout& layout, const std::string& name
105
) const {
1,446✔
106
    if (layout.shape().size() != required_shape.size()) {
1,446✔
NEW
107
        throw InvalidSDFGException(
×
NEW
108
            "On libNode #" + std::to_string(element_id()) + ": " + name +
×
NEW
109
            " tensor shape must match node shape dims: Given: " + std::to_string(layout.shape().size()) +
×
NEW
110
            " Required: " + std::to_string(required_shape.size())
×
NEW
111
        );
×
NEW
112
    }
×
113
    auto& given_shape = layout.shape();
1,446✔
114
    for (size_t i = 0; i < required_shape.size(); ++i) {
5,179✔
115
        if (!symbolic::eq(layout.shape().at(i), required_shape.at(i))) {
3,733✔
NEW
116
            throw InvalidSDFGException(
×
NEW
117
                "On libNode #" + std::to_string(element_id()) + ": " + name +
×
NEW
118
                " tensor shape must match shape: Given: " + layout.shape().at(i)->__str__() +
×
NEW
119
                " Expected shape: " + required_shape.at(i)->__str__()
×
NEW
120
            );
×
NEW
121
        }
×
122
    }
3,733✔
123
}
1,446✔
124

125
} // namespace tensor
126
} // namespace math
127
} // 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