InfiniOps
Operator Library for Accelerators
Loading...
Searching...
No Matches
topk.h
Go to the documentation of this file.
1#ifndef INFINI_OPS_BASE_TOPK_H_
2#define INFINI_OPS_BASE_TOPK_H_
3
4#include "operator.h"
5
6namespace infini::ops {
7
8class Topk : public Operator<Topk> {
9 public:
10 Topk(const Tensor input, const int64_t k, const int64_t dim,
11 const bool largest, const bool sorted, Tensor values, Tensor indices)
12 : input_shape_{input.shape()},
13 input_strides_{input.strides()},
14 input_type_{input.dtype()},
15 values_shape_{values.shape()},
16 values_strides_{values.strides()},
17 values_type_{values.dtype()},
18 indices_shape_{indices.shape()},
19 indices_strides_{indices.strides()},
20 indices_type_{indices.dtype()},
21 k_{k},
22 dim_{dim},
23 largest_{largest},
24 sorted_{sorted},
25 device_index_{values.device().index()} {}
26
27 virtual void operator()(const Tensor input, const int64_t k,
28 const int64_t dim, const bool largest,
29 const bool sorted, Tensor values,
30 Tensor indices) const = 0;
31
32 protected:
33 Tensor::Shape input_shape_;
34
35 Tensor::Strides input_strides_;
36
37 DataType input_type_;
38
39 Tensor::Shape values_shape_;
40
41 Tensor::Strides values_strides_;
42
43 DataType values_type_;
44
45 Tensor::Shape indices_shape_;
46
47 Tensor::Strides indices_strides_;
48
49 DataType indices_type_;
50
51 int64_t k_{};
52
53 int64_t dim_{};
54
55 bool largest_{};
56
57 bool sorted_{};
58
60};
61
62} // namespace infini::ops
63
64#endif
Definition generated/include/operator.h:282
Definition topk.h:8
Tensor::Shape values_shape_
Definition topk.h:39
Tensor::Shape input_shape_
Definition topk.h:33
DataType input_type_
Definition topk.h:37
DataType indices_type_
Definition topk.h:49
Tensor::Shape indices_shape_
Definition topk.h:45
Tensor::Strides values_strides_
Definition topk.h:41
int64_t k_
Definition topk.h:51
virtual void operator()(const Tensor input, const int64_t k, const int64_t dim, const bool largest, const bool sorted, Tensor values, Tensor indices) const =0
Tensor::Strides indices_strides_
Definition topk.h:47
Tensor::Strides input_strides_
Definition topk.h:35
Topk(const Tensor input, const int64_t k, const int64_t dim, const bool largest, const bool sorted, Tensor values, Tensor indices)
Definition topk.h:10
DataType values_type_
Definition topk.h:43
int64_t dim_
Definition topk.h:53
bool sorted_
Definition topk.h:57
bool largest_
Definition topk.h:55
int device_index_
Definition topk.h:59
Definition generated/include/operator.h:28
infini::rt::TensorView Tensor
Definition tensor.h:8