-
Notifications
You must be signed in to change notification settings - Fork 808
[SYCL][Matrix] Add initial get_coord API. #7037
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
Changes from 8 commits
59d0e7e
135d82b
95adb66
c7e6000
7742fd9
b4e3ef5
57a97cf
1c5ace5
4529e66
643aafc
8e73c9d
b2ca8e4
d2dfda6
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 |
|---|---|---|
|
|
@@ -123,6 +123,14 @@ template <typename T, std::size_t R, std::size_t C, | |
| extern SYCL_EXTERNAL size_t __spirv_JointMatrixWorkItemLengthINTEL( | ||
| JOINT_MATRIX_INTEL(T, R, C, L, S, U) *); | ||
|
|
||
| template <typename T, std::size_t R, std::size_t C, | ||
| __spv::MatrixUse U = __spv::MatrixUse::Unnecessary, | ||
| __spv::MatrixLayout L = __spv::MatrixLayout::RowMajor, | ||
| __spv::Scope::Flag S = __spv::Scope::Flag::Subgroup> | ||
| extern SYCL_EXTERNAL __ocl_vec_t<int32_t, 2> | ||
|
||
| __spirv_JointMatrixWorkItemElemCoord(JOINT_MATRIX_INTEL(T, R, C, L, S, U) *, | ||
|
||
| size_t i); | ||
|
|
||
| template <typename T, std::size_t R, std::size_t C, | ||
| __spv::MatrixUse U = __spv::MatrixUse::Unnecessary, | ||
| __spv::MatrixLayout L = __spv::MatrixLayout::RowMajor, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| #include <CL/__spirv/spirv_ops.hpp> | ||
| #include <sycl/detail/defines_elementary.hpp> | ||
| #include <sycl/feature_test.hpp> | ||
| #include <tuple> | ||
|
|
||
| namespace sycl { | ||
| __SYCL_INLINE_VER_NAMESPACE(_V1) { | ||
|
|
@@ -256,6 +257,21 @@ class wi_element { | |
| wi_element(joint_matrix<T, NumRows, NumCols, Use, Layout, Group> &Mat, | ||
| std::size_t i) | ||
| : M(Mat), idx(i) {} | ||
|
|
||
| std::tuple<size_t, size_t> get_coord() { | ||
|
||
| #ifdef __SYCL_DEVICE_ONLY__ | ||
| __ocl_vec_t<int32_t, 2> co_ord = | ||
|
||
| __spirv_JointMatrixWorkItemElemCoord(M.spvm, idx); | ||
| const int32_t row = co_ord[0]; | ||
| const int32_t col = co_ord[1]; | ||
| return std::make_tuple(row, col); | ||
arnamoy10 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #else | ||
| throw runtime_error("joint matrix is not supported on host device.", | ||
| PI_ERROR_INVALID_DEVICE); | ||
| #endif // __SYCL_DEVICE_ONLY__ | ||
| } | ||
|
|
||
| // Various Operations | ||
| operator T() { | ||
| #ifdef __SYCL_DEVICE_ONLY__ | ||
| return __spirv_VectorExtractDynamic(M.spvm, idx); | ||
|
|
@@ -339,6 +355,20 @@ class wi_element<uint16_t, NumRows, NumCols, Use, Layout, Group> { | |
| wi_element(joint_matrix<uint16_t, NumRows, NumCols, Use, Layout, Group> &Mat, | ||
| std::size_t i) | ||
| : M(Mat), idx(i) {} | ||
|
|
||
| std::tuple<size_t, size_t> get_coord() { | ||
| #ifdef __SYCL_DEVICE_ONLY__ | ||
| __ocl_vec_t<int32_t, 2> coord = | ||
| __spirv_JointMatrixWorkItemElemCoord(M.spvm, idx); | ||
| const int32_t row = coord[0]; | ||
| const int32_t col = coord[1]; | ||
| return std::make_tuple(row, col); | ||
| #else | ||
| throw runtime_error("joint matrix is not supported on host device.", | ||
| PI_ERROR_INVALID_DEVICE); | ||
| #endif // __SYCL_DEVICE_ONLY__ | ||
| } | ||
|
|
||
| operator uint16_t() { | ||
| #ifdef __SYCL_DEVICE_ONLY__ | ||
| return __spirv_VectorExtractDynamic(M.spvm, idx); | ||
|
|
@@ -489,6 +519,20 @@ class wi_element<sycl::ext::oneapi::experimental::bfloat16, NumRows, NumCols, | |
| NumCols, Use, Layout, Group> &Mat, | ||
| std::size_t i) | ||
| : M(Mat), idx(i) {} | ||
|
|
||
| std::tuple<size_t, size_t> get_coord() { | ||
| #ifdef __SYCL_DEVICE_ONLY__ | ||
| __ocl_vec_t<int32_t, 2> co_ord = | ||
| __spirv_JointMatrixWorkItemElemCoord(M.spvm, idx); | ||
| const int32_t row = co_ord[0]; | ||
| const int32_t col = co_ord[1]; | ||
| return std::make_tuple(row, col); | ||
| #else | ||
| throw runtime_error("joint matrix is not supported on host device.", | ||
| PI_ERROR_INVALID_DEVICE); | ||
| #endif // __SYCL_DEVICE_ONLY__ | ||
| } | ||
|
|
||
| operator sycl::ext::oneapi::experimental::bfloat16() { | ||
| #ifdef __SYCL_DEVICE_ONLY__ | ||
| return __spirv_VectorExtractDynamic(M.spvm, idx); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.