Skip to content

Commit 3bedbd9

Browse files
committed
feat: add gelu_backward base
1 parent cfea02e commit 3bedbd9

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

src/base/gelu_backward.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#ifndef INFINI_OPS_BASE_GELU_BACKWARD_H_
2+
#define INFINI_OPS_BASE_GELU_BACKWARD_H_
3+
4+
#include "operator.h"
5+
6+
namespace infini::ops {
7+
8+
class GeluBackward : public Operator<GeluBackward> {
9+
public:
10+
GeluBackward(const Tensor grad_output, const Tensor input,
11+
const std::string approximate, Tensor grad_input)
12+
: grad_output_shape_{grad_output.shape()},
13+
grad_output_strides_{grad_output.strides()},
14+
grad_output_type_{grad_output.dtype()},
15+
input_shape_{input.shape()},
16+
input_strides_{input.strides()},
17+
input_type_{input.dtype()},
18+
grad_input_shape_{grad_input.shape()},
19+
grad_input_strides_{grad_input.strides()},
20+
grad_input_type_{grad_input.dtype()},
21+
approximate_{approximate},
22+
device_index_{grad_input.device().index()} {}
23+
24+
virtual void operator()(const Tensor grad_output, const Tensor input,
25+
const std::string approximate,
26+
Tensor grad_input) const = 0;
27+
28+
protected:
29+
Tensor::Shape grad_output_shape_;
30+
31+
Tensor::Strides grad_output_strides_;
32+
33+
DataType grad_output_type_;
34+
35+
Tensor::Shape input_shape_;
36+
37+
Tensor::Strides input_strides_;
38+
39+
DataType input_type_;
40+
41+
Tensor::Shape grad_input_shape_;
42+
43+
Tensor::Strides grad_input_strides_;
44+
45+
DataType grad_input_type_;
46+
47+
std::string approximate_{};
48+
49+
int device_index_{0};
50+
};
51+
52+
} // namespace infini::ops
53+
54+
#endif

0 commit comments

Comments
 (0)