Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
31a49e0
Update
swolchok Mar 19, 2025
9fcd885
Update
swolchok Mar 19, 2025
29d6de9
Update
swolchok Mar 19, 2025
79b908c
Update
swolchok Mar 19, 2025
fd62a07
Update
swolchok Mar 19, 2025
854c991
Update
swolchok Mar 19, 2025
def7ed4
Update
swolchok Mar 19, 2025
40c1b1b
Update
swolchok Mar 19, 2025
7c78357
Update
swolchok Mar 19, 2025
7ba269a
Update
swolchok Mar 19, 2025
edd45fb
Update
swolchok Mar 19, 2025
b9c545f
Update
swolchok Mar 20, 2025
3091007
Update
swolchok Mar 20, 2025
4a00cac
Update
swolchok Mar 20, 2025
21b81bf
Update
swolchok Mar 20, 2025
4c4add0
Update
swolchok Mar 20, 2025
8782a90
Update
swolchok Mar 20, 2025
75f8970
Update
swolchok Mar 20, 2025
2d19e75
Update
swolchok Mar 20, 2025
b61a8a2
Update
swolchok Mar 25, 2025
91161bd
Update
swolchok Mar 25, 2025
4add706
Update
swolchok Mar 25, 2025
5348a92
Update
swolchok Mar 25, 2025
001d72c
Update
swolchok Mar 25, 2025
e49080d
Update
swolchok Mar 25, 2025
44ee51a
Update
swolchok Mar 25, 2025
f659627
Update
swolchok Mar 25, 2025
f1c5429
Update
swolchok Mar 25, 2025
b34f04f
Update
swolchok Mar 25, 2025
f934bc0
Update
swolchok Mar 25, 2025
3a74f25
Update
swolchok Mar 25, 2025
9a93839
Update
swolchok Mar 26, 2025
bb16a55
Update
swolchok Mar 26, 2025
2242f1e
Update
swolchok Mar 26, 2025
7f57a19
Update
swolchok Mar 26, 2025
5d95c06
Update
swolchok Mar 26, 2025
42623bb
Update
swolchok Mar 26, 2025
4553283
Update
swolchok Mar 26, 2025
39610ad
Update
swolchok Mar 26, 2025
b3120fa
Update
swolchok Mar 26, 2025
ff2c358
Update
swolchok Mar 26, 2025
7086659
Update
swolchok Mar 28, 2025
e13de0e
Update
swolchok Mar 28, 2025
943ab82
Update
swolchok Mar 28, 2025
f22d039
Update
swolchok Mar 28, 2025
45ce46d
Update
swolchok Mar 28, 2025
754dba4
Update
swolchok Mar 28, 2025
d5dfe2f
Update
swolchok Mar 28, 2025
ea9dc6f
Update
swolchok Mar 28, 2025
34eb5d4
Update
swolchok Mar 28, 2025
7d7859e
Update
swolchok Mar 28, 2025
b98829d
Update
swolchok Mar 28, 2025
3140910
Update
swolchok Mar 28, 2025
946f2e0
Update
swolchok Mar 28, 2025
afad88e
Update
swolchok Mar 28, 2025
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
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_acos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& acos_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "acos.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::acos(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::acos, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_acosh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& acosh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "acosh.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::acosh(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::acosh, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_asin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& asin_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "asin.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::asin(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::asin, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_asinh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& asinh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "asinh.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::asinh(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::asinh, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_atan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& atan_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "atan.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::atan(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::atan, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_atanh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& atanh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "atanh.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::atanh(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::atanh, ctx, in, out);
}

} // namespace native
Expand Down
4 changes: 1 addition & 3 deletions kernels/portable/cpu/op_ceil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ namespace native {
using executorch::aten::Tensor;

Tensor& ceil_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "ceil.out";
return internal::unary_ufunc_realh<op_name>(
[](auto x) { return std::ceil(x); }, ctx, in, out);
return internal::unary_ufunc_realh(std::ceil, ctx, in, out);
}

} // namespace native
Expand Down
4 changes: 1 addition & 3 deletions kernels/portable/cpu/op_cos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ namespace executor {
namespace native {

Tensor& cos_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "cos.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::cos(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(std::cos, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_cosh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& cosh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "cosh.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::cosh(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::cosh, ctx, in, out);
}

} // namespace native
Expand Down
4 changes: 1 addition & 3 deletions kernels/portable/cpu/op_erf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ namespace executor {
namespace native {

Tensor& erf_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "erf.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::erf(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(std::erf, ctx, in, out);
}

} // namespace native
Expand Down
4 changes: 1 addition & 3 deletions kernels/portable/cpu/op_exp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ namespace executor {
namespace native {

Tensor& exp_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "exp.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::exp(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(std::exp, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_expm1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& expm1_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "expm1.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::expm1(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::expm1, ctx, in, out);
}

} // namespace native
Expand Down
4 changes: 1 addition & 3 deletions kernels/portable/cpu/op_floor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ namespace native {
using executorch::aten::Tensor;

Tensor& floor_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "floor.out";
return internal::unary_ufunc_realh<op_name>(
[](auto x) { return std::floor(x); }, ctx, in, out);
return internal::unary_ufunc_realh(std::floor, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_isinf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ namespace native {
Tensor& isinf_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
// Lambda is syntactic sugar needed to workaround compilation on some older
// non-compatible distros where isnan is returning int rather than bool
static constexpr const char op_name[] = "isinf.out";
return internal::unary_ufunc_realhb_to_bool<op_name>(
[](auto x) -> bool { return std::isinf(x); }, ctx, in, out);
return internal::unary_ufunc_realhb_to_bool(
[](double x) -> bool { return std::isinf(x); }, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_isnan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ namespace native {
Tensor& isnan_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
// Lambda is syntactic sugar needed to workaround compilation on some older
// non-compatible distros where isnan is returning int rather than bool
static constexpr const char op_name[] = "isnan.out";
return internal::unary_ufunc_realhb_to_bool<op_name>(
[](auto x) -> bool { return std::isnan(x); }, ctx, in, out);
return internal::unary_ufunc_realhb_to_bool(
[](double x) -> bool { return std::isnan(x); }, ctx, in, out);
}

} // namespace native
Expand Down
4 changes: 1 addition & 3 deletions kernels/portable/cpu/op_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ namespace executor {
namespace native {

Tensor& log_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "log.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::log(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(std::log, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_log10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& log10_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "log10.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::log10(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::log10, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_log1p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& log1p_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "log1p.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::log1p(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::log1p, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_log2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& log2_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "log2.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::log2(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::log2, ctx, in, out);
}

} // namespace native
Expand Down
15 changes: 2 additions & 13 deletions kernels/portable/cpu/op_reciprocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,16 @@ namespace executor {
namespace native {
namespace {

float reciprocal(float x) {
return 1.0f / x;
}

double reciprocal(double x) {
return 1.0 / x;
}

template <
typename Integer,
std::enable_if_t<std::is_integral_v<Integer>, bool> = true>
double reciprocal(Integer x) {
return reciprocal((double)x);
}
} // namespace

Tensor&
reciprocal_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "reciprocal.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return reciprocal(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
reciprocal, ctx, in, out);
}

} // namespace native
Expand Down
17 changes: 8 additions & 9 deletions kernels/portable/cpu/op_rsqrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
namespace torch {
namespace executor {
namespace native {
namespace {

double rsqrt(double x) {
return 1.0 / std::sqrt(x);
}

} // namespace

Tensor& rsqrt_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "rsqrt.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) {
auto result = std::sqrt(x);
return static_cast<decltype(result)>(1) / result;
},
ctx,
in,
out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(rsqrt, ctx, in, out);
}

} // namespace native
Expand Down
4 changes: 1 addition & 3 deletions kernels/portable/cpu/op_sin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ namespace executor {
namespace native {

Tensor& sin_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "sin.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::sin(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(std::sin, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_sinh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& sinh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "sinh.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::sinh(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::sinh, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_sqrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& sqrt_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "sqrt.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::sqrt(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::sqrt, ctx, in, out);
}

} // namespace native
Expand Down
4 changes: 1 addition & 3 deletions kernels/portable/cpu/op_tan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ namespace executor {
namespace native {

Tensor& tan_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "tan.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::tan(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(std::tan, ctx, in, out);
}

} // namespace native
Expand Down
5 changes: 2 additions & 3 deletions kernels/portable/cpu/op_tanh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace executor {
namespace native {

Tensor& tanh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "tanh.out";
return internal::unary_ufunc_realhbbf16_to_floathbf16<op_name>(
[](auto x) { return std::tanh(x); }, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::tanh, ctx, in, out);
}

} // namespace native
Expand Down
4 changes: 1 addition & 3 deletions kernels/portable/cpu/op_trunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ namespace executor {
namespace native {

Tensor& trunc_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
static constexpr const char op_name[] = "trunc.out";
return internal::unary_ufunc_realh<op_name>(
[](auto x) { return std::trunc(x); }, ctx, in, out);
return internal::unary_ufunc_realh(std::trunc, ctx, in, out);
}

} // namespace native
Expand Down
Loading
Loading