Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 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
3 changes: 2 additions & 1 deletion kernels/portable/cpu/op_acos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace executor {
namespace native {

Tensor& acos_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::acos, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::acos, ctx, in, out);
}

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

Tensor& acosh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::acosh, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::acosh, ctx, in, out);
}

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

Tensor& asin_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::asin, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::asin, ctx, in, out);
}

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

Tensor& asinh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::asinh, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::asinh, ctx, in, out);
}

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

Tensor& atan_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::atan, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::atan, ctx, in, out);
}

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

Tensor& atanh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::atanh, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::atanh, ctx, in, out);
}

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

Tensor& cos_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::cos, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(std::cos, ctx, in, out);
}

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

Tensor& cosh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::cosh, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::cosh, ctx, in, out);
}

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

Tensor& erf_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::erf, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(std::erf, ctx, in, out);
}

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

Tensor& exp_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::exp, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(std::exp, ctx, in, out);
}

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

Tensor& expm1_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::expm1, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::expm1, ctx, in, out);
}

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

Tensor& log_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::log, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(std::log, ctx, in, out);
}

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

Tensor& log10_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::log10, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::log10, ctx, in, out);
}

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

Tensor& log1p_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::log1p, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::log1p, ctx, in, out);
}

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

Tensor& log2_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::log2, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::log2, ctx, in, out);
}

} // namespace native
Expand Down
3 changes: 2 additions & 1 deletion kernels/portable/cpu/op_reciprocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ double reciprocal(double x) {

Tensor&
reciprocal_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(reciprocal, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
reciprocal, ctx, in, out);
}

} // namespace native
Expand Down
2 changes: 1 addition & 1 deletion kernels/portable/cpu/op_rsqrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ double rsqrt(double x) {
} // namespace

Tensor& rsqrt_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(rsqrt, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(rsqrt, ctx, in, out);
}

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

Tensor& sin_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::sin, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(std::sin, ctx, in, out);
}

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

Tensor& sinh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::sinh, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::sinh, ctx, in, out);
}

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

Tensor& sqrt_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::sqrt, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::sqrt, ctx, in, out);
}

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

Tensor& tan_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::tan, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(std::tan, ctx, in, out);
}

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

Tensor& tanh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
return internal::unary_ufunc_realhb_to_floath(std::tanh, ctx, in, out);
return internal::unary_ufunc_realhbbf16_to_floathbf16(
std::tanh, ctx, in, out);
}

} // namespace native
Expand Down
6 changes: 3 additions & 3 deletions kernels/portable/cpu/pattern/pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ Tensor& unary_ufunc_realhb_to_bool(

/**
* Implements an op pattern for ops that take a single input tensor of any
* realhb dtye (real, half and boolean), no additional arguments, and outputs a
* realhbbf16 dtype (real/half/bool/bfloat16), no additional arguments, and outputs a
* floating point tensor of the same size. The function fn specifies the math
* operation which is applied to the input tensor element-wise.
*/
Tensor& unary_ufunc_realhb_to_floath(
Tensor& unary_ufunc_realhbbf16_to_floathbf16(
double (*fn)(double),
KernelRuntimeContext& ctx,
const Tensor& in,
Tensor& out);

/**
* Implements an op pattern for ops that take two broadcastable input tensors
* of any realb dtye, no additional arguments, performs an element-wise binary
* of any realb dtype, no additional arguments, performs an element-wise binary
* logical operation, and outputs a realb tensor. The function fn specifies the
* binary logical operation which is applied to the input tensors element-wise.
*/
Expand Down
2 changes: 1 addition & 1 deletion kernels/portable/cpu/pattern/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def define_common_targets():
name = "pattern",
srcs = [
"unary_ufunc_realhb_to_bool.cpp",
"unary_ufunc_realhb_to_floath.cpp",
"unary_ufunc_realhbbf16_to_floathbf16.cpp",
"unary_ufunc_realh.cpp",
"binary_ufunc_realb_realb_to_realb_logical.cpp",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace executor {
namespace native {
namespace internal {

Tensor& unary_ufunc_realhb_to_floath(
Tensor& unary_ufunc_realhbbf16_to_floathbf16(
double (*fn)(double),
KernelRuntimeContext& ctx,
const Tensor& in,
Expand All @@ -38,8 +38,8 @@ Tensor& unary_ufunc_realhb_to_floath(
const auto in_type = in.scalar_type();
const auto out_type = out.scalar_type();

ET_SWITCH_REALHB_TYPES(in_type, ctx, __func__, CTYPE_IN, [&] {
ET_SWITCH_FLOATH_TYPES(out_type, ctx, __func__, CTYPE_OUT, [&] {
ET_SWITCH_REALHBBF16_TYPES(in_type, ctx, __func__, CTYPE_IN, [&] {
ET_SWITCH_FLOATHBF16_TYPES(out_type, ctx, __func__, CTYPE_OUT, [&] {
apply_unary_map_fn(
[fn](const CTYPE_IN val_in) {
CTYPE_OUT xi = static_cast<CTYPE_OUT>(val_in);
Expand Down
2 changes: 1 addition & 1 deletion kernels/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ add_custom_target(
"${CMAKE_CURRENT_BINARY_DIR}/include/optimized/executorch/kernels/test/supported_features.cpp"
)

add_library(test_util UnaryUfuncRealHBToFloatHTest.cpp)
add_library(test_util UnaryUfuncRealHBBF16ToFloatHBF16Test.cpp)
target_include_directories(
test_util PRIVATE "${CMAKE_INSTALL_PREFIX}/include"
)
Expand Down
Loading
Loading