|
| 1 | +#ifndef INFINI_OPS_BASE_MASKED_SELECT_H_ |
| 2 | +#define INFINI_OPS_BASE_MASKED_SELECT_H_ |
| 3 | + |
| 4 | +#include "operator.h" |
| 5 | + |
| 6 | +namespace infini::ops { |
| 7 | + |
| 8 | +class MaskedSelect : public Operator<MaskedSelect> { |
| 9 | + public: |
| 10 | + MaskedSelect(const Tensor input, const Tensor mask, Tensor out) |
| 11 | + : input_shape_{input.shape()}, |
| 12 | + input_strides_{input.strides()}, |
| 13 | + input_type_{input.dtype()}, |
| 14 | + mask_shape_{mask.shape()}, |
| 15 | + mask_strides_{mask.strides()}, |
| 16 | + mask_type_{mask.dtype()}, |
| 17 | + out_shape_{out.shape()}, |
| 18 | + out_strides_{out.strides()}, |
| 19 | + out_type_{out.dtype()}, |
| 20 | + device_index_{out.device().index()} {} |
| 21 | + |
| 22 | + virtual void operator()(const Tensor input, const Tensor mask, |
| 23 | + Tensor out) const = 0; |
| 24 | + |
| 25 | + protected: |
| 26 | + Tensor::Shape input_shape_; |
| 27 | + |
| 28 | + Tensor::Strides input_strides_; |
| 29 | + |
| 30 | + DataType input_type_; |
| 31 | + |
| 32 | + Tensor::Shape mask_shape_; |
| 33 | + |
| 34 | + Tensor::Strides mask_strides_; |
| 35 | + |
| 36 | + DataType mask_type_; |
| 37 | + |
| 38 | + Tensor::Shape out_shape_; |
| 39 | + |
| 40 | + Tensor::Strides out_strides_; |
| 41 | + |
| 42 | + DataType out_type_; |
| 43 | + |
| 44 | + int device_index_{0}; |
| 45 | +}; |
| 46 | + |
| 47 | +} // namespace infini::ops |
| 48 | + |
| 49 | +#endif |
0 commit comments