-
Notifications
You must be signed in to change notification settings - Fork 250
Expand file tree
/
Copy pathArithmetic.hpp
More file actions
42 lines (35 loc) · 1.06 KB
/
Arithmetic.hpp
File metadata and controls
42 lines (35 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef UTENSOR_ARITHMETIC_OPS_H
#define UTENSOR_ARITHMETIC_OPS_H
#include <algorithm>
#include <limits>
#include "Arithmetic_kernels.hpp"
#include "uTensor/core/operatorBase.hpp"
namespace uTensor {
namespace ReferenceOperators {
template <typename T>
class AddOperator : public OperatorInterface<2, 1> {
public:
enum names_in : uint8_t { a, b };
enum names_out : uint8_t { c };
// AddOperator(FixedTensorMap<2> inputs, FixedTensorMap<1> outputs) :
// OperatorBase(inputs, outputs) {}
protected:
virtual void compute() {
add_kernel<T>(outputs[c].tensor(), inputs[a].tensor(), inputs[b].tensor());
}
};
template <typename T>
class MulOperator : public OperatorInterface<2, 1> {
public:
enum names_in : uint8_t { a, b };
enum names_out : uint8_t { c };
// AddOperator(FixedTensorMap<2> inputs, FixedTensorMap<1> outputs) :
// OperatorBase(inputs, outputs) {}
protected:
virtual void compute() {
mul_kernel<T>(outputs[c].tensor(), inputs[a].tensor(), inputs[b].tensor());
}
};
} // namespace ReferenceOperators
} // namespace uTensor
#endif