-
Couldn't load subscription status.
- Fork 700
[EE/BE] add float variant to unary_ufunc_realhbbf16_to_floathbf16 #12277
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,8 @@ namespace HiFi { | |
| namespace native { | ||
| namespace { | ||
|
|
||
| double rsqrt(double x) { | ||
| template <typename T> | ||
| T rsqrt(T x) { | ||
| return 1.0 / std::sqrt(x); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto T(1.0) |
||
| } | ||
|
|
||
|
|
@@ -46,7 +47,7 @@ Tensor& rsqrt_out(RuntimeContext& ctx, const Tensor& in, Tensor& out) { | |
| } | ||
|
|
||
| return torch::executor::native::internal:: | ||
| unary_ufunc_realhbbf16_to_floathbf16(rsqrt, ctx, in, out); | ||
| unary_ufunc_realhbbf16_to_floathbf16(rsqrt, rsqrt, ctx, in, out); | ||
| } | ||
|
|
||
| } // namespace native | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,11 +84,18 @@ Tensor& unary_ufunc_realhb_to_bool( | |
| * the math operation which is applied to the input tensor element-wise. | ||
| */ | ||
| Tensor& unary_ufunc_realhbbf16_to_floathbf16( | ||
| double (*fn)(double), | ||
| float (*fn_float)(float), | ||
| double (*fn_double)(double), | ||
| KernelRuntimeContext& ctx, | ||
| const Tensor& in, | ||
| Tensor& out); | ||
|
|
||
| #define DEFINE_UNARY_UFUNC_REALHBBF16_TO_FLOATHBF16(op_name, fn) \ | ||
| Tensor& op_name(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) { \ | ||
| return internal::unary_ufunc_realhbbf16_to_floathbf16( \ | ||
| fn, fn, ctx, in, out); \ | ||
| } | ||
|
|
||
|
Comment on lines
+93
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not define this macro to use the full namespace (prefixed with :: so it works from anywhere) so that backends/cadence can use it too? |
||
| } // namespace internal | ||
| } // namespace native | ||
| } // namespace executor | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think this should be T(1.0) otherwise we're forcing computation in double, right?