Skip to content

Commit a264ee5

Browse files
committed
Fix formatting
1 parent 98588cd commit a264ee5

File tree

5 files changed

+36
-38
lines changed

5 files changed

+36
-38
lines changed

sycl/include/sycl/detail/generic_type_traits.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <sycl/half_type.hpp> // for BIsRepresentationT
1818
#include <sycl/multi_ptr.hpp> // for multi_ptr, address_spa...
1919

20-
#include <sycl/ext/oneapi/bfloat16.hpp> // for bfloat16 storage type.
20+
#include <sycl/ext/oneapi/bfloat16.hpp> // for bfloat16 storage type.
2121

2222
#include <cstddef> // for byte
2323
#include <cstdint> // for uint8_t

sycl/include/sycl/detail/vector_convert.hpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -532,15 +532,14 @@ template <typename NativeBFT, typename NativeFloatT, int VecSize>
532532
inline NativeFloatT ConvertBF16ToF(NativeBFT vec) {
533533
if constexpr (VecSize == 1) {
534534
// On device, we interpret bfloat16 as a uint16_t scalar or vector.
535-
static_assert(std::is_same_v<NativeBFT,
536-
sycl::ext::oneapi::detail::Bfloat16StorageT>);
537-
535+
static_assert(
536+
std::is_same_v<NativeBFT, sycl::ext::oneapi::detail::Bfloat16StorageT>);
537+
538538
// Bitcast to BF16 and typecast to float.
539539
bfloat16 convertedBF = sycl::bit_cast<bfloat16>(vec);
540540
return (float)convertedBF;
541-
}
542-
else {
543-
bfloat16 *src = sycl::bit_cast<bfloat16*>(&vec);
541+
} else {
542+
bfloat16 *src = sycl::bit_cast<bfloat16 *>(&vec);
544543

545544
// OpenCL vector of 3 elements is aligned to 4 multiplied by
546545
// the size of data type.
@@ -556,13 +555,12 @@ template <typename NativeFloatT, typename NativeBFT, int VecSize>
556555
inline NativeBFT ConvertFToBF16(NativeFloatT vec) {
557556
if constexpr (VecSize == 1) {
558557
// On device, we interpret bfloat16 as a uint16_t scalar or vector.
559-
static_assert(std::is_same_v<NativeBFT,
560-
sycl::ext::oneapi::detail::Bfloat16StorageT>);
558+
static_assert(
559+
std::is_same_v<NativeBFT, sycl::ext::oneapi::detail::Bfloat16StorageT>);
561560

562561
auto bf16Val = bfloat16(vec);
563562
return sycl::bit_cast<NativeBFT>(bf16Val);
564-
}
565-
else {
563+
} else {
566564
float *src = sycl::bit_cast<float *>(&vec);
567565

568566
// OpenCL vector of 3 elements is aligned to 4 multiplied by

sycl/include/sycl/vector.hpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -796,13 +796,13 @@ template <typename Type, int NumElements> class vec {
796796

797797
// Currently, for BF16 <--> float conversion, we only support
798798
// Round-to-even rounding mode.
799-
constexpr bool isFloatToBF16Conv = std::is_same_v<convertT, bfloat16> &&
800-
std::is_same_v<DataT, float>;
801-
constexpr bool isBF16ToFloatConv = std::is_same_v<DataT, bfloat16> &&
802-
std::is_same_v<convertT, float>;
799+
constexpr bool isFloatToBF16Conv =
800+
std::is_same_v<convertT, bfloat16> && std::is_same_v<DataT, float>;
801+
constexpr bool isBF16ToFloatConv =
802+
std::is_same_v<DataT, bfloat16> && std::is_same_v<convertT, float>;
803803
if constexpr (isFloatToBF16Conv || isBF16ToFloatConv) {
804804
static_assert(roundingMode == rounding_mode::automatic ||
805-
roundingMode == rounding_mode::rte);
805+
roundingMode == rounding_mode::rte);
806806
}
807807

808808
using T = vec_data_t<DataT>;
@@ -848,16 +848,15 @@ template <typename Type, int NumElements> class vec {
848848
if constexpr (isFloatToBF16Conv) {
849849
Result[I] = bfloat16((*this)[I]);
850850
} else
851-
// For bf16 -> float.
852-
if constexpr (isBF16ToFloatConv) {
853-
Result[I] = (float)((*this)[I]);
854-
}
855-
else {
856-
Result.setValue(
857-
I, vec_data<convertT>::get(
858-
detail::convertImpl<T, R, roundingMode, 1, OpenCLT, OpenCLR>(
859-
vec_data<DataT>::get(getValue(I)))));
860-
}
851+
// For bf16 -> float.
852+
if constexpr (isBF16ToFloatConv) {
853+
Result[I] = (float)((*this)[I]);
854+
} else {
855+
Result.setValue(I, vec_data<convertT>::get(
856+
detail::convertImpl<T, R, roundingMode, 1,
857+
OpenCLT, OpenCLR>(
858+
vec_data<DataT>::get(getValue(I)))));
859+
}
861860
}
862861
}
863862

sycl/include/sycl/vector_preview.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,20 +420,21 @@ class vec : public detail::vec_arith<DataT, NumElements> {
420420
using T = ConvertBoolAndByteT<DataT>;
421421
using R = ConvertBoolAndByteT<convertT>;
422422
using bfloat16 = sycl::ext::oneapi::bfloat16;
423-
static_assert(std::is_integral_v<R> || detail::is_floating_point<R>::value ||
423+
static_assert(std::is_integral_v<R> ||
424+
detail::is_floating_point<R>::value ||
424425
std::is_same_v<R, bfloat16>,
425426
"Unsupported convertT");
426427

427428
{
428429
// Currently, for BF16 <--> float conversion, we only support
429430
// Round-to-even rounding mode.
430-
constexpr bool isFloatToBF16Conv = std::is_same_v<convertT, bfloat16> &&
431-
std::is_same_v<DataT, float>;
432-
constexpr bool isBF16ToFloatConv = std::is_same_v<DataT, bfloat16> &&
433-
std::is_same_v<convertT, float>;
431+
constexpr bool isFloatToBF16Conv =
432+
std::is_same_v<convertT, bfloat16> && std::is_same_v<DataT, float>;
433+
constexpr bool isBF16ToFloatConv =
434+
std::is_same_v<DataT, bfloat16> && std::is_same_v<convertT, float>;
434435
if constexpr (isFloatToBF16Conv || isBF16ToFloatConv) {
435436
static_assert(roundingMode == rounding_mode::automatic ||
436-
roundingMode == rounding_mode::rte);
437+
roundingMode == rounding_mode::rte);
437438
}
438439
}
439440

sycl/test-e2e/BFloat16/bfloat16_vec.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,13 @@ int main() {
190190
acc[13] = (brev2[0] == device_float[0]) && (brev2[1] == device_float[1]);
191191
});
192192
}).wait();
193-
// clang-format on
193+
// clang-format on
194194

195-
sycl::host_accessor h_acc(buf, sycl::read_only);
196-
for(unsigned i = 0; i < N; i++){
195+
sycl::host_accessor h_acc(buf, sycl::read_only);
196+
for (unsigned i = 0; i < N; i++) {
197197
assert(h_acc[i]);
198-
}
198+
}
199199

200-
std::cout<< "Test Passed."<<std::endl;
201-
return 0;
200+
std::cout << "Test Passed." << std::endl;
201+
return 0;
202202
}

0 commit comments

Comments
 (0)