InfiniOps
Operator Library for Accelerators
Loading...
Searching...
No Matches
gather.h
Go to the documentation of this file.
1#ifndef INFINI_OPS_BASE_GATHER_H_
2#define INFINI_OPS_BASE_GATHER_H_
3
4#include "operator.h"
5
6namespace infini::ops {
7
8class Gather : public Operator<Gather> {
9 public:
10 Gather(const Tensor input, const Tensor index, const int64_t dim,
11 const bool sparse_grad, 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 out_shape_{out.shape()},
19 out_strides_{out.strides()},
20 out_type_{out.dtype()},
21 dim_{dim},
22 sparse_grad_{sparse_grad},
23 device_index_{out.device().index()} {}
24
25 virtual void operator()(const Tensor input, const Tensor index,
26 const int64_t dim, const bool sparse_grad,
27 Tensor out) const = 0;
28
29 protected:
30 Tensor::Shape input_shape_;
31
32 Tensor::Strides input_strides_;
33
34 DataType input_type_;
35
36 Tensor::Shape index_shape_;
37
38 Tensor::Strides index_strides_;
39
40 DataType index_type_;
41
42 Tensor::Shape out_shape_;
43
44 Tensor::Strides out_strides_;
45
46 DataType out_type_;
47
48 int64_t dim_{};
49
51
53};
54
55} // namespace infini::ops
56
57#endif
Definition gather.h:8
Tensor::Strides out_strides_
Definition gather.h:44
Tensor::Shape index_shape_
Definition gather.h:36
bool sparse_grad_
Definition gather.h:50
Tensor::Strides input_strides_
Definition gather.h:32
DataType input_type_
Definition gather.h:34
DataType out_type_
Definition gather.h:46
int64_t dim_
Definition gather.h:48
virtual void operator()(const Tensor input, const Tensor index, const int64_t dim, const bool sparse_grad, Tensor out) const =0
int device_index_
Definition gather.h:52
Tensor::Shape out_shape_
Definition gather.h:42
Gather(const Tensor input, const Tensor index, const int64_t dim, const bool sparse_grad, Tensor out)
Definition gather.h:10
Tensor::Shape input_shape_
Definition gather.h:30
Tensor::Strides index_strides_
Definition gather.h:38
DataType index_type_
Definition gather.h:40
Definition generated/include/operator.h:282
Definition generated/include/operator.h:28
infini::rt::TensorView Tensor
Definition tensor.h:8