xref: /aosp_15_r20/external/executorch/kernels/portable/cpu/op_rsqrt.cpp (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #include <executorch/kernels/portable/cpu/pattern/pattern.h>
10 #include <executorch/runtime/kernel/kernel_includes.h>
11 
12 namespace torch {
13 namespace executor {
14 namespace native {
15 namespace {
16 
rsqrt(double x)17 double rsqrt(double x) {
18   return 1.0 / std::sqrt(x);
19 }
20 
21 } // namespace
22 
rsqrt_out(KernelRuntimeContext & ctx,const Tensor & in,Tensor & out)23 Tensor& rsqrt_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
24   return internal::unary_ufunc_realhbbf16_to_floathbf16(rsqrt, ctx, in, out);
25 }
26 
27 } // namespace native
28 } // namespace executor
29 } // namespace torch
30