-
Notifications
You must be signed in to change notification settings - Fork 26
Refactor dpnp includes and add extension example #2941
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
base: master
Are you sure you want to change the base?
Changes from all commits
82a59d1
1547e62
22fe46e
82d90b9
c735f53
5ce4ee9
a84e5fc
4c05f49
020e5ea
f162a9d
4a4e5d2
d0127f3
cded248
9b70628
6ac4c8b
8730fa6
4cd26db
4fb12d0
fc060a9
8066951
7304e4b
f3148d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| #.rst: | ||
| # | ||
| # Find the include directory for ``dpnp4pybind11.hpp`` and dpnp tensor kernels. | ||
| # | ||
| # This module sets the following variables: | ||
| # | ||
| # ``Dpnp_FOUND`` | ||
| # True if DPNP was found. | ||
| # ``Dpnp_INCLUDE_DIR`` | ||
| # The include directory needed to use dpnp. | ||
| # ``Dpnp_TENSOR_INCLUDE_DIR`` | ||
| # The include directory for tensor kernels implementation. | ||
| # ``Dpnp_VERSION`` | ||
| # The version of dpnp found. | ||
| # | ||
| # The module will also explicitly define two cache variables: | ||
| # | ||
| # ``Dpnp_INCLUDE_DIR`` | ||
| # ``Dpnp_TENSOR_INCLUDE_DIR`` | ||
| # | ||
|
|
||
| if(NOT Dpnp_FOUND) | ||
| find_package(Python 3.10 REQUIRED COMPONENTS Interpreter Development.Module) | ||
|
ndgrigorian marked this conversation as resolved.
|
||
|
|
||
| if(Python_EXECUTABLE) | ||
| execute_process( | ||
| COMMAND "${Python_EXECUTABLE}" -m dpnp --include-dir | ||
| OUTPUT_VARIABLE _dpnp_include_dir | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_QUIET | ||
| ) | ||
| execute_process( | ||
| COMMAND "${Python_EXECUTABLE}" -c "import dpnp; print(dpnp.__version__)" | ||
| OUTPUT_VARIABLE Dpnp_VERSION | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_QUIET | ||
| ) | ||
| endif() | ||
| endif() | ||
|
|
||
| find_path( | ||
| Dpnp_INCLUDE_DIR | ||
| dpnp4pybind11.hpp | ||
| PATHS "${_dpnp_include_dir}" "${Python_INCLUDE_DIRS}" | ||
| PATH_SUFFIXES dpnp/include | ||
|
ndgrigorian marked this conversation as resolved.
|
||
| NO_DEFAULT_PATH | ||
| ) | ||
| get_filename_component(_dpnp_dir "${Dpnp_INCLUDE_DIR}" DIRECTORY) | ||
|
|
||
| find_path( | ||
| Dpnp_TENSOR_INCLUDE_DIR | ||
| kernels | ||
| PATHS "${_dpnp_dir}/tensor/libtensor/include" | ||
| NO_DEFAULT_PATH | ||
| ) | ||
|
|
||
| set(Dpnp_INCLUDE_DIRS ${Dpnp_INCLUDE_DIR}) | ||
|
|
||
| # handle the QUIETLY and REQUIRED arguments and set Dpnp_FOUND to TRUE if | ||
| # all listed variables are TRUE | ||
| include(FindPackageHandleStandardArgs) | ||
| find_package_handle_standard_args( | ||
| Dpnp | ||
| REQUIRED_VARS Dpnp_INCLUDE_DIR Dpnp_TENSOR_INCLUDE_DIR | ||
| VERSION_VAR Dpnp_VERSION | ||
| ) | ||
|
|
||
| mark_as_advanced(Dpnp_INCLUDE_DIR) | ||
| mark_as_advanced(Dpnp_TENSOR_INCLUDE_DIR) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,7 @@ def _dpnp_dir() -> str: | |
|
|
||
| def get_include_dir() -> str: | ||
| """Returns path to dpnp include directory containing dpnp4pybind11.hpp""" | ||
| return os.path.join(_dpnp_dir(), "backend", "include") | ||
| return os.path.join(_dpnp_dir(), "include") | ||
|
|
||
|
|
||
| def print_include_flags() -> None: | ||
|
|
@@ -61,6 +61,13 @@ def print_tensor_include_flags() -> None: | |
| print("-I " + libtensor_dir) | ||
|
|
||
|
|
||
| def print_cmake_dir() -> None: | ||
| """Prints directory with dpnp-config.cmake""" | ||
| dpnp_dir = _dpnp_dir() | ||
| cmake_dir = os.path.join(dpnp_dir, "resources", "cmake") | ||
| print(cmake_dir) | ||
|
|
||
|
|
||
| def main() -> None: | ||
| """Main entry-point.""" | ||
| parser = argparse.ArgumentParser() | ||
|
|
@@ -84,6 +91,11 @@ def main() -> None: | |
| action="store_true", | ||
| help="Path to dpnp libtensor include directory.", | ||
| ) | ||
| parser.add_argument( | ||
| "--cmakedir", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to test
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure how you mean, |
||
| action="store_true", | ||
| help="CMake module directory, ideal for setting -DDpnp_ROOT in CMake.", | ||
| ) | ||
| args = parser.parse_args() | ||
| if not sys.argv[1:]: | ||
| parser.print_help() | ||
|
|
@@ -95,6 +107,8 @@ def main() -> None: | |
| print_tensor_include_flags() | ||
| if args.tensor_include_dir: | ||
| print(get_tensor_include_dir()) | ||
| if args.cmakedir: | ||
| print_cmake_dir() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.