Coverage Report

Created: 2026-11-02 16:55

/home/runner/work/LabNeura/LabNeura/src/labneura/backends/common/base.cpp
Line
Count
Source (jump to first uncovered line)
1
#include "labneura/backends/common/base.h"
2
#include <stdexcept>
3
4
namespace labneura {
5
6
453
void TensorBackend::add_inplace(const TensorBackend& other) {
7
453
    operation(other, OperationType::ADD);
8
453
}
9
10
142
void TensorBackend::sub_inplace(const TensorBackend& other) {
11
142
    operation(other, OperationType::SUB);
12
142
}
13
14
196
void TensorBackend::mul_inplace(const TensorBackend& other) {
15
196
    operation(other, OperationType::MUL);
16
196
}
17
18
154
void TensorBackend::div_inplace(const TensorBackend& other) {
19
154
    operation(other, OperationType::DIV);
20
154
}
21
22
945
void TensorBackend::operation(const TensorBackend& other, OperationType op) {
23
945
    if (size() != other.size()) {
24
12
        throw std::runtime_error("Tensor size mismatch");
25
12
    }
26
27
933
    if (quantization_mode() != other.quantization_mode()) {
28
16
        throw std::runtime_error("Quantization mode mismatch");
29
16
    }
30
31
917
    if (quantization_mode() == QuantizationMode::FP32) {
32
540
        operation_fp32(other, op);
33
540
    } else if (quantization_mode() == QuantizationMode::FP16) {
34
66
        operation_fp16(other, op);
35
311
    } else if (quantization_mode() == QuantizationMode::INT16) {
36
98
        operation_int16(other, op);
37
213
    } else {
38
213
        operation_int8(other, op);
39
213
    }
40
917
}
41
42
3
int16_t* TensorBackend::data_fp16() {
43
3
    throw std::runtime_error("FP16 data access not implemented for this backend");
44
3
}
45
46
0
const int16_t* TensorBackend::data_fp16() const {
47
0
    throw std::runtime_error("FP16 data access not implemented for this backend");
48
0
}
49
50
3
int16_t* TensorBackend::data_int16() {
51
3
    throw std::runtime_error("INT16 data access not implemented for this backend");
52
3
}
53
54
0
const int16_t* TensorBackend::data_int16() const {
55
0
    throw std::runtime_error("INT16 data access not implemented for this backend");
56
0
}
57
58
0
void TensorBackend::operation_fp16(const TensorBackend&, OperationType) {
59
0
    throw std::runtime_error("FP16 operations not implemented for this backend");
60
0
}
61
62
0
void TensorBackend::operation_int16(const TensorBackend&, OperationType) {
63
0
    throw std::runtime_error("INT16 operations not implemented for this backend");
64
0
}
65
66
} // namespace labneura