Skip to content

Convert .pxi include files to .pxd/.pyx in dpnp/tensor#2913

Open
vlad-perevezentsev wants to merge 5 commits into
masterfrom
update_tensor_cython_pxi
Open

Convert .pxi include files to .pxd/.pyx in dpnp/tensor#2913
vlad-perevezentsev wants to merge 5 commits into
masterfrom
update_tensor_cython_pxi

Conversation

@vlad-perevezentsev
Copy link
Copy Markdown
Contributor

This PR proposes to replace Cython textual includes with proper module imports in dpnp/tensor
.pxi files are converted into corresponding .pxd and .pyx modules for _slicing.pxi, _stride_utils.pxi and _types.pxi`

This change replaces the include .pxi pattern with standard Cython cimport statements and improving modularity

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

@coveralls
Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.38% (-0.06%) from 78.444% — update_tensor_cython_pxi into master

@github-actions
Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev0=py313h509198e_21 ran successfully.
Passed: 1355
Failed: 5
Skipped: 16

@github-actions
Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/2913/index.html

Comment thread dpnp/tensor/_usmarray.pyx
include "_stride_utils.pxi"
include "_types.pxi"
include "_slicing.pxi"
from ._slicing cimport *
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a good practice to use star cimport?

Comment thread CHANGELOG.md
Comment thread dpnp/tensor/_slicing.pyx
from cpython.buffer cimport PyObject_CheckBuffer
from numpy import ndarray

from ._usmarray cimport usm_ndarray
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not that produce a circular dependency? (_usmarray ↔ _slicing)

Comment thread dpnp/tensor/_usmarray.pyx


# Local storage for `cdef public api` constants
# declared in _usmarray.pxd
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to avoid redefinition? To keep the constant defined in single place, the same is applicable to UAR_* constants.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when these files were in dpctl, my thought was to move these constants into another, separate .pxd which could just be included by both

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndgrigorian could you clarify what you mean by a separate .pxd file?
Previously these constants were defined in .pxi files that were included directly into _usmarray.pyx which provided local storage for cdef public api
cimport from another .pxd does not work that (header is generated but constants are zero at runtime)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants