@@ -53,7 +53,7 @@ __ET_NODISCARD bool check_bounds(
53
53
}
54
54
});
55
55
} else if (isFloatingType (out_type)) {
56
- ET_SWITCH_FLOAT_TYPES (out_type, ctx, " clamp" , CTYPE_OUT, [&]() {
56
+ ET_SWITCH_FLOATH_TYPES (out_type, ctx, " clamp" , CTYPE_OUT, [&]() {
57
57
if (std::isfinite (val) &&
58
58
is_out_of_bounds<CTYPE_VAL, CTYPE_OUT, double >(val)) {
59
59
ET_LOG (Error, " %s value out of bounds" , val_name);
@@ -119,7 +119,7 @@ Tensor& clamp_out(
119
119
120
120
ET_KERNEL_CHECK (ctx, common_type == out_type, InvalidArgument, out);
121
121
122
- ET_SWITCH_REAL_TYPES (out_type, ctx, " clamp" , CTYPE_OUT, [&]() {
122
+ ET_SWITCH_REALH_TYPES (out_type, ctx, " clamp" , CTYPE_OUT, [&]() {
123
123
// Extract optional min value
124
124
CTYPE_OUT min = 0 ;
125
125
if (has_min) {
@@ -140,7 +140,7 @@ Tensor& clamp_out(
140
140
});
141
141
}
142
142
143
- ET_SWITCH_REAL_TYPES_AND (Bool, in_type, ctx, " clamp" , CTYPE_IN, [&]() {
143
+ ET_SWITCH_REALHB_TYPES ( in_type, ctx, " clamp" , CTYPE_IN, [&]() {
144
144
apply_unary_map_fn (
145
145
[has_min, min, has_max, max](const CTYPE_IN val_in) {
146
146
CTYPE_OUT val_out = static_cast <CTYPE_OUT>(val_in);
@@ -195,20 +195,20 @@ Tensor& clamp_tensor_out(
195
195
ScalarType out_type = out.scalar_type ();
196
196
197
197
if (has_min) {
198
- common_type = promoteTypes (common_type, min_type);
198
+ common_type = promoteTypes (common_type, min_type, /* half_to_float */ true );
199
199
}
200
200
if (has_max) {
201
- common_type = promoteTypes (common_type, max_type);
201
+ common_type = promoteTypes (common_type, max_type, /* half_to_float */ true );
202
202
}
203
203
204
204
ET_KERNEL_CHECK (ctx, canCast (common_type, out_type), InvalidArgument, out);
205
205
206
206
constexpr auto name = " clamp.Tensor_out" ;
207
207
208
- ET_SWITCH_REALB_TYPES (in_type, ctx, name, CTYPE_IN, [&]() {
209
- ET_SWITCH_REALB_TYPES (min_type, ctx, name, CTYPE_MIN, [&]() {
210
- ET_SWITCH_REALB_TYPES (max_type, ctx, name, CTYPE_MAX, [&]() {
211
- ET_SWITCH_REALB_TYPES (out_type, ctx, name, CTYPE_OUT, [&]() {
208
+ ET_SWITCH_REALHB_TYPES (in_type, ctx, name, CTYPE_IN, [&]() {
209
+ ET_SWITCH_REALHB_TYPES (min_type, ctx, name, CTYPE_MIN, [&]() {
210
+ ET_SWITCH_REALHB_TYPES (max_type, ctx, name, CTYPE_MAX, [&]() {
211
+ ET_SWITCH_REALHB_TYPES (out_type, ctx, name, CTYPE_OUT, [&]() {
212
212
apply_ternary_elementwise_fn<
213
213
CTYPE_IN,
214
214
CTYPE_MIN,
0 commit comments