|
| 1 | +#ifndef INFINI_OPS_BASE_MAX_POOL3D_WITH_INDICES_BACKWARD_GRAD_INPUT_H_ |
| 2 | +#define INFINI_OPS_BASE_MAX_POOL3D_WITH_INDICES_BACKWARD_GRAD_INPUT_H_ |
| 3 | + |
| 4 | +#include "operator.h" |
| 5 | + |
| 6 | +namespace infini::ops { |
| 7 | + |
| 8 | +class MaxPool3dWithIndicesBackwardGradInput |
| 9 | + : public Operator<MaxPool3dWithIndicesBackwardGradInput> { |
| 10 | + public: |
| 11 | + MaxPool3dWithIndicesBackwardGradInput( |
| 12 | + const Tensor grad_output, const Tensor self, |
| 13 | + const std::vector<int64_t> kernel_size, const std::vector<int64_t> stride, |
| 14 | + const std::vector<int64_t> padding, const std::vector<int64_t> dilation, |
| 15 | + const bool ceil_mode, const Tensor indices, Tensor grad_input) |
| 16 | + : grad_output_shape_{grad_output.shape()}, |
| 17 | + grad_output_strides_{grad_output.strides()}, |
| 18 | + grad_output_type_{grad_output.dtype()}, |
| 19 | + self_shape_{self.shape()}, |
| 20 | + self_strides_{self.strides()}, |
| 21 | + self_type_{self.dtype()}, |
| 22 | + indices_shape_{indices.shape()}, |
| 23 | + indices_strides_{indices.strides()}, |
| 24 | + indices_type_{indices.dtype()}, |
| 25 | + grad_input_shape_{grad_input.shape()}, |
| 26 | + grad_input_strides_{grad_input.strides()}, |
| 27 | + grad_input_type_{grad_input.dtype()}, |
| 28 | + device_index_{grad_input.device().index()} {} |
| 29 | + |
| 30 | + virtual void operator()(const Tensor grad_output, const Tensor self, |
| 31 | + const std::vector<int64_t> kernel_size, |
| 32 | + const std::vector<int64_t> stride, |
| 33 | + const std::vector<int64_t> padding, |
| 34 | + const std::vector<int64_t> dilation, |
| 35 | + const bool ceil_mode, const Tensor indices, |
| 36 | + Tensor grad_input) const = 0; |
| 37 | + |
| 38 | + protected: |
| 39 | + Tensor::Shape grad_output_shape_; |
| 40 | + Tensor::Strides grad_output_strides_; |
| 41 | + DataType grad_output_type_; |
| 42 | + Tensor::Shape self_shape_; |
| 43 | + Tensor::Strides self_strides_; |
| 44 | + DataType self_type_; |
| 45 | + Tensor::Shape indices_shape_; |
| 46 | + Tensor::Strides indices_strides_; |
| 47 | + DataType indices_type_; |
| 48 | + Tensor::Shape grad_input_shape_; |
| 49 | + Tensor::Strides grad_input_strides_; |
| 50 | + DataType grad_input_type_; |
| 51 | + int device_index_{0}; |
| 52 | +}; |
| 53 | + |
| 54 | +} // namespace infini::ops |
| 55 | + |
| 56 | +#endif |
0 commit comments