Skip to content

Commit 6570581

Browse files
committed
feat: add glu_backward_grad_input base
1 parent 57ec7e3 commit 6570581

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

src/base/glu_backward_grad_input.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#ifndef INFINI_OPS_BASE_GLU_BACKWARD_GRAD_INPUT_H_
2+
#define INFINI_OPS_BASE_GLU_BACKWARD_GRAD_INPUT_H_
3+
4+
#include "operator.h"
5+
6+
namespace infini::ops {
7+
8+
class GluBackwardGradInput : public Operator<GluBackwardGradInput> {
9+
public:
10+
GluBackwardGradInput(const Tensor grad_output, const Tensor self,
11+
const int64_t dim, 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+
self_shape_{self.shape()},
16+
self_strides_{self.strides()},
17+
self_type_{self.dtype()},
18+
grad_input_shape_{grad_input.shape()},
19+
grad_input_strides_{grad_input.strides()},
20+
grad_input_type_{grad_input.dtype()},
21+
device_index_{grad_input.device().index()} {}
22+
23+
virtual void operator()(const Tensor grad_output, const Tensor self,
24+
const int64_t dim, Tensor grad_input) const = 0;
25+
26+
protected:
27+
Tensor::Shape grad_output_shape_;
28+
Tensor::Strides grad_output_strides_;
29+
DataType grad_output_type_;
30+
Tensor::Shape self_shape_;
31+
Tensor::Strides self_strides_;
32+
DataType self_type_;
33+
Tensor::Shape grad_input_shape_;
34+
Tensor::Strides grad_input_strides_;
35+
DataType grad_input_type_;
36+
int device_index_{0};
37+
};
38+
39+
} // namespace infini::ops
40+
41+
#endif

0 commit comments

Comments
 (0)