|
| 1 | +#ifndef INFINI_OPS_BASE_MEDIAN_H_ |
| 2 | +#define INFINI_OPS_BASE_MEDIAN_H_ |
| 3 | + |
| 4 | +#include "operator.h" |
| 5 | + |
| 6 | +namespace infini::ops { |
| 7 | + |
| 8 | +class Median : public Operator<Median> { |
| 9 | + public: |
| 10 | + Median(const Tensor input, const int64_t dim, const bool keepdim, |
| 11 | + 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 | + dim_{dim}, |
| 22 | + keepdim_{keepdim}, |
| 23 | + device_index_{values.device().index()} {} |
| 24 | + |
| 25 | + virtual void operator()(const Tensor input, const int64_t dim, |
| 26 | + const bool keepdim, Tensor values, |
| 27 | + Tensor indices) const = 0; |
| 28 | + |
| 29 | + protected: |
| 30 | + Tensor::Shape input_shape_; |
| 31 | + |
| 32 | + Tensor::Strides input_strides_; |
| 33 | + |
| 34 | + DataType input_type_; |
| 35 | + |
| 36 | + Tensor::Shape values_shape_; |
| 37 | + |
| 38 | + Tensor::Strides values_strides_; |
| 39 | + |
| 40 | + DataType values_type_; |
| 41 | + |
| 42 | + Tensor::Shape indices_shape_; |
| 43 | + |
| 44 | + Tensor::Strides indices_strides_; |
| 45 | + |
| 46 | + DataType indices_type_; |
| 47 | + |
| 48 | + int64_t dim_{}; |
| 49 | + |
| 50 | + bool keepdim_{}; |
| 51 | + |
| 52 | + int device_index_{0}; |
| 53 | +}; |
| 54 | + |
| 55 | +} // namespace infini::ops |
| 56 | + |
| 57 | +#endif |
0 commit comments