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

daisytuner / docc / 30365534143

28 Jul 2026 01:50PM UTC coverage: 64.326% (+0.002%) from 64.324%
30365534143

Pull #898

github

web-flow
Merge fc9ad7b2f into 9ecbee2f9
Pull Request #898: [PyTorch] Add support for aten.neg

26 of 38 new or added lines in 4 files covered. (68.42%)

43444 of 67537 relevant lines covered (64.33%)

726.58 hits per line

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

68.75
/sdfg/src/data_flow/library_nodes/math/tensor/elementwise_ops/neg_node.cpp
1
#include "sdfg/data_flow/library_nodes/math/tensor/elementwise_ops/neg_node.h"
2

3
#include "sdfg/analysis/analysis.h"
4
#include "sdfg/builder/structured_sdfg_builder.h"
5

6
#include "sdfg/data_flow/access_node.h"
7
#include "sdfg/types/type.h"
8

9
namespace sdfg {
10
namespace math {
11
namespace tensor {
12

13
NegNode::NegNode(
14
    size_t element_id,
15
    const DebugInfo& debug_info,
16
    const graph::Vertex vertex,
17
    data_flow::DataFlowGraph& parent,
18
    const std::vector<symbolic::Expression>& shape,
19
    QuantizationType quantization,
20
    const data_flow::ImplementationType& impl_type
21
)
22
    : ElementWiseDataflowTensorNode(
20✔
23
          element_id, debug_info, vertex, parent, LibraryNodeType_Neg, shape, "Y", {"X"}, quantization, impl_type
20✔
24
      ) {}
20✔
25

26
ElementWiseDataflowTensorNode::ElementOutput NegNode::expand_operation_dataflow(
27
    builder::StructuredSDFGBuilder& builder,
28
    Block& block,
29
    std::vector<ElementInput>& needed_inputs,
30
    types::PrimitiveType expected_type
31
) {
20✔
32
    auto& input = needed_inputs.at(0);
20✔
33

34
    if (types::is_floating_point(input.required_type)) {
20✔
35
        // Floating-point negation maps directly to a unary fp_neg tasklet.
36
        auto& tasklet = builder.add_tasklet(block, data_flow::TaskletCode::fp_neg, "_out", {"_in"}, this->debug_info());
12✔
37
        input.consumer = &tasklet;
12✔
38
        input.input_conn_index = 0;
12✔
39
        return {.producer = &tasklet, .output_conn_index = 0, .type = input.required_type};
12✔
40
    } else if (types::is_integer(input.required_type)) {
12✔
41
        // Integer negation is expressed as a multiplication with the constant -1.
42
        auto& const_neg1 = builder.add_constant(block, "-1", types::Scalar(input.required_type), this->debug_info());
8✔
43

44
        auto& tasklet =
8✔
45
            builder.add_tasklet(block, data_flow::TaskletCode::int_mul, "_out", {"_in0", "_in1"}, this->debug_info());
8✔
46
        builder.add_computational_memlet(
8✔
47
            block, const_neg1, tasklet, "_in1", {}, types::Scalar(input.required_type), this->debug_info()
8✔
48
        );
8✔
49
        input.consumer = &tasklet;
8✔
50
        input.input_conn_index = 0;
8✔
51
        return {.producer = &tasklet, .output_conn_index = 0, .type = input.required_type};
8✔
52
    } else {
8✔
NEW
53
        throw InvalidSDFGException(
×
NEW
54
            std::string("NegNode: Unsupported expected type for expand_operation_dataflow: ") +
×
NEW
55
            types::primitive_type_to_string(input.required_type)
×
NEW
56
        );
×
NEW
57
    }
×
58
}
20✔
59

60
std::unique_ptr<data_flow::DataFlowNode> NegNode::
NEW
61
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const {
×
NEW
62
    return std::unique_ptr<data_flow::DataFlowNode>(new NegNode(
×
NEW
63
        element_id, this->debug_info(), vertex, parent, this->shape_, fixed_quantization_, implementation_type_
×
NEW
64
    ));
×
NEW
65
}
×
66

67
} // namespace tensor
68
} // namespace math
69
} // 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