Skip to content

Commit 2650897

Browse files
committed
feat: add fractional_max_pool2d base
1 parent cfea02e commit 2650897

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

src/base/fractional_max_pool2d.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#ifndef INFINI_OPS_BASE_FRACTIONAL_MAX_POOL2D_H_
2+
#define INFINI_OPS_BASE_FRACTIONAL_MAX_POOL2D_H_
3+
4+
#include "operator.h"
5+
6+
namespace infini::ops {
7+
8+
class FractionalMaxPool2d : public Operator<FractionalMaxPool2d> {
9+
public:
10+
FractionalMaxPool2d(const Tensor input,
11+
const std::vector<int64_t> kernel_size,
12+
const std::vector<int64_t> output_size,
13+
const Tensor random_samples, Tensor output,
14+
Tensor indices)
15+
: input_shape_{input.shape()},
16+
input_strides_{input.strides()},
17+
input_type_{input.dtype()},
18+
random_samples_shape_{random_samples.shape()},
19+
random_samples_strides_{random_samples.strides()},
20+
random_samples_type_{random_samples.dtype()},
21+
output_shape_{output.shape()},
22+
output_strides_{output.strides()},
23+
output_type_{output.dtype()},
24+
indices_shape_{indices.shape()},
25+
indices_strides_{indices.strides()},
26+
indices_type_{indices.dtype()},
27+
kernel_size_{kernel_size},
28+
output_size_{output_size},
29+
device_index_{output.device().index()} {}
30+
31+
virtual void operator()(const Tensor input,
32+
const std::vector<int64_t> kernel_size,
33+
const std::vector<int64_t> output_size,
34+
const Tensor random_samples, Tensor output,
35+
Tensor indices) const = 0;
36+
37+
protected:
38+
Tensor::Shape input_shape_;
39+
40+
Tensor::Strides input_strides_;
41+
42+
DataType input_type_;
43+
44+
Tensor::Shape random_samples_shape_;
45+
46+
Tensor::Strides random_samples_strides_;
47+
48+
DataType random_samples_type_;
49+
50+
Tensor::Shape output_shape_;
51+
52+
Tensor::Strides output_strides_;
53+
54+
DataType output_type_;
55+
56+
Tensor::Shape indices_shape_;
57+
58+
Tensor::Strides indices_strides_;
59+
60+
DataType indices_type_;
61+
62+
std::vector<int64_t> kernel_size_{};
63+
64+
std::vector<int64_t> output_size_{};
65+
66+
int device_index_{0};
67+
};
68+
69+
} // namespace infini::ops
70+
71+
#endif

0 commit comments

Comments
 (0)