InfiniOps
Operator Library for Accelerators
Loading...
Searching...
No Matches
clamp_max.h
Go to the documentation of this file.
1#ifndef INFINI_OPS_BASE_CLAMP_MAX_H_
2#define INFINI_OPS_BASE_CLAMP_MAX_H_
3
4#include "operator.h"
5
6namespace infini::ops {
7
8class ClampMax : public Operator<ClampMax> {
9 public:
10 ClampMax(const Tensor input, const double max, Tensor out)
11 : input_shape_{input.shape()},
12 input_strides_{input.strides()},
13 input_type_{input.dtype()},
14 out_shape_{out.shape()},
15 out_strides_{out.strides()},
16 out_type_{out.dtype()},
17 max_{max},
18 device_index_{out.device().index()} {}
19
20 ClampMax(const Tensor input, const Tensor max, Tensor out)
21 : input_shape_{input.shape()},
22 input_strides_{input.strides()},
23 input_type_{input.dtype()},
24 out_shape_{out.shape()},
25 out_strides_{out.strides()},
26 out_type_{out.dtype()},
27 max_shape_{max.shape()},
28 max_strides_{max.strides()},
29 max_type_{max.dtype()},
30 device_index_{out.device().index()} {}
31
34 [[deprecated("Use the explicit-output overload instead.")]]
35 ClampMax(Tensor input, const Tensor max)
36 : input_shape_{input.shape()},
37 input_strides_{input.strides()},
38 input_type_{input.dtype()},
39 max_shape_{max.shape()},
40 max_strides_{max.strides()},
41 max_type_{max.dtype()},
42 device_index_{input.device().index()} {}
43
44 virtual void operator()(const Tensor input, const double max,
45 Tensor out) const = 0;
46
47 virtual void operator()(const Tensor input, const Tensor max,
48 Tensor out) const = 0;
49
52 [[deprecated("Use an explicit-output overload instead.")]]
53 virtual void operator()(Tensor input, const Tensor max) 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 out_shape_;
63
64 Tensor::Strides out_strides_;
65
66 DataType out_type_;
67
68 double max_{};
69
70 Tensor::Shape max_shape_;
71
72 Tensor::Strides max_strides_;
73
74 DataType max_type_;
75
77};
78
79} // namespace infini::ops
80
81#endif
Definition clamp_max.h:8
Tensor::Strides input_strides_
Definition clamp_max.h:58
Tensor::Shape max_shape_
Definition clamp_max.h:70
DataType out_type_
Definition clamp_max.h:66
DataType max_type_
Definition clamp_max.h:74
int device_index_
Definition clamp_max.h:76
double max_
Definition clamp_max.h:68
Tensor::Strides max_strides_
Definition clamp_max.h:72
ClampMax(Tensor input, const Tensor max)
Definition clamp_max.h:35
virtual void operator()(const Tensor input, const double max, Tensor out) const =0
virtual void operator()(Tensor input, const Tensor max) const =0
ClampMax(const Tensor input, const Tensor max, Tensor out)
Definition clamp_max.h:20
Tensor::Strides out_strides_
Definition clamp_max.h:64
Tensor::Shape out_shape_
Definition clamp_max.h:62
DataType input_type_
Definition clamp_max.h:60
Tensor::Shape input_shape_
Definition clamp_max.h:56
ClampMax(const Tensor input, const double max, Tensor out)
Definition clamp_max.h:10
virtual void operator()(const Tensor input, const Tensor max, Tensor out) const =0
Definition generated/include/operator.h:282
Definition generated/include/operator.h:28
infini::rt::TensorView Tensor
Definition tensor.h:8