InfiniOps
Operator Library for Accelerators
Loading...
Searching...
No Matches
nan_to_num.h
Go to the documentation of this file.
1#ifndef INFINI_OPS_BASE_NAN_TO_NUM_H_
2#define INFINI_OPS_BASE_NAN_TO_NUM_H_
3
4#include <optional>
5
6#include "operator.h"
7
8namespace infini::ops {
9
10class NanToNum : public Operator<NanToNum> {
11 public:
12 NanToNum(const Tensor input, const std::optional<double> nan,
13 const std::optional<double> posinf,
14 const std::optional<double> neginf, Tensor out)
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 nan_{nan},
22 posinf_{posinf},
23 neginf_{neginf},
24 device_index_{out.device().index()} {}
25
26 virtual void operator()(const Tensor input, const std::optional<double> nan,
27 const std::optional<double> posinf,
28 const std::optional<double> neginf,
29 Tensor out) const = 0;
30
31 protected:
32 Tensor::Shape input_shape_;
33
34 Tensor::Strides input_strides_;
35
36 DataType input_type_;
37
38 Tensor::Shape out_shape_;
39
40 Tensor::Strides out_strides_;
41
42 DataType out_type_;
43
44 std::optional<double> nan_{};
45
46 std::optional<double> posinf_{};
47
48 std::optional<double> neginf_{};
49
51};
52
53} // namespace infini::ops
54
55#endif
Definition nan_to_num.h:10
std::optional< double > posinf_
Definition nan_to_num.h:46
NanToNum(const Tensor input, const std::optional< double > nan, const std::optional< double > posinf, const std::optional< double > neginf, Tensor out)
Definition nan_to_num.h:12
Tensor::Shape input_shape_
Definition nan_to_num.h:32
Tensor::Strides input_strides_
Definition nan_to_num.h:34
Tensor::Shape out_shape_
Definition nan_to_num.h:38
virtual void operator()(const Tensor input, const std::optional< double > nan, const std::optional< double > posinf, const std::optional< double > neginf, Tensor out) const =0
Tensor::Strides out_strides_
Definition nan_to_num.h:40
DataType input_type_
Definition nan_to_num.h:36
std::optional< double > nan_
Definition nan_to_num.h:44
std::optional< double > neginf_
Definition nan_to_num.h:48
int device_index_
Definition nan_to_num.h:50
DataType out_type_
Definition nan_to_num.h:42
Definition generated/include/operator.h:282
Definition generated/include/operator.h:28
infini::rt::TensorView Tensor
Definition tensor.h:8