|
| 1 | +#ifndef INFINI_OPS_BASE_MIN_H_ |
| 2 | +#define INFINI_OPS_BASE_MIN_H_ |
| 3 | + |
| 4 | +#include "operator.h" |
| 5 | + |
| 6 | +namespace infini::ops { |
| 7 | + |
| 8 | +class Min : public Operator<Min> { |
| 9 | + public: |
| 10 | + Min(const Tensor input, const Tensor other, Tensor out) |
| 11 | + : input_shape_{input.shape()}, |
| 12 | + input_strides_{input.strides()}, |
| 13 | + input_type_{input.dtype()}, |
| 14 | + other_shape_{other.shape()}, |
| 15 | + other_strides_{other.strides()}, |
| 16 | + other_type_{other.dtype()}, |
| 17 | + out_shape_{out.shape()}, |
| 18 | + out_strides_{out.strides()}, |
| 19 | + out_type_{out.dtype()}, |
| 20 | + device_index_{out.device().index()} {} |
| 21 | + |
| 22 | + Min(const Tensor input, const int64_t dim, const bool keepdim, Tensor min, |
| 23 | + Tensor min_indices) |
| 24 | + : input_shape_{input.shape()}, |
| 25 | + input_strides_{input.strides()}, |
| 26 | + input_type_{input.dtype()}, |
| 27 | + min_shape_{min.shape()}, |
| 28 | + min_strides_{min.strides()}, |
| 29 | + min_type_{min.dtype()}, |
| 30 | + min_indices_shape_{min_indices.shape()}, |
| 31 | + min_indices_strides_{min_indices.strides()}, |
| 32 | + min_indices_type_{min_indices.dtype()}, |
| 33 | + dim_{dim}, |
| 34 | + keepdim_{keepdim}, |
| 35 | + device_index_{min.device().index()} {} |
| 36 | + |
| 37 | + Min(const Tensor input, Tensor out) |
| 38 | + : input_shape_{input.shape()}, |
| 39 | + input_strides_{input.strides()}, |
| 40 | + input_type_{input.dtype()}, |
| 41 | + out_shape_{out.shape()}, |
| 42 | + out_strides_{out.strides()}, |
| 43 | + out_type_{out.dtype()}, |
| 44 | + device_index_{out.device().index()} {} |
| 45 | + |
| 46 | + virtual void operator()(const Tensor input, const Tensor other, |
| 47 | + Tensor out) const = 0; |
| 48 | + |
| 49 | + virtual void operator()(const Tensor input, const int64_t dim, |
| 50 | + const bool keepdim, Tensor min, |
| 51 | + Tensor min_indices) const = 0; |
| 52 | + |
| 53 | + virtual void operator()(const Tensor input, Tensor out) const = 0; |
| 54 | + |
| 55 | + protected: |
| 56 | + Tensor::Shape input_shape_; |
| 57 | + |
| 58 | + Tensor::Strides input_strides_; |
| 59 | + |
| 60 | + DataType input_type_; |
| 61 | + |
| 62 | + Tensor::Shape other_shape_; |
| 63 | + |
| 64 | + Tensor::Strides other_strides_; |
| 65 | + |
| 66 | + DataType other_type_; |
| 67 | + |
| 68 | + Tensor::Shape out_shape_; |
| 69 | + |
| 70 | + Tensor::Strides out_strides_; |
| 71 | + |
| 72 | + DataType out_type_; |
| 73 | + |
| 74 | + Tensor::Shape min_shape_; |
| 75 | + |
| 76 | + Tensor::Strides min_strides_; |
| 77 | + |
| 78 | + DataType min_type_; |
| 79 | + |
| 80 | + Tensor::Shape min_indices_shape_; |
| 81 | + |
| 82 | + Tensor::Strides min_indices_strides_; |
| 83 | + |
| 84 | + DataType min_indices_type_; |
| 85 | + |
| 86 | + int64_t dim_{}; |
| 87 | + |
| 88 | + bool keepdim_{}; |
| 89 | + |
| 90 | + int device_index_{0}; |
| 91 | +}; |
| 92 | + |
| 93 | +} // namespace infini::ops |
| 94 | + |
| 95 | +#endif |
0 commit comments