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

daisytuner / docc / 26521975951

27 May 2026 03:45PM UTC coverage: 60.869% (-0.02%) from 60.886%
26521975951

push

github

web-flow
Libnode ptr edges (#719)

Migrating SDFGs to treat pointers as inputs to libNodes / Calls as scalars.
A pointer will only appear in an output edge if its actually returned from the function (like malloc).

* Stdlib, Blas and Tensor Matmul nodes were migrated to this new format. Other, currently transitory Tensor Nodes are not yet migrated.
* DOCC version was bumped to incorporate previous docc-llvm versions (up to 0.4.0) that had been counted separately.
! Until all passes consider the use / leak of pointers as uncertainty / hiding potential writes, TensorNodes are declared as general side-effect.
* Lots of utility functions to centralize the creation (and edges) of various libNodes that needed to be changed.
* Fixed & unified docc paths across python and llvm front-ends.
* Skip BlockFusion test that fails to its libNodes currently having side effects
~ Prevent a crash in DotViz when using symbolic offsets into structs
* Removing old ConstProp pass, it is not safe for the new pointer representation and should not be all too critical

961 of 1749 new or added lines in 52 files covered. (54.95%)

87 existing lines in 28 files now uncovered.

35225 of 57870 relevant lines covered (60.87%)

11046.32 hits per line

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

66.25
/sdfg/src/types/tensor.cpp
1
#include "sdfg/types/tensor.h"
2

3
#include "sdfg/types/scalar.h"
4

5
namespace sdfg {
6
namespace types {
7

8
symbolic::MultiExpression Tensor::strides_from_shape(const symbolic::MultiExpression& shape) {
8✔
9
    if (shape.empty()) {
8✔
UNCOV
10
        return {};
×
UNCOV
11
    }
×
12
    symbolic::MultiExpression strides(shape.size());
8✔
13
    strides.back() = SymEngine::integer(1);
8✔
14
    for (size_t i = shape.size() - 1; i > 0; --i) {
18✔
15
        strides[i - 1] = SymEngine::mul(strides[i], shape[i]);
10✔
16
    }
10✔
17
    return strides;
8✔
18
}
8✔
19

20
Tensor::Tensor(const Scalar& element_type, const math::tensor::TensorLayout& layout)
21
    : element_type_(std::unique_ptr<Scalar>(static_cast<Scalar*>(element_type.clone().release()))), layout_(layout) {};
999✔
22

23
Tensor::Tensor(const Scalar& element_type, const symbolic::MultiExpression& shape)
24
    : Tensor(element_type, math::tensor::TensorLayout(shape)) {};
994✔
25

26
Tensor::Tensor(
27
    const Scalar& element_type,
28
    const symbolic::MultiExpression& shape,
29
    const symbolic::MultiExpression& strides,
30
    const symbolic::Expression& offset
31
)
32
    : Tensor(element_type, math::tensor::TensorLayout(shape, strides, offset)) {};
5✔
33

34
Tensor::Tensor(
35
    StorageType storage_type,
36
    size_t alignment,
37
    const std::string& initializer,
38
    const Scalar& element_type,
39
    const math::tensor::TensorLayout& layout
40
)
41
    : IType(storage_type, alignment, initializer),
5,144✔
42
      element_type_(std::unique_ptr<Scalar>(static_cast<Scalar*>(element_type.clone().release()))), layout_(layout) {};
5,144✔
43

44
Tensor::Tensor(
45
    StorageType storage_type,
46
    size_t alignment,
47
    const std::string& initializer,
48
    const Scalar& element_type,
49
    const symbolic::MultiExpression& shape,
50
    const symbolic::MultiExpression& strides,
51
    const symbolic::Expression& offset
52
)
53
    : Tensor(
1,462✔
54
          std::move(storage_type),
1,462✔
55
          alignment,
1,462✔
56
          initializer,
1,462✔
57
          element_type,
1,462✔
58
          math::tensor::TensorLayout(shape, strides, offset)
1,462✔
59
      ) {};
1,462✔
60

61
PrimitiveType Tensor::primitive_type() const { return this->element_type_->primitive_type(); };
1,971✔
62

63
bool Tensor::is_symbol() const { return false; };
1✔
64

65
const Scalar& Tensor::element_type() const { return *this->element_type_; };
2,461✔
66

NEW
67
const math::tensor::TensorLayout& Tensor::layout() const { return this->layout_; }
×
68

69
const symbolic::MultiExpression& Tensor::shape() const { return this->layout_.shape(); };
23,845✔
70

71
const symbolic::MultiExpression& Tensor::strides() const { return this->layout_.strides(); };
9,563✔
72

73
const symbolic::Expression& Tensor::offset() const { return this->layout_.offset(); };
1,470✔
74

NEW
75
symbolic::Expression Tensor::total_elements() const { return layout_.total_elements(); };
×
76

77
bool Tensor::is_scalar() const { return this->layout_.shape().empty(); }
8,310✔
78

79
TypeID Tensor::type_id() const { return TypeID::Tensor; };
19,493✔
80

81
bool Tensor::operator==(const IType& other) const {
8✔
82
    if (!dynamic_cast<const Tensor*>(&other)) {
8✔
83
        return false;
×
84
    }
×
85
    const auto& tensor_type = static_cast<const Tensor&>(other);
8✔
86

87
    if (!this->element_type_->operator==(*tensor_type.element_type_)) {
8✔
88
        return false;
1✔
89
    }
1✔
90
    if (layout_ != tensor_type.layout_) {
7✔
91
        return false;
1✔
92
    }
1✔
93

94
    return true;
6✔
95
};
7✔
96

97

98
std::unique_ptr<IType> Tensor::clone() const {
3,680✔
99
    return std::make_unique<
3,680✔
100
        Tensor>(this->storage_type(), this->alignment(), this->initializer(), *this->element_type_, this->layout_);
3,680✔
101
};
3,680✔
102

103
std::string Tensor::print() const {
×
NEW
104
    std::string result = "Tensor(" + this->element_type_->print() + ", ";
×
NEW
105
    result += layout_.toStr();
×
106
    result += ")";
×
107
    return result;
×
108
};
×
109

110
std::unique_ptr<Tensor> Tensor::newaxis(size_t axis) const {
×
111
    return std::make_unique<Tensor>(
×
NEW
112
        this->storage_type(), this->alignment(), this->initializer(), *this->element_type_, *layout_.newaxis(axis)
×
113
    );
×
114
}
×
115

116
std::unique_ptr<Tensor> Tensor::flip(size_t axis) const {
1✔
117
    return std::make_unique<
1✔
118
        Tensor>(this->storage_type(), this->alignment(), this->initializer(), *this->element_type_, *layout_.flip(axis));
1✔
119
}
1✔
120

121
std::unique_ptr<Tensor> Tensor::unsqueeze(size_t axis) const { return this->newaxis(axis); }
×
122

123
std::unique_ptr<Tensor> Tensor::squeeze(size_t axis) const {
×
124
    return std::make_unique<Tensor>(
×
NEW
125
        this->storage_type(), this->alignment(), this->initializer(), *this->element_type_, *layout_.squeeze(axis)
×
126
    );
×
127
}
×
128

129
std::unique_ptr<Tensor> Tensor::squeeze() const {
×
NEW
130
    return std::make_unique<
×
NEW
131
        Tensor>(this->storage_type(), this->alignment(), this->initializer(), *this->element_type_, *layout_.squeeze());
×
UNCOV
132
}
×
133

134
std::unique_ptr<Tensor> Tensor::reshape(const symbolic::MultiExpression& new_shape) const {
1✔
135
    return std::make_unique<Tensor>(
1✔
136
        this->storage_type(), this->alignment(), this->initializer(), *this->element_type_, *layout_.reshape(new_shape)
1✔
137
    );
1✔
138
}
1✔
139

140
} // namespace types
141
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc