Skip to content

Revert "[Matrix][SYCL] Add bfloat16 support for joint_matrix" #6108

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 1 commit into from
May 6, 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
151 changes: 0 additions & 151 deletions sycl/include/sycl/ext/oneapi/matrix/matrix-jit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <CL/__spirv/spirv_ops.hpp>
#include <CL/sycl/detail/defines_elementary.hpp>
#include <CL/sycl/feature_test.hpp>
#include <sycl/ext/oneapi/experimental/bfloat16.hpp>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
Expand Down Expand Up @@ -454,156 +453,6 @@ class wi_element<uint16_t, NumRows, NumCols, Layout, Group> {
#undef OP
};

template <size_t NumRows, size_t NumCols, matrix_layout Layout, typename Group>
class wi_element<sycl::ext::oneapi::experimental::bfloat16, NumRows, NumCols,
Layout, Group> {
joint_matrix<sycl::ext::oneapi::experimental::bfloat16, NumRows, NumCols,
Layout, Group> &M;
std::size_t idx;

public:
wi_element(joint_matrix<sycl::ext::oneapi::experimental::bfloat16, NumRows,
NumCols, Layout, Group> &Mat,
std::size_t i)
: M(Mat), idx(i) {}
operator sycl::ext::oneapi::experimental::bfloat16() {
#ifdef __SYCL_DEVICE_ONLY__
return __spirv_VectorExtractDynamic(M.spvm, idx);
#else
throw runtime_error("joint matrix is not supported on host device.",
PI_INVALID_DEVICE);
#endif // __SYCL_DEVICE_ONLY__
}

explicit operator bool() {
#ifdef __SYCL_DEVICE_ONLY__
return std::fabs(static_cast<float>(__spirv_VectorExtractDynamic(
M.spvm, idx))) >= std::numeric_limits<float>::epsilon();
#else
throw runtime_error("joint matrix is not supported on host device.",
PI_INVALID_DEVICE);
#endif // __SYCL_DEVICE_ONLY__
}

wi_element &operator=(const sycl::ext::oneapi::experimental::bfloat16 &rhs) {
#ifdef __SYCL_DEVICE_ONLY__
M.spvm = __spirv_VectorInsertDynamic(M.spvm, rhs, idx);
return *this;
#else
(void)rhs;
throw runtime_error("joint matrix is not supported on host device.",
PI_INVALID_DEVICE);
#endif // __SYCL_DEVICE_ONLY__
}

wi_element &
operator=(const wi_element<sycl::ext::oneapi::experimental::bfloat16, NumRows,
NumCols, Layout, Group> &rhs) {
#ifdef __SYCL_DEVICE_ONLY__
M.spvm = __spirv_VectorInsertDynamic(
M.spvm, __spirv_VectorExtractDynamic(rhs.M.spvm, rhs.idx), idx);
return *this;
#else
(void)rhs;
throw runtime_error("joint matrix is not supported on host device.",
PI_INVALID_DEVICE);
#endif // __SYCL_DEVICE_ONLY__
}

#if __SYCL_DEVICE_ONLY__
#define OP(opassign, op) \
wi_element &operator opassign( \
const sycl::ext::oneapi::experimental::bfloat16 &rhs) { \
M.spvm = __spirv_VectorInsertDynamic( \
M.spvm, __spirv_VectorExtractDynamic(M.spvm, idx) op rhs, idx); \
return *this; \
}
#else // __SYCL_DEVICE_ONLY__
#define OP(opassign, op) \
wi_element &operator opassign( \
const sycl::ext::oneapi::experimental::bfloat16 &rhs) { \
(void)rhs; \
throw runtime_error("joint matrix is not supported on host device.", \
PI_INVALID_DEVICE); \
}
#endif // __SYCL_DEVICE_ONLY__
OP(+=, +)
OP(-=, -)
OP(*=, *)
OP(/=, /)
#undef OP

#if __SYCL_DEVICE_ONLY__
#define OP(type, op) \
friend type operator op( \
const wi_element<sycl::ext::oneapi::experimental::bfloat16, NumRows, \
NumCols, Layout, Group> &lhs, \
const sycl::ext::oneapi::experimental::bfloat16 &rhs) { \
return __spirv_VectorExtractDynamic(lhs.M.spvm, lhs.idx) op rhs; \
} \
friend type operator op( \
const sycl::ext::oneapi::experimental::bfloat16 &lhs, \
const wi_element<sycl::ext::oneapi::experimental::bfloat16, NumRows, \
NumCols, Layout, Group> &rhs) { \
return __spirv_VectorExtractDynamic(rhs.M.spvm, rhs.idx) op lhs; \
}
OP(sycl::ext::oneapi::experimental::bfloat16, +)
OP(sycl::ext::oneapi::experimental::bfloat16, -)
OP(sycl::ext::oneapi::experimental::bfloat16, *)
OP(sycl::ext::oneapi::experimental::bfloat16, /)
#undef OP
#define OP(type, op) \
friend type operator op( \
const wi_element<sycl::ext::oneapi::experimental::bfloat16, NumRows, \
NumCols, Layout, Group> &lhs, \
const sycl::ext::oneapi::experimental::bfloat16 &rhs) { \
return type{static_cast<float>(__spirv_VectorExtractDynamic( \
lhs.M.spvm, lhs.idx)) op static_cast<float>(rhs)}; \
} \
friend type operator op( \
const sycl::ext::oneapi::experimental::bfloat16 &lhs, \
const wi_element<sycl::ext::oneapi::experimental::bfloat16, NumRows, \
NumCols, Layout, Group> &rhs) { \
return type{static_cast<float>(__spirv_VectorExtractDynamic( \
rhs.M.spvm, rhs.idx)) op static_cast<float>(lhs)}; \
}
OP(bool, ==)
OP(bool, !=)
OP(bool, <)
OP(bool, >)
OP(bool, <=)
OP(bool, >=)
#undef OP
#else // __SYCL_DEVICE_ONLY__
#define OP(type, op) \
friend type operator op( \
const wi_element<sycl::ext::oneapi::experimental::bfloat16, NumRows, \
NumCols, Layout, Group> &, \
const sycl::ext::oneapi::experimental::bfloat16 &) { \
throw runtime_error("joint matrix is not supported on host device.", \
PI_INVALID_DEVICE); \
} \
friend type operator op( \
const sycl::ext::oneapi::experimental::bfloat16 &, \
const wi_element<sycl::ext::oneapi::experimental::bfloat16, NumRows, \
NumCols, Layout, Group> &) { \
throw runtime_error("joint matrix is not supported on host device.", \
PI_INVALID_DEVICE); \
}
OP(sycl::ext::oneapi::experimental::bfloat16, +)
OP(sycl::ext::oneapi::experimental::bfloat16, -)
OP(sycl::ext::oneapi::experimental::bfloat16, *)
OP(sycl::ext::oneapi::experimental::bfloat16, /)
OP(bool, ==)
OP(bool, !=)
OP(bool, <)
OP(bool, >)
OP(bool, <=)
OP(bool, >=)
#undef OP
#endif // __SYCL_DEVICE_ONLY__
};

template <typename T, size_t NumRows, size_t NumCols, matrix_layout Layout,
typename Group>
class wi_data {
Expand Down
191 changes: 0 additions & 191 deletions sycl/test/matrix/matrix-bfloat16-test.cpp

This file was deleted.