|
| 1 | +#ifndef INFINI_OPS_BASE_MULTILABEL_MARGIN_LOSS_BACKWARD_GRAD_INPUT_H_ |
| 2 | +#define INFINI_OPS_BASE_MULTILABEL_MARGIN_LOSS_BACKWARD_GRAD_INPUT_H_ |
| 3 | + |
| 4 | +#include "operator.h" |
| 5 | + |
| 6 | +namespace infini::ops { |
| 7 | + |
| 8 | +class MultilabelMarginLossBackwardGradInput |
| 9 | + : public Operator<MultilabelMarginLossBackwardGradInput> { |
| 10 | + public: |
| 11 | + MultilabelMarginLossBackwardGradInput(const Tensor grad_output, |
| 12 | + const Tensor self, const Tensor target, |
| 13 | + const int64_t reduction, |
| 14 | + const Tensor is_target, |
| 15 | + 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 | + target_shape_{target.shape()}, |
| 23 | + target_strides_{target.strides()}, |
| 24 | + target_type_{target.dtype()}, |
| 25 | + is_target_shape_{is_target.shape()}, |
| 26 | + is_target_strides_{is_target.strides()}, |
| 27 | + is_target_type_{is_target.dtype()}, |
| 28 | + grad_input_shape_{grad_input.shape()}, |
| 29 | + grad_input_strides_{grad_input.strides()}, |
| 30 | + grad_input_type_{grad_input.dtype()}, |
| 31 | + device_index_{grad_input.device().index()} {} |
| 32 | + |
| 33 | + virtual void operator()(const Tensor grad_output, const Tensor self, |
| 34 | + const Tensor target, const int64_t reduction, |
| 35 | + const Tensor is_target, Tensor grad_input) const = 0; |
| 36 | + |
| 37 | + protected: |
| 38 | + Tensor::Shape grad_output_shape_; |
| 39 | + Tensor::Strides grad_output_strides_; |
| 40 | + DataType grad_output_type_; |
| 41 | + Tensor::Shape self_shape_; |
| 42 | + Tensor::Strides self_strides_; |
| 43 | + DataType self_type_; |
| 44 | + Tensor::Shape target_shape_; |
| 45 | + Tensor::Strides target_strides_; |
| 46 | + DataType target_type_; |
| 47 | + Tensor::Shape is_target_shape_; |
| 48 | + Tensor::Strides is_target_strides_; |
| 49 | + DataType is_target_type_; |
| 50 | + Tensor::Shape grad_input_shape_; |
| 51 | + Tensor::Strides grad_input_strides_; |
| 52 | + DataType grad_input_type_; |
| 53 | + int device_index_{0}; |
| 54 | +}; |
| 55 | + |
| 56 | +} // namespace infini::ops |
| 57 | + |
| 58 | +#endif |
0 commit comments