Skip to content
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

#5424: Clean up Sfpu Sign kernel api #16809

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

atatuzunerTT
Copy link
Contributor

@atatuzunerTT atatuzunerTT commented Jan 16, 2025

Ticket

Link to Github Issue

Problem description

Ckernel sfpu functions are implemented both in third party llk layer and metal llk api layer. The goal is to remove any duplicates and have llk api layer to call the implementation in third party. This PR is concerned with the clean up (i.e. removal of duplicates) of the calculate_sign API located at:

  • tt_metal/hw/ckernels//metal/llk_api/llk_sfpu/ckernel_sfpu_sign.h

What's changed

Removed duplicate implementation for all architectures (i.e. bh, wh and gs). This API now calls the corresponding third party function calculate_sign that implements the functionality. Added test case in the sfpu_compute test suite for llks.

Checklist

  • Post commit CI passes
  • Blackhole Post commit (if applicable)
  • Model regression CI testing passes (if applicable)
  • Device performance regression CI testing passes (if applicable)
  • (For models and ops writers) Full new models tests passes
  • New/Existing tests provide coverage for changes

@@ -18,8 +18,10 @@ inline void llk_math_eltwise_unary_sfpu_sign_init() {
}

template <bool APPROXIMATE>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment here explaining the exponent_size_8 flag and why its defaulted to 1?

@@ -18,8 +18,10 @@ inline void llk_math_eltwise_unary_sfpu_sign_init() {
}

template <bool APPROXIMATE>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, a small comment about exponent_size_8

@@ -18,8 +18,10 @@ inline void llk_math_eltwise_unary_sfpu_sign_init() {
}

template <bool APPROXIMATE>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here

@@ -61,6 +62,8 @@ bfloat16 sfpu_function(const string& op_name, const bfloat16& input) {
return bfloat16(logf(input.to_float()));
} else if (op_name == "tanh") {
return bfloat16(std::tanh(input.to_float()));
} else if (op_name == "sign") {
return bfloat16((0.0f < input.to_float()) ? 1.0f : ((input.to_float() < 0.0f) ? -1.0f : 0.0f));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked what it does when you give it -0.0f ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants