Skip to content

Commit 8142df7

Browse files
committed
feat: add pow base
1 parent cfea02e commit 8142df7

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

src/base/pow.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#ifndef INFINI_OPS_BASE_POW_H_
2+
#define INFINI_OPS_BASE_POW_H_
3+
4+
#include "operator.h"
5+
6+
namespace infini::ops {
7+
8+
class Pow : public Operator<Pow> {
9+
public:
10+
Pow(const Tensor input, const Tensor exponent, Tensor out)
11+
: input_shape_{input.shape()},
12+
input_strides_{input.strides()},
13+
input_type_{input.dtype()},
14+
exponent_shape_{exponent.shape()},
15+
exponent_strides_{exponent.strides()},
16+
exponent_type_{exponent.dtype()},
17+
out_shape_{out.shape()},
18+
out_strides_{out.strides()},
19+
out_type_{out.dtype()},
20+
device_index_{out.device().index()} {}
21+
22+
Pow(const Tensor input, const double exponent, Tensor out)
23+
: input_shape_{input.shape()},
24+
input_strides_{input.strides()},
25+
input_type_{input.dtype()},
26+
out_shape_{out.shape()},
27+
out_strides_{out.strides()},
28+
out_type_{out.dtype()},
29+
exponent_{exponent},
30+
device_index_{out.device().index()} {}
31+
32+
virtual void operator()(const Tensor input, const Tensor exponent,
33+
Tensor out) const = 0;
34+
35+
virtual void operator()(const Tensor input, const double exponent,
36+
Tensor out) const = 0;
37+
38+
protected:
39+
Tensor::Shape input_shape_;
40+
41+
Tensor::Strides input_strides_;
42+
43+
DataType input_type_;
44+
45+
Tensor::Shape exponent_shape_;
46+
47+
Tensor::Strides exponent_strides_;
48+
49+
DataType exponent_type_;
50+
51+
Tensor::Shape out_shape_;
52+
53+
Tensor::Strides out_strides_;
54+
55+
DataType out_type_;
56+
57+
double exponent_{};
58+
59+
int device_index_{0};
60+
};
61+
62+
} // namespace infini::ops
63+
64+
#endif

0 commit comments

Comments
 (0)