InfiniOps
Operator Library for Accelerators
Loading...
Searching...
No Matches
index_reduce.h
Go to the documentation of this file.
1#ifndef INFINI_OPS_BASE_INDEX_REDUCE_H_
2#define INFINI_OPS_BASE_INDEX_REDUCE_H_
3
4#include <string>
5
6#include "operator.h"
7
8namespace infini::ops {
9
10class IndexReduce : public Operator<IndexReduce> {
11 public:
12 IndexReduce(const Tensor input, const Tensor index, const Tensor source,
13 const int64_t dim, const std::string reduce,
14 const bool include_self, Tensor out)
15 : input_shape_{input.shape()},
16 input_strides_{input.strides()},
17 input_type_{input.dtype()},
18 index_shape_{index.shape()},
19 index_strides_{index.strides()},
20 index_type_{index.dtype()},
21 source_shape_{source.shape()},
22 source_strides_{source.strides()},
23 source_type_{source.dtype()},
24 out_shape_{out.shape()},
25 out_strides_{out.strides()},
26 out_type_{out.dtype()},
27 dim_{dim},
28 reduce_{reduce},
29 include_self_{include_self},
30 device_index_{out.device().index()} {}
31
32 virtual void operator()(const Tensor input, const Tensor index,
33 const Tensor source, const int64_t dim,
34 const std::string reduce, const bool include_self,
35 Tensor out) const = 0;
36
37 protected:
38 Tensor::Shape input_shape_;
39
40 Tensor::Strides input_strides_;
41
42 DataType input_type_;
43
44 Tensor::Shape index_shape_;
45
46 Tensor::Strides index_strides_;
47
48 DataType index_type_;
49
50 Tensor::Shape source_shape_;
51
52 Tensor::Strides source_strides_;
53
54 DataType source_type_;
55
56 Tensor::Shape out_shape_;
57
58 Tensor::Strides out_strides_;
59
60 DataType out_type_;
61
62 int64_t dim_{};
63
64 std::string reduce_{};
65
67
69};
70
71} // namespace infini::ops
72
73#endif
Definition index_reduce.h:10
Tensor::Shape input_shape_
Definition index_reduce.h:38
int device_index_
Definition index_reduce.h:68
Tensor::Shape out_shape_
Definition index_reduce.h:56
DataType source_type_
Definition index_reduce.h:54
IndexReduce(const Tensor input, const Tensor index, const Tensor source, const int64_t dim, const std::string reduce, const bool include_self, Tensor out)
Definition index_reduce.h:12
DataType index_type_
Definition index_reduce.h:48
Tensor::Strides index_strides_
Definition index_reduce.h:46
DataType out_type_
Definition index_reduce.h:60
std::string reduce_
Definition index_reduce.h:64
Tensor::Shape source_shape_
Definition index_reduce.h:50
DataType input_type_
Definition index_reduce.h:42
bool include_self_
Definition index_reduce.h:66
Tensor::Strides source_strides_
Definition index_reduce.h:52
Tensor::Strides input_strides_
Definition index_reduce.h:40
virtual void operator()(const Tensor input, const Tensor index, const Tensor source, const int64_t dim, const std::string reduce, const bool include_self, Tensor out) const =0
Tensor::Shape index_shape_
Definition index_reduce.h:44
Tensor::Strides out_strides_
Definition index_reduce.h:58
int64_t dim_
Definition index_reduce.h:62
Definition generated/include/operator.h:282
Definition generated/include/operator.h:28
infini::rt::TensorView Tensor
Definition tensor.h:8