Skip to content

Commit b778776

Browse files
committed
add to vw_core
1 parent 362b98b commit b778776

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ option(VW_BUILD_VW_C_WRAPPER "Enable building the c_wrapper project" ON)
178178
option(vw_BUILD_NET_CORE "Build .NET Core targets" OFF)
179179
option(vw_BUILD_NET_FRAMEWORK "Build .NET Framework targets" OFF)
180180
option(VW_BUILD_WASM "Add WASM target" OFF)
181+
option(STD_INV_SQRT "Use standard library inverse square root" OFF)
181182

182183
if(VW_INSTALL AND NOT VW_ZLIB_SYS_DEP)
183184
message(WARNING "Installing with a vendored version of zlib is not recommended. Use VW_ZLIB_SYS_DEP to use a system dependency or specify VW_INSTALL=OFF to silence this warning.")

vowpalwabbit/core/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ if (MSVC_IDE)
440440
target_sources(vw_core PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/vw_types.natvis> )
441441
endif()
442442

443+
if(STD_INV_SQRT)
444+
target_compile_definitions(vw_core PUBLIC STD_INV_SQRT)
445+
endif()
446+
443447
# Clang-cl on Windows has issues with our usage of SIMD types. Turn it off explicitly for Windows + clang-cl to mitigate.
444448
# See issue #
445449
if(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")

vowpalwabbit/core/src/reductions/gd.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ VW_WARNING_STATE_POP
153153

154154
static inline float inv_sqrt(float x)
155155
{
156+
return 1.f / std::sqrt(x);
156157
#if defined(STD_INV_SQRT)
157158
return 1.f / std::sqrt(x);
158159
#endif

0 commit comments

Comments
 (0)