From a961f19e48c0e9ae54b980f06b1077d51b8f71b8 Mon Sep 17 00:00:00 2001 From: Jiacheng Huang Date: Sat, 9 May 2026 18:18:35 +0800 Subject: [PATCH] feat: add `replication_pad2d_backward` base --- src/base/replication_pad2d_backward.h | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/base/replication_pad2d_backward.h diff --git a/src/base/replication_pad2d_backward.h b/src/base/replication_pad2d_backward.h new file mode 100644 index 00000000..9568552d --- /dev/null +++ b/src/base/replication_pad2d_backward.h @@ -0,0 +1,55 @@ +#ifndef INFINI_OPS_BASE_REPLICATION_PAD2D_BACKWARD_H_ +#define INFINI_OPS_BASE_REPLICATION_PAD2D_BACKWARD_H_ + +#include "operator.h" + +namespace infini::ops { + +class ReplicationPad2dBackward : public Operator { + public: + ReplicationPad2dBackward(const Tensor grad_output, const Tensor input, + const std::vector padding, + Tensor grad_input) + : grad_output_shape_{grad_output.shape()}, + grad_output_strides_{grad_output.strides()}, + grad_output_type_{grad_output.dtype()}, + input_shape_{input.shape()}, + input_strides_{input.strides()}, + input_type_{input.dtype()}, + grad_input_shape_{grad_input.shape()}, + grad_input_strides_{grad_input.strides()}, + grad_input_type_{grad_input.dtype()}, + padding_{padding}, + device_index_{grad_input.device().index()} {} + + virtual void operator()(const Tensor grad_output, const Tensor input, + const std::vector padding, + Tensor grad_input) const = 0; + + protected: + Tensor::Shape grad_output_shape_; + + Tensor::Strides grad_output_strides_; + + DataType grad_output_type_; + + Tensor::Shape input_shape_; + + Tensor::Strides input_strides_; + + DataType input_type_; + + Tensor::Shape grad_input_shape_; + + Tensor::Strides grad_input_strides_; + + DataType grad_input_type_; + + std::vector padding_{}; + + int device_index_{0}; +}; + +} // namespace infini::ops + +#endif