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

Fix compilation error when HWY_COMPILER_GCC_ACTUAL < 1300 #120

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

ufownl
Copy link
Contributor

@ufownl ufownl commented Mar 28, 2024

This issue is caused by hwy::ConvertScalarTo called in EmbeddingScaling. The comment on EmbeddingScaling said that it's for rounding the float to bf16 to match Gemma's Embedder. It calls this version of the template function:

template <typename TTo, typename TFrom, HWY_IF_BF16(TFrom),
          HWY_IF_NOT_SPECIAL_FLOAT(TTo)>
HWY_API HWY_BF16_CONSTEXPR TTo ConvertScalarTo(TFrom in) {
  return static_cast<TTo>(F32FromBF16(in));
}

When HWY_COMPILER_GCC_ACTUAL < 1300 and there is no built-in function __builtin_bit_cast, It will not be constexpr. However, constexpr attribute of EmbeddingScaling only follows Sqrt, which may cause compilation errors. So I open this PR to fix it.

@austinvhuang
Copy link
Collaborator

Thanks, maybe related -
#119 (comment)

Copy link
Member

@jan-wassenberg jan-wassenberg left a comment

Choose a reason for hiding this comment

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

Nice solution, thank you for fixing this :)

@jan-wassenberg jan-wassenberg added the copybara-import Trigger Copybara for merging pull requests label Mar 28, 2024
@copybara-service copybara-service bot merged commit 7e0a6fc into google:dev Mar 28, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
copybara-import Trigger Copybara for merging pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants