Skip to content

Commit 59d9bad

Browse files
authored
Use c++17 for size test
Differential Revision: D62389344 Pull Request resolved: #5178
1 parent 542ecb5 commit 59d9bad

File tree

6 files changed

+16
-37
lines changed

6 files changed

+16
-37
lines changed

extension/llm/custom_ops/op_sdpa.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static inline scalar_t* conditional_data_ptr(scalar_t* ptr, scalar_t* ptr2) {
158158
template <
159159
typename scalar_t,
160160
typename std::enable_if_t<
161-
::executorch::runtime::is_reduced_floating_point<scalar_t>::value,
161+
::executorch::runtime::is_reduced_floating_point_v<scalar_t>,
162162
int> = 0>
163163
static inline scalar_t* conditional_data_ptr(float* ptr, scalar_t* ptr2) {
164164
(void)ptr;
@@ -247,7 +247,7 @@ void cpu_flash_attention(
247247
"KV_split_size must be greater than q_split_size");
248248

249249
constexpr bool is_reduced_type =
250-
::executorch::runtime::is_reduced_floating_point<scalar_t>::value;
250+
::executorch::runtime::is_reduced_floating_point_v<scalar_t>;
251251

252252
ET_CHECK_MSG(
253253
!is_reduced_type, "FlashAttention does not support reduced types.");

runtime/core/exec_aten/util/scalar_type_util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ struct is_reduced_floating_point
7373
bool,
7474
std::is_same<T, torch::executor::Half>::value ||
7575
std::is_same<T, torch::executor::BFloat16>::value> {};
76+
77+
template <typename T>
78+
constexpr bool is_reduced_floating_point_v =
79+
is_reduced_floating_point<T>::value;
7680
#endif
7781

7882
/// Maps ScalarTypes to C++ types.

runtime/core/portable_type/half.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct alignas(2) Half {
6262
namespace internal {
6363

6464
inline float fp32_from_bits(uint32_t w) {
65-
static_assert(sizeof(float) == sizeof(uint32_t), "");
65+
static_assert(sizeof(float) == sizeof(uint32_t));
6666
union {
6767
uint32_t as_bits;
6868
float as_value;
@@ -71,7 +71,7 @@ inline float fp32_from_bits(uint32_t w) {
7171
}
7272

7373
inline uint32_t fp32_to_bits(float f) {
74-
static_assert(sizeof(float) == sizeof(uint32_t), "");
74+
static_assert(sizeof(float) == sizeof(uint32_t));
7575
union {
7676
float as_value;
7777
uint32_t as_bits;

runtime/core/portable_type/string_view.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,10 @@ class basic_string_view final {
7979
}
8080

8181
constexpr const_reference at(size_type pos) const {
82-
return (pos >= size_)
83-
? (ET_ASSERT_MESSAGE_EMIT(
84-
" (%s): "
85-
"string_view::operator[] or string_view::at() out of range",
86-
pos >= size_),
87-
torch::executor::runtime_abort())
88-
: at_(pos);
82+
ET_CHECK_MSG(
83+
pos >= size_,
84+
"string_view::operator[] or string_view::at() out of range");
85+
return at_(pos);
8986
}
9087

9188
constexpr const_reference front() const {
@@ -140,13 +137,9 @@ class basic_string_view final {
140137

141138
constexpr basic_string_view substr(size_type pos = 0, size_type count = npos)
142139
const {
143-
return (pos > size_)
144-
? (ET_ASSERT_MESSAGE_EMIT(
145-
" (%s): "
146-
"basic_string_view::substr parameter out of bounds.",
147-
pos > size_),
148-
torch::executor::runtime_abort())
149-
: substr_(pos, count);
140+
ET_CHECK_MSG(
141+
pos > size_, "basic_string_view::substr parameter out of bounds.");
142+
return substr_(pos, count);
150143
}
151144

152145
constexpr int compare(basic_string_view rhs) const noexcept {

test/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
cmake_minimum_required(VERSION 3.19)
2020
project(size_test)
2121

22-
# Use C++11 for size test.
23-
set(CMAKE_CXX_STANDARD 11)
22+
set(CMAKE_CXX_STANDARD 17)
2423

2524
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..)
2625

test/build_size_test.sh

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,12 @@ set -e
1111
# shellcheck source=/dev/null
1212
source "$(dirname "${BASH_SOURCE[0]}")/../.ci/scripts/utils.sh"
1313

14-
# Set compile flags for Clang and GCC.
15-
# -Wno-gnu allows us to use gnu statement-expressions.
16-
# -Werror -Wc++17* ensure we do not use features from C++17.
17-
CXX_FLAGS="-Wno-gnu"
18-
compiler=$(cc --version)
19-
if [[ $compiler == *"clang"* ]]; then
20-
CXX_FLAGS="$CXX_FLAGS -Werror -Wc++17-extensions -Wc++14-extensions"
21-
elif [[ $compiler == *"cc"* ]]; then
22-
CXX_FLAGS="$CXX_FLAGS -Werror -Wc++17-compat -Wc++14-compat"
23-
else
24-
echo "Unknown compiler: $compiler"
25-
exit 1
26-
fi
27-
echo "Using compiler $compiler with flags $CXX_FLAGS"
28-
2914
cmake_install_executorch_lib() {
3015
echo "Installing libexecutorch.a"
3116
rm -rf cmake-out
3217

3318
retry cmake -DBUCK2="$BUCK2" \
34-
-DCMAKE_CXX_STANDARD=11 \
3519
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
36-
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
3720
-DCMAKE_INSTALL_PREFIX=cmake-out \
3821
-DCMAKE_BUILD_TYPE=Release \
3922
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \

0 commit comments

Comments
 (0)