Skip to content

Commit 312cd42

Browse files
committed
feat(torch): add generated operator bases
1 parent 3e3e319 commit 312cd42

469 files changed

Lines changed: 25469 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/base/abs.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef INFINI_OPS_BASE_ABS_H_
2+
#define INFINI_OPS_BASE_ABS_H_
3+
4+
#include "operator.h"
5+
6+
namespace infini::ops {
7+
8+
class Abs : public Operator<Abs> {
9+
public:
10+
Abs(const Tensor self, Tensor out)
11+
: self_shape_{self.shape()},
12+
self_strides_{self.strides()},
13+
self_type_{self.dtype()},
14+
out_shape_{out.shape()},
15+
out_strides_{out.strides()},
16+
out_type_{out.dtype()},
17+
device_index_{out.device().index()} {}
18+
19+
virtual void operator()(const Tensor self, Tensor out) const = 0;
20+
21+
protected:
22+
Tensor::Shape self_shape_;
23+
24+
Tensor::Strides self_strides_;
25+
26+
DataType self_type_;
27+
28+
Tensor::Shape out_shape_;
29+
30+
Tensor::Strides out_strides_;
31+
32+
DataType out_type_;
33+
34+
int device_index_{0};
35+
};
36+
37+
} // namespace infini::ops
38+
39+
#endif

src/base/absolute.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef INFINI_OPS_BASE_ABSOLUTE_H_
2+
#define INFINI_OPS_BASE_ABSOLUTE_H_
3+
4+
#include "operator.h"
5+
6+
namespace infini::ops {
7+
8+
class Absolute : public Operator<Absolute> {
9+
public:
10+
Absolute(const Tensor self, Tensor out)
11+
: self_shape_{self.shape()},
12+
self_strides_{self.strides()},
13+
self_type_{self.dtype()},
14+
out_shape_{out.shape()},
15+
out_strides_{out.strides()},
16+
out_type_{out.dtype()},
17+
device_index_{out.device().index()} {}
18+
19+
virtual void operator()(const Tensor self, Tensor out) const = 0;
20+
21+
protected:
22+
Tensor::Shape self_shape_;
23+
24+
Tensor::Strides self_strides_;
25+
26+
DataType self_type_;
27+
28+
Tensor::Shape out_shape_;
29+
30+
Tensor::Strides out_strides_;
31+
32+
DataType out_type_;
33+
34+
int device_index_{0};
35+
};
36+
37+
} // namespace infini::ops
38+
39+
#endif

src/base/acos.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef INFINI_OPS_BASE_ACOS_H_
2+
#define INFINI_OPS_BASE_ACOS_H_
3+
4+
#include "operator.h"
5+
6+
namespace infini::ops {
7+
8+
class Acos : public Operator<Acos> {
9+
public:
10+
Acos(const Tensor self, Tensor out)
11+
: self_shape_{self.shape()},
12+
self_strides_{self.strides()},
13+
self_type_{self.dtype()},
14+
out_shape_{out.shape()},
15+
out_strides_{out.strides()},
16+
out_type_{out.dtype()},
17+
device_index_{out.device().index()} {}
18+
19+
virtual void operator()(const Tensor self, Tensor out) const = 0;
20+
21+
protected:
22+
Tensor::Shape self_shape_;
23+
24+
Tensor::Strides self_strides_;
25+
26+
DataType self_type_;
27+
28+
Tensor::Shape out_shape_;
29+
30+
Tensor::Strides out_strides_;
31+
32+
DataType out_type_;
33+
34+
int device_index_{0};
35+
};
36+
37+
} // namespace infini::ops
38+
39+
#endif

src/base/acosh.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef INFINI_OPS_BASE_ACOSH_H_
2+
#define INFINI_OPS_BASE_ACOSH_H_
3+
4+
#include "operator.h"
5+
6+
namespace infini::ops {
7+
8+
class Acosh : public Operator<Acosh> {
9+
public:
10+
Acosh(const Tensor self, Tensor out)
11+
: self_shape_{self.shape()},
12+
self_strides_{self.strides()},
13+
self_type_{self.dtype()},
14+
out_shape_{out.shape()},
15+
out_strides_{out.strides()},
16+
out_type_{out.dtype()},
17+
device_index_{out.device().index()} {}
18+
19+
virtual void operator()(const Tensor self, Tensor out) const = 0;
20+
21+
protected:
22+
Tensor::Shape self_shape_;
23+
24+
Tensor::Strides self_strides_;
25+
26+
DataType self_type_;
27+
28+
Tensor::Shape out_shape_;
29+
30+
Tensor::Strides out_strides_;
31+
32+
DataType out_type_;
33+
34+
int device_index_{0};
35+
};
36+
37+
} // namespace infini::ops
38+
39+
#endif

src/base/adaptive_avg_pool2d.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef INFINI_OPS_BASE_ADAPTIVE_AVG_POOL2D_H_
2+
#define INFINI_OPS_BASE_ADAPTIVE_AVG_POOL2D_H_
3+
4+
#include <vector>
5+
#include "operator.h"
6+
7+
namespace infini::ops {
8+
9+
class AdaptiveAvgPool2d : public Operator<AdaptiveAvgPool2d> {
10+
public:
11+
AdaptiveAvgPool2d(const Tensor self, const std::vector<int64_t> output_size, Tensor out)
12+
: self_shape_{self.shape()},
13+
self_strides_{self.strides()},
14+
self_type_{self.dtype()},
15+
out_shape_{out.shape()},
16+
out_strides_{out.strides()},
17+
out_type_{out.dtype()},
18+
output_size_{output_size},
19+
device_index_{out.device().index()} {}
20+
21+
virtual void operator()(const Tensor self, const std::vector<int64_t> output_size, Tensor out) const = 0;
22+
23+
protected:
24+
Tensor::Shape self_shape_;
25+
26+
Tensor::Strides self_strides_;
27+
28+
DataType self_type_;
29+
30+
Tensor::Shape out_shape_;
31+
32+
Tensor::Strides out_strides_;
33+
34+
DataType out_type_;
35+
36+
std::vector<int64_t> output_size_{};
37+
38+
int device_index_{0};
39+
};
40+
41+
} // namespace infini::ops
42+
43+
#endif

src/base/adaptive_avg_pool3d.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef INFINI_OPS_BASE_ADAPTIVE_AVG_POOL3D_H_
2+
#define INFINI_OPS_BASE_ADAPTIVE_AVG_POOL3D_H_
3+
4+
#include <vector>
5+
#include "operator.h"
6+
7+
namespace infini::ops {
8+
9+
class AdaptiveAvgPool3d : public Operator<AdaptiveAvgPool3d> {
10+
public:
11+
AdaptiveAvgPool3d(const Tensor self, const std::vector<int64_t> output_size, Tensor out)
12+
: self_shape_{self.shape()},
13+
self_strides_{self.strides()},
14+
self_type_{self.dtype()},
15+
out_shape_{out.shape()},
16+
out_strides_{out.strides()},
17+
out_type_{out.dtype()},
18+
output_size_{output_size},
19+
device_index_{out.device().index()} {}
20+
21+
virtual void operator()(const Tensor self, const std::vector<int64_t> output_size, Tensor out) const = 0;
22+
23+
protected:
24+
Tensor::Shape self_shape_;
25+
26+
Tensor::Strides self_strides_;
27+
28+
DataType self_type_;
29+
30+
Tensor::Shape out_shape_;
31+
32+
Tensor::Strides out_strides_;
33+
34+
DataType out_type_;
35+
36+
std::vector<int64_t> output_size_{};
37+
38+
int device_index_{0};
39+
};
40+
41+
} // namespace infini::ops
42+
43+
#endif
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#ifndef INFINI_OPS_BASE_ADAPTIVE_AVG_POOL3D_BACKWARD_H_
2+
#define INFINI_OPS_BASE_ADAPTIVE_AVG_POOL3D_BACKWARD_H_
3+
4+
#include "operator.h"
5+
6+
namespace infini::ops {
7+
8+
class AdaptiveAvgPool3dBackward : public Operator<AdaptiveAvgPool3dBackward> {
9+
public:
10+
AdaptiveAvgPool3dBackward(const Tensor grad_output, const Tensor self, Tensor grad_input)
11+
: grad_output_shape_{grad_output.shape()},
12+
grad_output_strides_{grad_output.strides()},
13+
grad_output_type_{grad_output.dtype()},
14+
self_shape_{self.shape()},
15+
self_strides_{self.strides()},
16+
self_type_{self.dtype()},
17+
grad_input_shape_{grad_input.shape()},
18+
grad_input_strides_{grad_input.strides()},
19+
grad_input_type_{grad_input.dtype()},
20+
device_index_{grad_input.device().index()} {}
21+
22+
virtual void operator()(const Tensor grad_output, const Tensor self, Tensor grad_input) const = 0;
23+
24+
protected:
25+
Tensor::Shape grad_output_shape_;
26+
27+
Tensor::Strides grad_output_strides_;
28+
29+
DataType grad_output_type_;
30+
31+
Tensor::Shape self_shape_;
32+
33+
Tensor::Strides self_strides_;
34+
35+
DataType self_type_;
36+
37+
Tensor::Shape grad_input_shape_;
38+
39+
Tensor::Strides grad_input_strides_;
40+
41+
DataType grad_input_type_;
42+
43+
int device_index_{0};
44+
};
45+
46+
} // namespace infini::ops
47+
48+
#endif

src/base/adaptive_max_pool2d.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#ifndef INFINI_OPS_BASE_ADAPTIVE_MAX_POOL2D_H_
2+
#define INFINI_OPS_BASE_ADAPTIVE_MAX_POOL2D_H_
3+
4+
#include <vector>
5+
#include "operator.h"
6+
7+
namespace infini::ops {
8+
9+
class AdaptiveMaxPool2d : public Operator<AdaptiveMaxPool2d> {
10+
public:
11+
AdaptiveMaxPool2d(const Tensor self, const std::vector<int64_t> output_size, Tensor out, Tensor indices)
12+
: self_shape_{self.shape()},
13+
self_strides_{self.strides()},
14+
self_type_{self.dtype()},
15+
out_shape_{out.shape()},
16+
out_strides_{out.strides()},
17+
out_type_{out.dtype()},
18+
indices_shape_{indices.shape()},
19+
indices_strides_{indices.strides()},
20+
indices_type_{indices.dtype()},
21+
output_size_{output_size},
22+
device_index_{out.device().index()} {}
23+
24+
virtual void operator()(const Tensor self, const std::vector<int64_t> output_size, Tensor out, Tensor indices) const = 0;
25+
26+
protected:
27+
Tensor::Shape self_shape_;
28+
29+
Tensor::Strides self_strides_;
30+
31+
DataType self_type_;
32+
33+
Tensor::Shape out_shape_;
34+
35+
Tensor::Strides out_strides_;
36+
37+
DataType out_type_;
38+
39+
Tensor::Shape indices_shape_;
40+
41+
Tensor::Strides indices_strides_;
42+
43+
DataType indices_type_;
44+
45+
std::vector<int64_t> output_size_{};
46+
47+
int device_index_{0};
48+
};
49+
50+
} // namespace infini::ops
51+
52+
#endif

0 commit comments

Comments
 (0)