Skip to content

Compile certain source files in libtensor with no-fast-math #1318

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

Merged
merged 2 commits into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dpctl/tensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ if (WIN32)
set(_clang_prefix "/clang:")
endif()
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/full_ctor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/linear_sequences.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/elementwise_functions.cpp
PROPERTIES COMPILE_OPTIONS "${_clang_prefix}-fno-fast-math")
target_compile_options(${python_module_name} PRIVATE -fno-sycl-id-queries-fit-in-int)
Expand Down
24 changes: 24 additions & 0 deletions dpctl/tests/test_usm_ndarray_ctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,30 @@ def test_full_dtype_inference():
assert np.issubdtype(dpt.full(10, 0.3 - 2j, dtype=rdt).dtype, np.floating)


@pytest.mark.parametrize("dt", ["f2", "f4", "f8"])
def test_full_special_fp(dt):
"""See gh-1314"""
q = get_queue_or_skip()
skip_if_dtype_not_supported(dt, q)

ar = dpt.full(10, fill_value=dpt.nan)
err_msg = f"Failed for fill_value=dpt.nan and dtype {dt}"
assert dpt.isnan(ar[0]), err_msg

ar = dpt.full(10, fill_value=dpt.inf)
err_msg = f"Failed for fill_value=dpt.inf and dtype {dt}"
assert dpt.isinf(ar[0]) and dpt.greater(ar[0], 0), err_msg

ar = dpt.full(10, fill_value=-dpt.inf)
err_msg = f"Failed for fill_value=-dpt.inf and dtype {dt}"
assert dpt.isinf(ar[0]) and dpt.less(ar[0], 0), err_msg

ar = dpt.full(10, fill_value=dpt.pi)
err_msg = f"Failed for fill_value=dpt.pi and dtype {dt}"
check = abs(float(ar[0]) - dpt.pi) < 16 * dpt.finfo(ar.dtype).eps
assert check, err_msg


def test_full_fill_array():
q = get_queue_or_skip()

Expand Down