InfiniOps
Operator Library for Accelerators
Loading...
Searching...
No Matches
index.h
Go to the documentation of this file.
1#ifndef INFINI_OPS_BASE_INDEX_H_
2#define INFINI_OPS_BASE_INDEX_H_
3
4#include <optional>
5#include <vector>
6
7#include "operator.h"
8
9namespace infini::ops {
10
11class Index : public Operator<Index> {
12 public:
13 Index(const Tensor input, const std::vector<std::optional<Tensor>> indices,
14 Tensor out)
15 : input_shape_{input.shape()},
16 input_strides_{input.strides()},
17 input_type_{input.dtype()},
18 indices_{indices},
19 out_shape_{out.shape()},
20 out_strides_{out.strides()},
21 out_type_{out.dtype()},
22 device_index_{out.device().index()} {}
23
24 virtual void operator()(const Tensor input,
25 const std::vector<std::optional<Tensor>> indices,
26 Tensor out) const = 0;
27
28 protected:
29 Tensor::Shape input_shape_;
30
31 Tensor::Strides input_strides_;
32
33 DataType input_type_;
34
35 std::vector<std::optional<Tensor>> indices_{};
36
37 Tensor::Shape out_shape_;
38
39 Tensor::Strides out_strides_;
40
41 DataType out_type_;
42
44};
45
46} // namespace infini::ops
47
48#endif
Definition index.h:11
Index(const Tensor input, const std::vector< std::optional< Tensor > > indices, Tensor out)
Definition index.h:13
std::vector< std::optional< Tensor > > indices_
Definition index.h:35
Tensor::Shape out_shape_
Definition index.h:37
Tensor::Strides input_strides_
Definition index.h:31
Tensor::Shape input_shape_
Definition index.h:29
DataType input_type_
Definition index.h:33
virtual void operator()(const Tensor input, const std::vector< std::optional< Tensor > > indices, Tensor out) const =0
Tensor::Strides out_strides_
Definition index.h:39
DataType out_type_
Definition index.h:41
int device_index_
Definition index.h:43
Definition generated/include/operator.h:282
Definition generated/include/operator.h:28
infini::rt::TensorView Tensor
Definition tensor.h:8