-
Notifications
You must be signed in to change notification settings - Fork 20
refactor: replace is_fp32_dest_acc_en boolean with DestDatumWidth enum for type safety
#524
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
base: main
Are you sure you want to change the base?
Conversation
|
After migrating from the Previously we often passed a bool is_fp32_dest_acc_en with hardcoded true/false and recently migrated to usage of Should we always hardcode ::Enable/::Disable at call sites? |
We don't have this macro in this repository. Once this repo is clear of compile issues, we should try to integrate these changes into tt-metal. What I see that remains to be done here is replace boolean with new enum in the test cases. |
|
After taking a deeper look into the changes, I see that enum class approach introduces a lot of boilerplate code needed for the macros to work. I have a bit different proposal, but I'd like to hear from @nvelickovicTT and @amahmudTT. It's a wrapper class. In short, something like this: class DestAccumulation {
public:
enum Value {
Disable,
Enable
};
DestAccumulation() = default;
constexpr DestAccumulation(Value destAccumulation) : value(destAccumulation) { }
constexpr bool operator==(DestAccumulation a) const { return value == a.value; }
constexpr bool operator!=(DestAccumulation a) const { return !(*this == a); }
// Boolean conversion
constexpr operator bool() const { return value == Value::Enable; }
// Optional: Access to raw enum
constexpr Value raw() const { return value; }
private:
Value value;
};This way you could achieve the same thing as with enum class: DestAccumulation d = DestAccumulation::Enable;And also, thanks to boolean conversion, you can just pass dest accumulation object to TT/TTI macros. |
|
@fvranicTT This approach makes sense the way easier with current code. I have also thought of boolean conversion intially for tt-metal in caller sites. So thought to push PR into llk to validate here |
@fvranicTT Good point. Seems this would allow for a more condensed code ( |
|
Maybe something like class DestAccumulation {
public:
static const DestAccumulation Enable;
static const DestAccumulation Disable;
constexpr bool operator==(DestAccumulation a) const { return value == a.value; }
constexpr bool operator!=(DestAccumulation a) const { return !(*this == a); }
constexpr operator bool() const {
return value;
}
private:
constexpr explicit DestAccumulation(bool value) : value(value) {}
bool value;
};
// Definition of static members
constexpr inline DestAccumulation DestAccumulation::Enable{true};
constexpr inline DestAccumulation DestAccumulation::Disable{false};Is more fitting:
|
amahmudTT
left a comment
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.
Please do two things,
-
For cases like (is_fp32_enable && some_other_cond), if you have changed it to something like ( fp_32_flag == fp32_flag::ENALBE && some_other_cond) , please put the first check in parenthesis.
-
For the git diff output , please grep for "=" and make sure none of the "==" mistakenly got replaced by a single "=" , as that would silently be ignored.
|
✨ A mirror branch has been created/updated for this PR: |
|
@asr2003 could you take a look at the mirrored branch? I made some changes that circumvent the problem of C++ versions. Also, we've decided to rename the class to better reflect what it does. I've made changes for wormhole, but they might be incomplete/tests failing. I haven't touched BH code. Please take a look. Thank you and sorry to keep you waiting this long. |
|
Hello! @asr2003 any luck? |
|
Hi @marty1885. I have few errors to resolve once there are done, I will push latest changes here by today or tomorrow |
is_fp32_dest_acc_en bool to DestAccumulation typeis_fp32_dest_acc_en boolean with DestDatumWidth enum for type safety
|
For pre-commit check, I will run it and push after a while(I am facing some installation issues of it) |
|
@fvranicTT I have fixed pre-commit check fail. Can I get latest status of CI? |
|
@fvranicTT I have ported tests now to use new class. Can I get latest status of CI? |
|
@nvelickovicTT @fvranicTT @amahmudTT @marty1885 Can I get latest status of CI? |
|
@nvelickovicTT @fvranicTT @amahmudTT @marty1885 Can I get latest status of CI? |
|
@marty1885 Can I get latest status of CI? I have fixed the format issues that caused last CI to fail |
|
@asr2003 Sorry I missed your messages - yeah the tests are failing. That needs to be fixed. Do you have hardware access? I don't think debugging on the CI is a viable strategy. I can give you could access. Would that help? |
|
Hello @asr2003 any updated? I'm obligated to check and I'll reopen the issue if you have lost interest on Firday |
Ticket
Part of tenstorrent/tt-metal#24109
Problem description
Currently, the code uses a boolean template parameter is_dest_accum_en to control destination accumulation behavior.
What's changed
All boolean template parameter usage of is_dest_accum_en converted to enum class and parameter is renamed to fp32_dest_accumulation
Type of change
Checklist