|
| 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