Skip to content

(release branch only) Revert "Respect selective build for dtype_specialized_elementwise_fn_impl in elementwise_util (#11975)" #12184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release/0.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions kernels/portable/cpu/util/elementwise_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <c10/util/irange.h>
#include <executorch/kernels/portable/cpu/scalar_utils.h>
#include <executorch/kernels/portable/cpu/selective_build.h>
#include <executorch/kernels/portable/cpu/util/broadcast_indexes_range.h>
#include <executorch/kernels/portable/cpu/util/broadcast_util.h>
#include <executorch/kernels/portable/cpu/util/dtype_util.h>
Expand Down Expand Up @@ -319,22 +318,20 @@ inline void apply_elementwise_fn(
}

constexpr auto compute_type = CppTypeToScalarType<CTYPE_COMPUTE>::value;
if constexpr (should_include_kernel_dtype(op_name, compute_type)) {
const bool all_inputs_compute_dtype =
((inputs.first->scalar_type() == compute_type) && ...);

constexpr ScalarType out_specialized_scalar_type =
specialized_output_scalar_type<CTYPE_COMPUTE>(out_dtypes);
if (all_inputs_compute_dtype &&
out.scalar_type() == out_specialized_scalar_type) {
using CTYPE_OUT =
typename ScalarTypeToCppType<out_specialized_scalar_type>::type;
dtype_specialized_elementwise_fn_impl<
CTYPE_COMPUTE,
CTYPE_OUT,
support_noncontiguous_tensors>(compute_fun, ctx, out, inputs...);
return;
}
const bool all_inputs_compute_dtype =
((inputs.first->scalar_type() == compute_type) && ...);

constexpr ScalarType out_specialized_scalar_type =
specialized_output_scalar_type<CTYPE_COMPUTE>(out_dtypes);
if (all_inputs_compute_dtype &&
out.scalar_type() == out_specialized_scalar_type) {
using CTYPE_OUT =
typename ScalarTypeToCppType<out_specialized_scalar_type>::type;
dtype_specialized_elementwise_fn_impl<
CTYPE_COMPUTE,
CTYPE_OUT,
support_noncontiguous_tensors>(compute_fun, ctx, out, inputs...);
return;
}

apply_elementwise_fn_generic_impl<
Expand Down
2 changes: 1 addition & 1 deletion kernels/portable/cpu/util/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ def define_common_targets():
":vectorized_math",
"//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch",
"//executorch/runtime/kernel:kernel_runtime_context",
"//executorch/kernels/portable/cpu:scalar_utils",
"//executorch/extension/threadpool:threadpool",
"//executorch/kernels/portable/cpu:scalar_utils",
],
deps = [
"//executorch/kernels/portable/cpu:scalar_utils",
"//executorch/runtime/kernel:kernel_includes",
],
visibility = ["//executorch/kernels/portable/cpu/...", "//executorch/kernels/optimized/cpu/...", "@EXECUTORCH_CLIENTS"],
Expand Down
Loading