Skip to content

Commit c6c3616

Browse files
Revert vectorization stack (#11536)
### Summary These broke some internal tests. @swolchok said to just revert and he would try again ### Test plan ci
1 parent 2dda7a2 commit c6c3616

Some content is hidden

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

70 files changed

+328
-959
lines changed

.lintrunner.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,6 @@ exclude_patterns = [
271271
'examples/**',
272272
'exir/verification/bindings.cpp',
273273
'extension/**',
274-
# Uses properly-gated (ET_USE_PYTORCH_HEADERS) ATen include.
275-
'kernels/portable/cpu/util/elementwise_util.h',
276-
'kernels/portable/cpu/util/math_util.h',
277-
'kernels/portable/cpu/util/vectorized_math.h',
278274
'kernels/optimized/**',
279275
'runtime/core/exec_aten/**',
280276
# Want to be able to keep c10 in sync with PyTorch core.

kernels/portable/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,8 @@ if(EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
6969
target_compile_options(optimized_portable_kernels PUBLIC ${_common_compile_options})
7070
target_include_directories(optimized_portable_kernels PRIVATE ${TORCH_INCLUDE_DIRS})
7171
target_compile_definitions(optimized_portable_kernels PRIVATE ET_USE_PYTORCH_HEADERS)
72-
gen_selected_ops(LIB_NAME "optimized_portable_ops_lib" OPS_SCHEMA_YAML "${_yaml}")
73-
generate_bindings_for_kernels(
74-
LIB_NAME "optimized_portable_ops_lib" FUNCTIONS_YAML "${_yaml}"
75-
)
76-
gen_operators_lib(
77-
LIB_NAME "optimized_portable_ops_lib" KERNEL_LIBS optimized_portable_kernels DEPS executorch_core
78-
)
7972
install(
80-
TARGETS optimized_portable_kernels optimized_portable_ops_lib
73+
TARGETS optimized_portable_kernels
8174
DESTINATION lib
8275
)
8376
endif()

kernels/portable/cpu/op_acos.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ namespace executor {
1515
namespace native {
1616

1717
Tensor& acos_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
18-
static constexpr const char op_name[] = "acos.out";
19-
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
20-
[](auto x) { return executorch::math::acos(x); }, ctx, in, out);
18+
return internal::unary_ufunc_realhbbf16_to_floathbf16(
19+
std::acos, ctx, in, out);
2120
}
2221

2322
} // namespace native

kernels/portable/cpu/op_acosh.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ namespace executor {
1515
namespace native {
1616

1717
Tensor& acosh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
18-
static constexpr const char op_name[] = "acosh.out";
19-
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
20-
[](auto x) { return executorch::math::acosh(x); }, ctx, in, out);
18+
return internal::unary_ufunc_realhbbf16_to_floathbf16(
19+
std::acosh, ctx, in, out);
2120
}
2221

2322
} // namespace native

kernels/portable/cpu/op_add.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,14 @@ Tensor& add_scalar_out(
102102
static constexpr const char op_name[] = "add.Scalar_out";
103103

104104
ET_SWITCH_REALB_TYPES(compute_type, ctx, op_name, CTYPE_COMPUTE, [&]() {
105-
CTYPE_COMPUTE val_b = utils::scalar_to<CTYPE_COMPUTE>(b);
106-
CTYPE_COMPUTE val_alpha = utils::scalar_to<CTYPE_COMPUTE>(alpha);
107-
auto val_alpha_times_b = val_alpha * val_b;
108105
utils::apply_unitensor_elementwise_fn<
109106
CTYPE_COMPUTE,
110107
op_name,
111108
utils::SupportedTensorDtypes::SAME_AS_COMMON>(
112-
[val_alpha_times_b](const auto val_a) {
113-
// Cast here supports vectorization; either it does nothing
114-
// or it casts from CTYPE_COMPUTE to
115-
// Vectorized<CTYPE_COMPUTE>.
116-
return val_a + decltype(val_a)(val_alpha_times_b);
109+
[b, alpha](const auto val_a) {
110+
CTYPE_COMPUTE val_b = utils::scalar_to<CTYPE_COMPUTE>(b);
111+
CTYPE_COMPUTE val_alpha = utils::scalar_to<CTYPE_COMPUTE>(alpha);
112+
return val_a + val_alpha * val_b;
117113
},
118114
ctx,
119115
a,

kernels/portable/cpu/op_asin.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ namespace executor {
1515
namespace native {
1616

1717
Tensor& asin_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
18-
static constexpr const char op_name[] = "asin.out";
19-
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
20-
[](auto x) { return executorch::math::asin(x); }, ctx, in, out);
18+
return internal::unary_ufunc_realhbbf16_to_floathbf16(
19+
std::asin, ctx, in, out);
2120
}
2221

2322
} // namespace native

kernels/portable/cpu/op_asinh.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ namespace executor {
1515
namespace native {
1616

1717
Tensor& asinh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
18-
static constexpr const char op_name[] = "asinh.out";
19-
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
20-
[](auto x) { return executorch::math::asinh(x); }, ctx, in, out);
18+
return internal::unary_ufunc_realhbbf16_to_floathbf16(
19+
std::asinh, ctx, in, out);
2120
}
2221

2322
} // namespace native

kernels/portable/cpu/op_atan.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ namespace executor {
1515
namespace native {
1616

1717
Tensor& atan_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
18-
static constexpr const char op_name[] = "atan.out";
19-
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
20-
[](auto x) { return executorch::math::atan(x); }, ctx, in, out);
18+
return internal::unary_ufunc_realhbbf16_to_floathbf16(
19+
std::atan, ctx, in, out);
2120
}
2221

2322
} // namespace native

kernels/portable/cpu/op_atan2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Tensor& atan2_out(
6060
op_name,
6161
utils::SupportedTensorDtypes::FLOATHBF16>(
6262
[](const auto val_a, const auto val_b) {
63-
return executorch::math::atan2(val_a, val_b);
63+
return std::atan2(val_a, val_b);
6464
},
6565
ctx,
6666
a,

kernels/portable/cpu/op_atanh.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ namespace executor {
1515
namespace native {
1616

1717
Tensor& atanh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
18-
static constexpr const char op_name[] = "atanh.out";
19-
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
20-
[](auto x) { return executorch::math::atanh(x); }, ctx, in, out);
18+
return internal::unary_ufunc_realhbbf16_to_floathbf16(
19+
std::atanh, ctx, in, out);
2120
}
2221

2322
} // namespace native

0 commit comments

Comments
 (0)