Skip to content

Initial check-in of some unary and binary elementwise functions #1203

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 52 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
2d2bfc2
Initial check-in of elementwise functions: abs/cos/isnan/add
oleksandr-pavlyk May 8, 2023
d7b4238
Fixed add_contig_impl and add_matrix_vector_broadcasting_contig_impl
oleksandr-pavlyk May 9, 2023
70615d1
Fixed typo in CMakeLists.txt cause -fno-apporox-func to be ignored
oleksandr-pavlyk May 9, 2023
a947b3a
Fixing typos discovered by added tests
oleksandr-pavlyk May 10, 2023
872f372
Added tests to increase coverage of elementwise functions
oleksandr-pavlyk May 10, 2023
6d71e46
Implemented isinf, isfinite, reused templates to define Contig and St…
oleksandr-pavlyk May 11, 2023
049b523
Added missing include statements
oleksandr-pavlyk May 12, 2023
b49744a
Debug: Set -H when compiling elementwise_functions.cpp
oleksandr-pavlyk May 12, 2023
56b134c
Added -fno-approx-func and -fno-finite-math-only
oleksandr-pavlyk May 12, 2023
4952132
Implements dpctl.tensor.sqrt
ndgrigorian May 12, 2023
1798bf2
Removed unneeded temporaries
oleksandr-pavlyk May 12, 2023
d2c9aa4
Use sycl::isinf for vec, but std::inf for scalars
oleksandr-pavlyk May 15, 2023
ca46b1b
Removed -H as it is not helpful, but verbose
oleksandr-pavlyk May 15, 2023
88e8931
Update meta.yaml to require sysroot_linux-64 >=2.28, and use dppy/lab…
oleksandr-pavlyk May 16, 2023
95a8142
Use verbose lsplatform in run_test.sh
oleksandr-pavlyk May 16, 2023
b1495a2
Added gdb call in test_linux as a separate step
oleksandr-pavlyk May 16, 2023
58ff5be
Merge pull request #1208 from IntelPython/feature/elementwise-functio…
oleksandr-pavlyk May 16, 2023
f3535f1
Created templates for binary functions too, applied for addition
oleksandr-pavlyk May 17, 2023
73e979d
Added NullPtrTable<FunPtrT> and NullPtrVector<FunPtrT> classes (yet u…
oleksandr-pavlyk May 17, 2023
300cc47
Merge remote-tracking branch 'origin/master' into feature/elementwise…
oleksandr-pavlyk May 17, 2023
8077aac
No all binary functions are symmetric, modified py_binary_func accord…
oleksandr-pavlyk May 17, 2023
d699a5f
Fixed type in the test name: vaidation->validation
oleksandr-pavlyk May 17, 2023
5d37d74
Added tests for dpctl.tensor.sqrt
ndgrigorian May 17, 2023
40113bc
Merge pull request #1205 from IntelPython/feature/elementwise-functio…
oleksandr-pavlyk May 17, 2023
863ba3b
Renamed private sycl::event variable
oleksandr-pavlyk May 17, 2023
b088a52
Use std::cos for complex types as well.
oleksandr-pavlyk May 17, 2023
6b56e99
Added BinaryContigMatrixContigRowBroadcastFunctor and RowMatrix variant
oleksandr-pavlyk May 17, 2023
8a8411a
Exposed dpctl.tensor.divide(x, y)
oleksandr-pavlyk May 17, 2023
dc386eb
Split tests of elementwise functions into separate files
oleksandr-pavlyk May 17, 2023
85d468c
Migrated tests for sqrt into elementwise folder
oleksandr-pavlyk May 18, 2023
7453bf7
Corrected order="K" handling for binary function in some cases
oleksandr-pavlyk May 18, 2023
89f8fe9
Tweak to find_buf_dtype2
oleksandr-pavlyk May 18, 2023
2be09e5
Adding tests for dpt.divide
oleksandr-pavlyk May 18, 2023
7a12565
Add tests for _get_default_device_type utility
oleksandr-pavlyk May 18, 2023
c3a3f01
Removed superfluous semicolon
oleksandr-pavlyk May 18, 2023
1aa37db
Changes to NullPtrTable, NullPtrVector to remove unneeded methods.
oleksandr-pavlyk May 18, 2023
61100e4
Also try _get_device_default_type with invalid kind argument
oleksandr-pavlyk May 18, 2023
cde757c
Added implementation of dpctl.tensor.equal
oleksandr-pavlyk May 18, 2023
5f659fe
Adding tests for equal
oleksandr-pavlyk May 18, 2023
4439bf7
Renamed struct to better reflect its purpose
oleksandr-pavlyk May 18, 2023
c6ef075
Use MemoryOverlap
oleksandr-pavlyk May 18, 2023
6bc4ba8
Added wait to avoid dangling host_task
oleksandr-pavlyk May 18, 2023
aebaf3a
Fixed type of output multi_ptr per PR review remark by @ndgrigorian
oleksandr-pavlyk May 19, 2023
aef6de3
out keyword for elementwise functions
vtavana May 19, 2023
21e1415
update the tests
vtavana May 19, 2023
0820add
Removed unsed code
oleksandr-pavlyk May 19, 2023
121f819
add new tests to improve coverage
vtavana May 20, 2023
05ae945
Fixed tests to run on Iris Xe
oleksandr-pavlyk May 20, 2023
d691846
Added a test for broadcasting error
oleksandr-pavlyk May 20, 2023
f3d5519
use keywrod argument
vtavana May 20, 2023
cc75cd2
Merge pull request #1209 from IntelPython/feature/elementwise-functio…
vtavana May 20, 2023
62f2d46
Added missing license headers, updated license year to 2023
oleksandr-pavlyk May 22, 2023
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
15 changes: 11 additions & 4 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: conda install conda-build
- name: Build conda package
run: |
CHANNELS="-c intel -c main --override-channels"
CHANNELS="-c dppy/label/tools -c intel -c main --override-channels"
VERSIONS="--python ${{ matrix.python }}"
TEST="--no-test"
conda build \
Expand Down Expand Up @@ -161,13 +161,20 @@ jobs:
run: |
. $CONDA/etc/profile.d/conda.sh
conda activate test_dpctl
python -c "import dpctl; dpctl.lsplatform()"
python -c "import dpctl; dpctl.lsplatform(verbosity=2)"
- name: Install gdb
run: |
sudo apt-get install -y gdb
- name: Run test_elementwise under gdb
run: |
. $CONDA/etc/profile.d/conda.sh
conda activate test_dpctl
gdb --batch -ex r -ex 'info sharedlibrary' -ex 'set print elements 1000' -ex bt --args ${CONDA_PREFIX}/bin/python -m pytest -q -ra --disable-warnings --pyargs dpctl.tests.test_tensor_elementwise::test_cos_order -vv || true
- name: Run tests
run: |
. $CONDA/etc/profile.d/conda.sh
conda activate test_dpctl
# clinfo -l
python -m pytest --pyargs $MODULE_NAME
python -m pytest -v --pyargs $MODULE_NAME

test_windows:
needs: build_windows
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ requirements:
build:
- {{ compiler('cxx') }}
- {{ compiler('dpcpp') }} >=2023.1 # [not osx]
- sysroot_linux-64 >=2.17 # [linux]
- sysroot_linux-64 >=2.28 # [linux]
host:
- setuptools
- cmake >=3.21
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
set -e

${PYTHON} -c "import dpctl; print(dpctl.__version__)"
${PYTHON} -c "import dpctl; dpctl.lsplatform()"
${PYTHON} -c "import dpctl; dpctl.lsplatform(verbosity=2)"
${PYTHON} -m pytest -q -ra --disable-warnings -p no:faulthandler --cov dpctl --cov-report term-missing --pyargs dpctl -vv
8 changes: 8 additions & 0 deletions dpctl/tensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ pybind11_add_module(${python_module_name} MODULE
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/where.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/boolean_reductions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/device_support_queries.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/elementwise_functions.cpp
)
set(_clang_prefix "")
if (WIN32)
set(_clang_prefix "/clang:")
endif()
set_source_files_properties(
${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)
target_link_options(${python_module_name} PRIVATE -fsycl-device-code-split=per_kernel)
if(UNIX)
Expand Down
20 changes: 20 additions & 0 deletions dpctl/tensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@
from dpctl.tensor._utility_functions import all, any

from ._constants import e, inf, nan, newaxis, pi
from ._elementwise_funcs import (
abs,
add,
cos,
divide,
equal,
isfinite,
isinf,
isnan,
sqrt,
)

__all__ = [
"Device",
Expand Down Expand Up @@ -167,4 +178,13 @@
"pi",
"nan",
"inf",
"abs",
"add",
"cos",
"isinf",
"isnan",
"isfinite",
"sqrt",
"divide",
"equal",
]
Loading