|
| 1 | +#ifndef INFINI_OPS_BASE_SEARCHSORTED_H_ |
| 2 | +#define INFINI_OPS_BASE_SEARCHSORTED_H_ |
| 3 | + |
| 4 | +#include "operator.h" |
| 5 | + |
| 6 | +namespace infini::ops { |
| 7 | + |
| 8 | +class Searchsorted : public Operator<Searchsorted> { |
| 9 | + public: |
| 10 | + Searchsorted(const Tensor sorted_sequence, const Tensor input, |
| 11 | + const bool out_int32, const bool right, Tensor out) |
| 12 | + : sorted_sequence_shape_{sorted_sequence.shape()}, |
| 13 | + sorted_sequence_strides_{sorted_sequence.strides()}, |
| 14 | + sorted_sequence_type_{sorted_sequence.dtype()}, |
| 15 | + input_shape_{input.shape()}, |
| 16 | + input_strides_{input.strides()}, |
| 17 | + input_type_{input.dtype()}, |
| 18 | + out_shape_{out.shape()}, |
| 19 | + out_strides_{out.strides()}, |
| 20 | + out_type_{out.dtype()}, |
| 21 | + out_int32_{out_int32}, |
| 22 | + right_{right}, |
| 23 | + device_index_{out.device().index()} {} |
| 24 | + |
| 25 | + Searchsorted(const Tensor sorted_sequence, const double input, |
| 26 | + const bool out_int32, const bool right, Tensor out) |
| 27 | + : sorted_sequence_shape_{sorted_sequence.shape()}, |
| 28 | + sorted_sequence_strides_{sorted_sequence.strides()}, |
| 29 | + sorted_sequence_type_{sorted_sequence.dtype()}, |
| 30 | + out_shape_{out.shape()}, |
| 31 | + out_strides_{out.strides()}, |
| 32 | + out_type_{out.dtype()}, |
| 33 | + out_int32_{out_int32}, |
| 34 | + right_{right}, |
| 35 | + input_{input}, |
| 36 | + device_index_{out.device().index()} {} |
| 37 | + |
| 38 | + virtual void operator()(const Tensor sorted_sequence, const Tensor input, |
| 39 | + const bool out_int32, const bool right, |
| 40 | + Tensor out) const = 0; |
| 41 | + |
| 42 | + virtual void operator()(const Tensor sorted_sequence, const double input, |
| 43 | + const bool out_int32, const bool right, |
| 44 | + Tensor out) const = 0; |
| 45 | + |
| 46 | + protected: |
| 47 | + Tensor::Shape sorted_sequence_shape_; |
| 48 | + |
| 49 | + Tensor::Strides sorted_sequence_strides_; |
| 50 | + |
| 51 | + DataType sorted_sequence_type_; |
| 52 | + |
| 53 | + Tensor::Shape input_shape_; |
| 54 | + |
| 55 | + Tensor::Strides input_strides_; |
| 56 | + |
| 57 | + DataType input_type_; |
| 58 | + |
| 59 | + Tensor::Shape out_shape_; |
| 60 | + |
| 61 | + Tensor::Strides out_strides_; |
| 62 | + |
| 63 | + DataType out_type_; |
| 64 | + |
| 65 | + bool out_int32_{}; |
| 66 | + |
| 67 | + bool right_{}; |
| 68 | + |
| 69 | + double input_{}; |
| 70 | + |
| 71 | + int device_index_{0}; |
| 72 | +}; |
| 73 | + |
| 74 | +} // namespace infini::ops |
| 75 | + |
| 76 | +#endif |
0 commit comments