InfiniOps
Operator Library for Accelerators
Loading...
Searching...
No Matches
kthvalue.h
Go to the documentation of this file.
1#ifndef INFINI_OPS_BASE_KTHVALUE_H_
2#define INFINI_OPS_BASE_KTHVALUE_H_
3
4#include "operator.h"
5
6namespace infini::ops {
7
8class Kthvalue : public Operator<Kthvalue> {
9 public:
10 Kthvalue(const Tensor input, const int64_t k, const int64_t dim,
11 const bool keepdim, 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 keepdim_{keepdim},
24 device_index_{values.device().index()} {}
25
26 virtual void operator()(const Tensor input, const int64_t k,
27 const int64_t dim, const bool keepdim, Tensor values,
28 Tensor indices) const = 0;
29
30 protected:
31 Tensor::Shape input_shape_;
32
33 Tensor::Strides input_strides_;
34
35 DataType input_type_;
36
37 Tensor::Shape values_shape_;
38
39 Tensor::Strides values_strides_;
40
41 DataType values_type_;
42
43 Tensor::Shape indices_shape_;
44
45 Tensor::Strides indices_strides_;
46
47 DataType indices_type_;
48
49 int64_t k_{};
50
51 int64_t dim_{};
52
53 bool keepdim_{};
54
56};
57
58} // namespace infini::ops
59
60#endif
Definition kthvalue.h:8
Kthvalue(const Tensor input, const int64_t k, const int64_t dim, const bool keepdim, Tensor values, Tensor indices)
Definition kthvalue.h:10
Tensor::Strides input_strides_
Definition kthvalue.h:33
Tensor::Strides values_strides_
Definition kthvalue.h:39
bool keepdim_
Definition kthvalue.h:53
int64_t dim_
Definition kthvalue.h:51
DataType indices_type_
Definition kthvalue.h:47
Tensor::Strides indices_strides_
Definition kthvalue.h:45
int device_index_
Definition kthvalue.h:55
Tensor::Shape values_shape_
Definition kthvalue.h:37
int64_t k_
Definition kthvalue.h:49
DataType input_type_
Definition kthvalue.h:35
Tensor::Shape indices_shape_
Definition kthvalue.h:43
DataType values_type_
Definition kthvalue.h:41
virtual void operator()(const Tensor input, const int64_t k, const int64_t dim, const bool keepdim, Tensor values, Tensor indices) const =0
Tensor::Shape input_shape_
Definition kthvalue.h:31
Definition generated/include/operator.h:282
Definition generated/include/operator.h:28
infini::rt::TensorView Tensor
Definition tensor.h:8