Skip to content

Moved implementation of kernels out to dedicated header files. #925

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 4 commits into from
Oct 12, 2022
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
51 changes: 51 additions & 0 deletions dpctl/apis/include/dpctl4pybind11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,57 @@ class usm_memory : public py::object

namespace tensor
{

inline std::vector<py::ssize_t>
c_contiguous_strides(int nd,
const py::ssize_t *shape,
py::ssize_t element_size = 1)
{
if (nd > 0) {
std::vector<py::ssize_t> c_strides(nd, element_size);
for (int ic = nd - 1; ic > 0;) {
py::ssize_t next_v = c_strides[ic] * shape[ic];
c_strides[--ic] = next_v;
}
return c_strides;
}
else {
return std::vector<py::ssize_t>();
}
}

inline std::vector<py::ssize_t>
f_contiguous_strides(int nd,
const py::ssize_t *shape,
py::ssize_t element_size = 1)
{
if (nd > 0) {
std::vector<py::ssize_t> f_strides(nd, element_size);
for (int i = 0; i < nd - 1;) {
py::ssize_t next_v = f_strides[i] * shape[i];
f_strides[++i] = next_v;
}
return f_strides;
}
else {
return std::vector<py::ssize_t>();
}
}

inline std::vector<py::ssize_t>
c_contiguous_strides(const std::vector<py::ssize_t> &shape,
py::ssize_t element_size = 1)
{
return c_contiguous_strides(shape.size(), shape.data(), element_size);
}

inline std::vector<py::ssize_t>
f_contiguous_strides(const std::vector<py::ssize_t> &shape,
py::ssize_t element_size = 1)
{
return f_contiguous_strides(shape.size(), shape.data(), element_size);
}

class usm_ndarray : public py::object
{
public:
Expand Down
5 changes: 4 additions & 1 deletion dpctl/apis/include/dpctl_capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@
* C functions can use dpctl's C-API functions without linking to
* shared objects defining this symbols, if they call `import_dpctl()`
* prior to using those symbols.
*
* It is declared inline to allow multiple definitions in
* different translation units
*/
void import_dpctl(void)
static inline void import_dpctl(void)
{
import_dpctl___sycl_device();
import_dpctl___sycl_context();
Expand Down
Loading