Skip to content

Commit 9ebe603

Browse files
committed
ET use compiler macros in ops
Pull Request resolved: #13638 Use new compiler macros to fix operator library builds. Additional issues, isnan and signbit supported types are only on float, double and long double. Apply static cast to avoid msvc compiler error. Differential Revision: [D78854136](https://our.internmc.facebook.com/intern/diff/D78854136/) ghstack-source-id: 305793447
1 parent e89006e commit 9ebe603

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+105
-102
lines changed

kernels/portable/cpu/op_add.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Tensor& add_out(
4949
ScalarType compute_type = utils::get_compute_type(common_type);
5050

5151
// @lint-ignore CLANGTIDY facebook-hte-CArray
52-
static constexpr const char op_name[] = "add.out";
52+
static ET_OP_NAME_SPECIFIER const char op_name[] = "add.out";
5353

5454
if (executorch::runtime::isComplexType(a.scalar_type()) ||
5555
executorch::runtime::isComplexType(b.scalar_type()) ||
@@ -125,7 +125,7 @@ Tensor& add_scalar_out(
125125
ScalarType compute_type = utils::get_compute_type(common_type);
126126

127127
// @lint-ignore CLANGTIDY facebook-hte-CArray
128-
static constexpr const char op_name[] = "add.Scalar_out";
128+
static ET_OP_NAME_SPECIFIER const char op_name[] = "add.Scalar_out";
129129

130130
ET_SWITCH_REALB_TYPES(compute_type, ctx, op_name, CTYPE_COMPUTE, [&]() {
131131
CTYPE_COMPUTE val_b = utils::scalar_to<CTYPE_COMPUTE>(b);

kernels/portable/cpu/op_addmm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Tensor& addmm_out(
5454
ET_KERNEL_CHECK(ctx, tensor_is_default_dim_order(in), InvalidArgument, out);
5555

5656
// @lint-ignore CLANGTIDY facebook-hte-CArray
57-
static constexpr const char op_name[] = "addmm.out";
57+
static ET_OP_NAME_SPECIFIER const char op_name[] = "addmm.out";
5858

5959
ET_SWITCH_REALHBF16_TYPES(in.scalar_type(), ctx, op_name, CTYPE, [&]() {
6060
CTYPE alpha_val = utils::scalar_to<CTYPE>(alpha);

kernels/portable/cpu/op_amax.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Tensor& amax_out(
5555
for (const auto out_ix : c10::irange(begin, end)) {
5656
out_data[out_ix] = plan.execute<CTYPE>(
5757
[](CTYPE v, CTYPE max_v) {
58-
return std::isnan(v) || v > max_v ? v : max_v;
58+
return std::isnan(static_cast<float>(v)) || v > max_v ? v : max_v;
5959
},
6060
out_ix);
6161
}

kernels/portable/cpu/op_amin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Tensor& amin_out(
5454
for (const auto out_ix : c10::irange(begin, end)) {
5555
out_data[out_ix] = plan.execute<CTYPE>(
5656
[](CTYPE v, CTYPE min_v) {
57-
return std::isnan(v) || v < min_v ? v : min_v;
57+
return std::isnan(static_cast<float>(v)) || v < min_v ? v : min_v;
5858
},
5959
out_ix);
6060
}

kernels/portable/cpu/op_argmax.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Tensor& argmax_out(
5858
// the below condition as written is equivalent to
5959
// !isnan(accval) && (isnan(v) || v > acc_val). See
6060
// argument in op_argmin.cpp.
61-
if (!std::isnan(acc_val) && !(v <= acc_val)) {
61+
if (!std::isnan(static_cast<float>(acc_val)) && !(v <= acc_val)) {
6262
acc_val = v;
6363
acc_ix = ix;
6464
}

kernels/portable/cpu/op_argmin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Tensor& argmin_out(
6565
// - false, so the result is true. The result is trivially
6666
// - true for the above condition that uses isnan(v) as
6767
// - well.
68-
if (!std::isnan(acc_val) && !(v >= acc_val)) {
68+
if (!std::isnan(static_cast<float>(acc_val)) && !(v >= acc_val)) {
6969
acc_val = v;
7070
acc_ix = ix;
7171
}

kernels/portable/cpu/op_atan2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Tensor& atan2_out(
5252
ScalarType compute_type = utils::get_compute_type(common_type);
5353

5454
// @lint-ignore CLANGTIDY facebook-hte-CArray
55-
static constexpr const char op_name[] = "atan2.out";
55+
static ET_OP_NAME_SPECIFIER const char op_name[] = "atan2.out";
5656

5757
ET_SWITCH_FLOAT_TYPES(compute_type, ctx, op_name, CTYPE_COMPUTE, [&]() {
5858
utils::apply_bitensor_elementwise_fn<

kernels/portable/cpu/op_bitwise_and.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Tensor& bitwise_and_Tensor_out(
2020
const Tensor& b,
2121
Tensor& out) {
2222
// @lint-ignore CLANGTIDY facebook-hte-CArray
23-
static constexpr const char op_name[] = "bitwise_and.Tensor_out";
23+
static ET_OP_NAME_SPECIFIER const char op_name[] = "bitwise_and.Tensor_out";
2424
return internal::bitwise_tensor_out<std::bit_and, op_name>(ctx, a, b, out);
2525
}
2626

@@ -30,7 +30,7 @@ Tensor& bitwise_and_Scalar_out(
3030
const Scalar& b,
3131
Tensor& out) {
3232
// @lint-ignore CLANGTIDY facebook-hte-CArray
33-
static constexpr const char op_name[] = "bitwise_and.Scalar_out";
33+
static ET_OP_NAME_SPECIFIER const char op_name[] = "bitwise_and.Scalar_out";
3434
return internal::bitwise_scalar_out<std::bit_and, op_name>(ctx, a, b, out);
3535
}
3636

kernels/portable/cpu/op_bitwise_or.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Tensor& bitwise_or_Tensor_out(
2020
const Tensor& b,
2121
Tensor& out) {
2222
// @lint-ignore CLANGTIDY facebook-hte-CArray
23-
static constexpr const char op_name[] = "bitwise_or.Tensor_out";
23+
static ET_OP_NAME_SPECIFIER const char op_name[] = "bitwise_or.Tensor_out";
2424
return internal::bitwise_tensor_out<std::bit_or, op_name>(ctx, a, b, out);
2525
}
2626

@@ -30,7 +30,7 @@ Tensor& bitwise_or_Scalar_out(
3030
const Scalar& b,
3131
Tensor& out) {
3232
// @lint-ignore CLANGTIDY facebook-hte-CArray
33-
static constexpr const char op_name[] = "bitwise_or.Scalar_out";
33+
static ET_OP_NAME_SPECIFIER const char op_name[] = "bitwise_or.Scalar_out";
3434
return internal::bitwise_scalar_out<std::bit_or, op_name>(ctx, a, b, out);
3535
}
3636

kernels/portable/cpu/op_bitwise_xor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Tensor& bitwise_xor_Tensor_out(
2020
const Tensor& b,
2121
Tensor& out) {
2222
// @lint-ignore CLANGTIDY facebook-hte-CArray
23-
static constexpr const char op_name[] = "bitwise_xor.Tensor_out";
23+
static ET_OP_NAME_SPECIFIER const char op_name[] = "bitwise_xor.Tensor_out";
2424
return internal::bitwise_tensor_out<std::bit_xor, op_name>(ctx, a, b, out);
2525
}
2626

@@ -30,7 +30,7 @@ Tensor& bitwise_xor_Scalar_out(
3030
const Scalar& b,
3131
Tensor& out) {
3232
// @lint-ignore CLANGTIDY facebook-hte-CArray
33-
static constexpr const char op_name[] = "bitwise_xor.Scalar_out";
33+
static ET_OP_NAME_SPECIFIER const char op_name[] = "bitwise_xor.Scalar_out";
3434
return internal::bitwise_scalar_out<std::bit_xor, op_name>(ctx, a, b, out);
3535
}
3636

0 commit comments

Comments
 (0)