|
| 1 | +#ifndef INFINI_OPS_BASE_SCATTER_ADD_H_ |
| 2 | +#define INFINI_OPS_BASE_SCATTER_ADD_H_ |
| 3 | + |
| 4 | +#include "operator.h" |
| 5 | + |
| 6 | +namespace infini::ops { |
| 7 | + |
| 8 | +class ScatterAdd : public Operator<ScatterAdd> { |
| 9 | + public: |
| 10 | + ScatterAdd(const Tensor input, const int64_t dim, const Tensor index, |
| 11 | + const Tensor src, Tensor out) |
| 12 | + : input_shape_{input.shape()}, |
| 13 | + input_strides_{input.strides()}, |
| 14 | + input_type_{input.dtype()}, |
| 15 | + index_shape_{index.shape()}, |
| 16 | + index_strides_{index.strides()}, |
| 17 | + index_type_{index.dtype()}, |
| 18 | + src_shape_{src.shape()}, |
| 19 | + src_strides_{src.strides()}, |
| 20 | + src_type_{src.dtype()}, |
| 21 | + out_shape_{out.shape()}, |
| 22 | + out_strides_{out.strides()}, |
| 23 | + out_type_{out.dtype()}, |
| 24 | + dim_{dim}, |
| 25 | + device_index_{out.device().index()} {} |
| 26 | + |
| 27 | + virtual void operator()(const Tensor input, const int64_t dim, |
| 28 | + const Tensor index, const Tensor src, |
| 29 | + Tensor out) const = 0; |
| 30 | + |
| 31 | + protected: |
| 32 | + Tensor::Shape input_shape_; |
| 33 | + |
| 34 | + Tensor::Strides input_strides_; |
| 35 | + |
| 36 | + DataType input_type_; |
| 37 | + |
| 38 | + Tensor::Shape index_shape_; |
| 39 | + |
| 40 | + Tensor::Strides index_strides_; |
| 41 | + |
| 42 | + DataType index_type_; |
| 43 | + |
| 44 | + Tensor::Shape src_shape_; |
| 45 | + |
| 46 | + Tensor::Strides src_strides_; |
| 47 | + |
| 48 | + DataType src_type_; |
| 49 | + |
| 50 | + Tensor::Shape out_shape_; |
| 51 | + |
| 52 | + Tensor::Strides out_strides_; |
| 53 | + |
| 54 | + DataType out_type_; |
| 55 | + |
| 56 | + int64_t dim_{}; |
| 57 | + |
| 58 | + int device_index_{0}; |
| 59 | +}; |
| 60 | + |
| 61 | +} // namespace infini::ops |
| 62 | + |
| 63 | +#endif |
0 commit comments