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

daisytuner / docc / 22023884668

14 Feb 2026 08:36PM UTC coverage: 64.903% (-1.4%) from 66.315%
22023884668

Pull #525

github

web-flow
Merge 1d47f8bf2 into 9d01cacd5
Pull Request #525: Step 3 (Native Tensor Support): Refactor Python Frontend

2522 of 3435 new or added lines in 32 files covered. (73.42%)

320 existing lines in 15 files now uncovered.

23204 of 35752 relevant lines covered (64.9%)

370.03 hits per line

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

78.43
/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✔
NEW
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✔
NEW
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 (container_type->type_id() == types::TypeID::Scalar) {
8✔
NEW
50
            memlet.set_base_type(*container_type);
×
NEW
51
            memlet.set_subset({});
×
NEW
52
            applied = true;
×
NEW
53
            continue;
×
NEW
54
        }
×
55

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

61
        auto& element_type = tensor_type.element_type();
8✔
62
        auto& shape = tensor_type.shape();
8✔
63
        auto& strides = tensor_type.strides();
8✔
64

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

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

74
        types::Pointer pointer_type(element_type);
8✔
75
        memlet.set_base_type(pointer_type);
8✔
76

77
        applied = true;
8✔
78
    }
8✔
79

80
    return applied;
4✔
81
}
4✔
82

83
} // namespace passes
84
} // 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