-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mariya Podchishchaeva <[email protected]>
- Loading branch information
1 parent
e87838c
commit 83403c9
Showing
10 changed files
with
718 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
//==-------------- half_type.hpp --- SYCL half type ------------------------==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <functional> | ||
|
||
namespace cl { | ||
namespace sycl { | ||
namespace detail { | ||
namespace half_impl { | ||
|
||
class half { | ||
public: | ||
half() = default; | ||
half(const half &) = default; | ||
half(half &&) = default; | ||
|
||
half(const float &rhs); | ||
|
||
half &operator=(const half &rhs) = default; | ||
|
||
// Operator +=, -=, *=, /= | ||
half &operator+=(const half &rhs); | ||
|
||
half &operator-=(const half &rhs); | ||
|
||
half &operator*=(const half &rhs); | ||
|
||
half &operator/=(const half &rhs); | ||
|
||
// Operator ++, -- | ||
half &operator++() { | ||
*this += 1; | ||
return *this; | ||
} | ||
|
||
half operator++(int) { | ||
half ret(*this); | ||
operator++(); | ||
return ret; | ||
} | ||
|
||
half &operator--() { | ||
*this -= 1; | ||
return *this; | ||
} | ||
|
||
half operator--(int) { | ||
half ret(*this); | ||
operator--(); | ||
return ret; | ||
} | ||
|
||
// Operator float | ||
operator float() const; | ||
|
||
template <typename Key> friend struct std::hash; | ||
|
||
private: | ||
uint16_t Buf; | ||
}; | ||
} // namespace half_impl | ||
} // namespace detail | ||
|
||
} // namespace sycl | ||
} // namespace cl | ||
|
||
namespace std { | ||
|
||
template <> struct hash<cl::sycl::detail::half_impl::half> { | ||
size_t operator()(cl::sycl::detail::half_impl::half const &key) const | ||
noexcept { | ||
return hash<uint16_t>()(key.Buf); | ||
} | ||
}; | ||
|
||
} // namespace std |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.