Skip to content

Fix compilation error when HWY_COMPILER_GCC_ACTUAL < 1300#120

Merged
copybara-service[bot] merged 1 commit intogoogle:devfrom
ufownl:bugfix/gcc_compilation_error
Mar 28, 2024
Merged

Fix compilation error when HWY_COMPILER_GCC_ACTUAL < 1300#120
copybara-service[bot] merged 1 commit intogoogle:devfrom
ufownl:bugfix/gcc_compilation_error

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
Contributor

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
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.

3 participants