Skip to content

Commit 32fbef9

Browse files
committed
Update
[ghstack-poisoned]
1 parent 67b6009 commit 32fbef9

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

kernels/portable/cpu/op_neg.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
#include <executorch/kernels/portable/cpu/util/functional_util.h>
9+
#include <executorch/kernels/portable/cpu/util/elementwise_util.h>
1010
#include <executorch/runtime/kernel/kernel_includes.h>
1111
#include <executorch/runtime/platform/assert.h>
1212

@@ -33,12 +33,17 @@ Tensor& neg_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
3333
ET_KERNEL_CHECK(
3434
ctx, tensors_have_same_dim_order(in, out), InvalidArgument, out);
3535

36-
ET_SWITCH_REALHBF16_TYPES(in.scalar_type(), ctx, "neg.out", CTYPE, [&] {
37-
apply_unary_map_fn(
38-
[](const CTYPE val_in) { return static_cast<CTYPE>(-val_in); },
39-
in.const_data_ptr<CTYPE>(),
40-
out.mutable_data_ptr<CTYPE>(),
41-
in.numel());
36+
static constexpr const char op_name[] = "neg.out";
37+
ET_SWITCH_REALHBF16_TYPES(in.scalar_type(), ctx, op_name, CTYPE, [&] {
38+
utils::internal::apply_unitensor_elementwise_fn<
39+
CTYPE,
40+
op_name,
41+
utils::SupportedTensorDtypes::SAME_AS_COMMON>(
42+
[](const auto val_in) { return -val_in; },
43+
ctx,
44+
in,
45+
utils::SupportedTensorDtypes::REALHBF16,
46+
out);
4247
});
4348

4449
return out;

shim_et/xplat/executorch/kernels/portable/op_registration_util.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ ATEN_OPS = (
917917
op_target(
918918
name = "op_neg",
919919
deps = [
920-
"//executorch/kernels/portable/cpu/util:functional_util",
920+
"//executorch/kernels/portable/cpu/util:elementwise_util",
921921
],
922922
),
923923
op_target(

0 commit comments

Comments
 (0)