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

daisytuner / docc / 23868272706

01 Apr 2026 08:03PM UTC coverage: 64.453% (+0.06%) from 64.398%
23868272706

push

github

web-flow
Merge pull request #626 from daisytuner/einsum-conversion

adds einsum conversion to expand bindings

2 of 11 new or added lines in 4 files covered. (18.18%)

2 existing lines in 2 files now uncovered.

28779 of 44651 relevant lines covered (64.45%)

386.15 hits per line

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

75.47
/sdfg/src/passes/dataflow/tensor_to_pointer_conversion.cpp
1
#include "sdfg/passes/dataflow/tensor_to_pointer_conversion.h"
2

3
#include "sdfg/data_flow/data_flow_graph.h"
4
#include "sdfg/data_flow/memlet.h"
5
#include "sdfg/structured_control_flow/block.h"
6
#include "sdfg/symbolic/symbolic.h"
7
#include "sdfg/types/array.h"
8
#include "sdfg/types/pointer.h"
9
#include "sdfg/types/utils.h"
10
#include "sdfg/visitor/structured_sdfg_visitor.h"
11

12
namespace sdfg {
13
namespace passes {
14

15
TensorToPointerConversion::
16
    TensorToPointerConversion(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager)
17
    : visitor::NonStoppingStructuredSDFGVisitor(builder, analysis_manager) {}
4✔
18

19
bool TensorToPointerConversion::accept(structured_control_flow::Block& block) {
4✔
20
    bool applied = false;
4✔
21
    auto& dfg = block.dataflow();
4✔
22

23
    for (auto& memlet : dfg.edges()) {
8✔
24
        auto& base_type = memlet.base_type();
8✔
25
        if (base_type.type_id() != types::TypeID::Tensor) {
8✔
26
            continue;
×
27
        }
×
28
        auto& tensor_type = static_cast<const types::Tensor&>(base_type);
8✔
29

30
        // Distinguish between pointer and scalar buffers
31
        const types::IType* container_type = nullptr;
8✔
32
        if (!dynamic_cast<const data_flow::AccessNode*>(&memlet.src())) {
8✔
33
            auto& dst_node = static_cast<const data_flow::AccessNode&>(memlet.dst());
4✔
34
            if (auto const_node = dynamic_cast<const data_flow::ConstantNode*>(&dst_node)) {
4✔
35
                container_type = &const_node->type();
×
36
            } else {
4✔
37
                container_type = &builder_.subject().type(dst_node.data());
4✔
38
            }
4✔
39
        } else {
4✔
40
            auto& src_node = static_cast<const data_flow::AccessNode&>(memlet.src());
4✔
41
            if (auto const_node = dynamic_cast<const data_flow::ConstantNode*>(&src_node)) {
4✔
42
                container_type = &const_node->type();
×
43
            } else {
4✔
44
                container_type = &builder_.subject().type(src_node.data());
4✔
45
            }
4✔
46
        }
4✔
47

48
        // Handle scalar containers (including scalar tensor memlets with empty subset)
49
        if (tensor_type.shape().empty()) {
8✔
50
            assert(memlet.subset().empty());
×
51
            memlet.set_base_type(tensor_type.element_type());
×
52
            applied = true;
×
53
            continue;
×
54
        }
×
55

56
        // For pointer containers, we need a non-empty subset to linearize
57
        if (memlet.subset().empty()) {
8✔
NEW
58
            memlet.set_base_type(*container_type);
×
NEW
59
            applied = true;
×
60
            continue;
×
61
        }
×
62

63
        auto& element_type = tensor_type.element_type();
8✔
64
        auto& shape = tensor_type.shape();
8✔
65
        auto& strides = tensor_type.strides();
8✔
66

67
        auto& tensor_subset = memlet.subset();
8✔
68
        symbolic::Expression linearized_access = tensor_type.offset();
8✔
69
        for (size_t i = 0; i < shape.size(); ++i) {
22✔
70
            linearized_access = symbolic::add(linearized_access, symbolic::mul(tensor_subset.at(i), strides.at(i)));
14✔
71
        }
14✔
72

73
        data_flow::Subset pointer_subset = {linearized_access};
8✔
74
        memlet.set_subset(pointer_subset);
8✔
75

76
        types::Pointer pointer_type(element_type);
8✔
77
        memlet.set_base_type(pointer_type);
8✔
78

79
        applied = true;
8✔
80
    }
8✔
81

82
    return applied;
4✔
83
}
4✔
84

85
} // namespace passes
86
} // 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