Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/base/scatter_add.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#ifndef INFINI_OPS_BASE_SCATTER_ADD_H_
#define INFINI_OPS_BASE_SCATTER_ADD_H_

#include "operator.h"

namespace infini::ops {

class ScatterAdd : public Operator<ScatterAdd> {
public:
ScatterAdd(const Tensor input, const int64_t dim, const Tensor index,
const Tensor src, Tensor out)
: input_shape_{input.shape()},
input_strides_{input.strides()},
input_type_{input.dtype()},
index_shape_{index.shape()},
index_strides_{index.strides()},
index_type_{index.dtype()},
src_shape_{src.shape()},
src_strides_{src.strides()},
src_type_{src.dtype()},
out_shape_{out.shape()},
out_strides_{out.strides()},
out_type_{out.dtype()},
dim_{dim},
device_index_{out.device().index()} {}

virtual void operator()(const Tensor input, const int64_t dim,
const Tensor index, const Tensor src,
Tensor out) const = 0;

protected:
Tensor::Shape input_shape_;

Tensor::Strides input_strides_;

DataType input_type_;

Tensor::Shape index_shape_;

Tensor::Strides index_strides_;

DataType index_type_;

Tensor::Shape src_shape_;

Tensor::Strides src_strides_;

DataType src_type_;

Tensor::Shape out_shape_;

Tensor::Strides out_strides_;

DataType out_type_;

int64_t dim_{};

int device_index_{0};
};

} // namespace infini::ops

#endif
Loading