/* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include namespace executorch { namespace vec { // See Note [CPU_CAPABILITY namespace] inline namespace CPU_CAPABILITY { inline Vectorized convert_to_bool(Vectorized x) { __at_align__ bool buffer[x.size()]; x.ne(Vectorized(0)).store(buffer); Vectorized ret; static_assert(x.size() == ret.size(), ""); std::memcpy(ret, buffer, ret.size() * sizeof(bool)); return ret; } template <> inline Vectorized Vectorized::loadu(const void* ptr) { // See NOTE [Loading boolean values] return convert_to_bool(Vectorized::loadu(ptr)); } template <> inline Vectorized Vectorized::loadu(const void* ptr, int64_t count) { // See NOTE [Loading boolean values] return convert_to_bool(Vectorized::loadu(ptr, count)); } } // namespace CPU_CAPABILITY } // namespace vec } // namespace executorch