|
| 1 | +#ifndef INFINI_OPS_BASE_WHERE_H_ |
| 2 | +#define INFINI_OPS_BASE_WHERE_H_ |
| 3 | + |
| 4 | +#include "operator.h" |
| 5 | + |
| 6 | +namespace infini::ops { |
| 7 | + |
| 8 | +class Where : public Operator<Where> { |
| 9 | + public: |
| 10 | + Where(const Tensor condition, const Tensor input, const Tensor other, |
| 11 | + Tensor out) |
| 12 | + : condition_shape_{condition.shape()}, |
| 13 | + condition_strides_{condition.strides()}, |
| 14 | + condition_type_{condition.dtype()}, |
| 15 | + input_shape_{input.shape()}, |
| 16 | + input_strides_{input.strides()}, |
| 17 | + input_type_{input.dtype()}, |
| 18 | + other_shape_{other.shape()}, |
| 19 | + other_strides_{other.strides()}, |
| 20 | + other_type_{other.dtype()}, |
| 21 | + out_shape_{out.shape()}, |
| 22 | + out_strides_{out.strides()}, |
| 23 | + out_type_{out.dtype()}, |
| 24 | + device_index_{out.device().index()} {} |
| 25 | + |
| 26 | + virtual void operator()(const Tensor condition, const Tensor input, |
| 27 | + const Tensor other, Tensor out) const = 0; |
| 28 | + |
| 29 | + protected: |
| 30 | + Tensor::Shape condition_shape_; |
| 31 | + |
| 32 | + Tensor::Strides condition_strides_; |
| 33 | + |
| 34 | + DataType condition_type_; |
| 35 | + |
| 36 | + Tensor::Shape input_shape_; |
| 37 | + |
| 38 | + Tensor::Strides input_strides_; |
| 39 | + |
| 40 | + DataType input_type_; |
| 41 | + |
| 42 | + Tensor::Shape other_shape_; |
| 43 | + |
| 44 | + Tensor::Strides other_strides_; |
| 45 | + |
| 46 | + DataType other_type_; |
| 47 | + |
| 48 | + Tensor::Shape out_shape_; |
| 49 | + |
| 50 | + Tensor::Strides out_strides_; |
| 51 | + |
| 52 | + DataType out_type_; |
| 53 | + |
| 54 | + int device_index_{0}; |
| 55 | +}; |
| 56 | + |
| 57 | +} // namespace infini::ops |
| 58 | + |
| 59 | +#endif |
0 commit comments