Skip to content

Commit 18d1728

Browse files
Merge pull request #1203 from IntelPython/feature/elementwise-functions
Initial check-in of some unary and binary elementwise functions
2 parents 634348b + 62f2d46 commit 18d1728

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+8082
-34
lines changed

.github/workflows/conda-package.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
run: conda install conda-build
4545
- name: Build conda package
4646
run: |
47-
CHANNELS="-c intel -c main --override-channels"
47+
CHANNELS="-c dppy/label/tools -c intel -c main --override-channels"
4848
VERSIONS="--python ${{ matrix.python }}"
4949
TEST="--no-test"
5050
conda build \
@@ -161,13 +161,20 @@ jobs:
161161
run: |
162162
. $CONDA/etc/profile.d/conda.sh
163163
conda activate test_dpctl
164-
python -c "import dpctl; dpctl.lsplatform()"
164+
python -c "import dpctl; dpctl.lsplatform(verbosity=2)"
165+
- name: Install gdb
166+
run: |
167+
sudo apt-get install -y gdb
168+
- name: Run test_elementwise under gdb
169+
run: |
170+
. $CONDA/etc/profile.d/conda.sh
171+
conda activate test_dpctl
172+
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
165173
- name: Run tests
166174
run: |
167175
. $CONDA/etc/profile.d/conda.sh
168176
conda activate test_dpctl
169-
# clinfo -l
170-
python -m pytest --pyargs $MODULE_NAME
177+
python -m pytest -v --pyargs $MODULE_NAME
171178
172179
test_windows:
173180
needs: build_windows

conda-recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ requirements:
1414
build:
1515
- {{ compiler('cxx') }}
1616
- {{ compiler('dpcpp') }} >=2023.1 # [not osx]
17-
- sysroot_linux-64 >=2.17 # [linux]
17+
- sysroot_linux-64 >=2.28 # [linux]
1818
host:
1919
- setuptools
2020
- cmake >=3.21

conda-recipe/run_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
set -e
44

55
${PYTHON} -c "import dpctl; print(dpctl.__version__)"
6-
${PYTHON} -c "import dpctl; dpctl.lsplatform()"
6+
${PYTHON} -c "import dpctl; dpctl.lsplatform(verbosity=2)"
77
${PYTHON} -m pytest -q -ra --disable-warnings -p no:faulthandler --cov dpctl --cov-report term-missing --pyargs dpctl -vv

dpctl/tensor/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@ pybind11_add_module(${python_module_name} MODULE
4646
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/where.cpp
4747
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/boolean_reductions.cpp
4848
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/device_support_queries.cpp
49+
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/elementwise_functions.cpp
4950
)
51+
set(_clang_prefix "")
52+
if (WIN32)
53+
set(_clang_prefix "/clang:")
54+
endif()
55+
set_source_files_properties(
56+
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/elementwise_functions.cpp
57+
PROPERTIES COMPILE_OPTIONS "${_clang_prefix}-fno-fast-math")
5058
target_compile_options(${python_module_name} PRIVATE -fno-sycl-id-queries-fit-in-int)
5159
target_link_options(${python_module_name} PRIVATE -fsycl-device-code-split=per_kernel)
5260
if(UNIX)

dpctl/tensor/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@
9191
from dpctl.tensor._utility_functions import all, any
9292

9393
from ._constants import e, inf, nan, newaxis, pi
94+
from ._elementwise_funcs import (
95+
abs,
96+
add,
97+
cos,
98+
divide,
99+
equal,
100+
isfinite,
101+
isinf,
102+
isnan,
103+
sqrt,
104+
)
94105

95106
__all__ = [
96107
"Device",
@@ -167,4 +178,13 @@
167178
"pi",
168179
"nan",
169180
"inf",
181+
"abs",
182+
"add",
183+
"cos",
184+
"isinf",
185+
"isnan",
186+
"isfinite",
187+
"sqrt",
188+
"divide",
189+
"equal",
170190
]

0 commit comments

Comments
 (0)