Skip to content

Commit 0d17e1f

Browse files
committed
feat: add normal base
1 parent cfea02e commit 0d17e1f

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

src/base/normal.h

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

0 commit comments

Comments
 (0)