Skip to content

[ET-VK] Organize StringUtil.h and Utils.h into utils/ and VkUtils.h #4123

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

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion backends/vulkan/runtime/api/Adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <executorch/backends/vulkan/runtime/api/Pipeline.h>
#include <executorch/backends/vulkan/runtime/api/Shader.h>
#include <executorch/backends/vulkan/runtime/api/Utils.h>
#include <executorch/backends/vulkan/runtime/api/utils/VecUtils.h>

#include <executorch/backends/vulkan/runtime/api/memory/Allocator.h>

Expand Down
2 changes: 1 addition & 1 deletion backends/vulkan/runtime/api/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <executorch/backends/vulkan/runtime/api/Descriptor.h>
#include <executorch/backends/vulkan/runtime/api/Pipeline.h>
#include <executorch/backends/vulkan/runtime/api/Shader.h>
#include <executorch/backends/vulkan/runtime/api/Utils.h>
#include <executorch/backends/vulkan/runtime/api/utils/VecUtils.h>

#include <executorch/backends/vulkan/runtime/api/memory/Buffer.h>
#include <executorch/backends/vulkan/runtime/api/memory/Image.h>
Expand Down
1 change: 1 addition & 0 deletions backends/vulkan/runtime/api/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include <executorch/backends/vulkan/runtime/api/Context.h>
#include <executorch/backends/vulkan/runtime/api/VkUtils.h>

#ifndef VULKAN_DESCRIPTOR_POOL_SIZE
#define VULKAN_DESCRIPTOR_POOL_SIZE 1024u
Expand Down
2 changes: 2 additions & 0 deletions backends/vulkan/runtime/api/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <executorch/backends/vulkan/runtime/api/QueryPool.h>
#include <executorch/backends/vulkan/runtime/api/Runtime.h>

#include <executorch/backends/vulkan/runtime/api/utils/MacroUtils.h>

namespace vkcompute {
namespace api {

Expand Down
3 changes: 2 additions & 1 deletion backends/vulkan/runtime/api/Descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

#include <executorch/backends/vulkan/runtime/api/Descriptor.h>
#include <executorch/backends/vulkan/runtime/api/Utils.h>

#include <executorch/backends/vulkan/runtime/api/utils/VecUtils.h>

#include <algorithm>
#include <utility>
Expand Down
22 changes: 11 additions & 11 deletions backends/vulkan/runtime/api/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@

#include <executorch/backends/vulkan/runtime/api/vk_api.h>

#include <executorch/backends/vulkan/runtime/api/StringUtil.h>
#include <executorch/backends/vulkan/runtime/api/utils/StringUtils.h>

#include <exception>
#include <ostream>
#include <string>
#include <vector>

#define VK_CHECK(function) \
do { \
const VkResult result = (function); \
if (VK_SUCCESS != result) { \
throw ::vkcompute::api::Error( \
{__func__, __FILE__, static_cast<uint32_t>(__LINE__)}, \
::vkcompute::api::concat_str(#function, " returned ", result)); \
} \
#define VK_CHECK(function) \
do { \
const VkResult result = (function); \
if (VK_SUCCESS != result) { \
throw ::vkcompute::api::Error( \
{__func__, __FILE__, static_cast<uint32_t>(__LINE__)}, \
::vkcompute::utils::concat_str(#function, " returned ", result)); \
} \
} while (false)

#define VK_CHECK_COND(cond, ...) \
Expand All @@ -34,15 +34,15 @@
throw ::vkcompute::api::Error( \
{__func__, __FILE__, static_cast<uint32_t>(__LINE__)}, \
#cond, \
::vkcompute::api::concat_str(__VA_ARGS__)); \
::vkcompute::utils::concat_str(__VA_ARGS__)); \
} \
} while (false)

#define VK_THROW(...) \
do { \
throw ::vkcompute::api::Error( \
{__func__, __FILE__, static_cast<uint32_t>(__LINE__)}, \
::vkcompute::api::concat_str(__VA_ARGS__)); \
::vkcompute::utils::concat_str(__VA_ARGS__)); \
} while (false)

namespace vkcompute {
Expand Down
2 changes: 1 addition & 1 deletion backends/vulkan/runtime/api/QueryPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// @lint-ignore-every CLANGTIDY facebook-hte-BadImplicitCast

#include <executorch/backends/vulkan/runtime/api/QueryPool.h>
#include <executorch/backends/vulkan/runtime/api/Utils.h>
#include <executorch/backends/vulkan/runtime/api/utils/VecUtils.h>

#include <cmath>
#include <iomanip>
Expand Down
3 changes: 2 additions & 1 deletion backends/vulkan/runtime/api/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include <executorch/backends/vulkan/runtime/api/vk_api.h>

#include <executorch/backends/vulkan/runtime/api/Types.h>
#include <executorch/backends/vulkan/runtime/api/Utils.h>

#include <executorch/backends/vulkan/runtime/api/utils/VecUtils.h>

#include <mutex>
#include <unordered_map>
Expand Down
2 changes: 1 addition & 1 deletion backends/vulkan/runtime/api/Tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

#include <executorch/backends/vulkan/runtime/api/Tensor.h>
#include <executorch/backends/vulkan/runtime/api/Utils.h>
#include <executorch/backends/vulkan/runtime/api/VkUtils.h>

namespace vkcompute {

Expand Down
21 changes: 21 additions & 0 deletions backends/vulkan/runtime/api/VkUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 <executorch/backends/vulkan/runtime/api/vk_api.h>

namespace vkcompute {
namespace api {

inline VkExtent3D create_extent3d(const utils::uvec3& extents) {
return VkExtent3D{extents.data[0u], extents.data[1u], extents.data[2u]};
}

} // namespace api
} // namespace vkcompute
3 changes: 2 additions & 1 deletion backends/vulkan/runtime/api/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <executorch/backends/vulkan/runtime/api/ShaderRegistry.h>
#include <executorch/backends/vulkan/runtime/api/StorageBuffer.h>
#include <executorch/backends/vulkan/runtime/api/Tensor.h>
#include <executorch/backends/vulkan/runtime/api/Utils.h>

#include <executorch/backends/vulkan/runtime/api/utils/VecUtils.h>

#include <executorch/backends/vulkan/runtime/api/memory/Allocation.h>
#include <executorch/backends/vulkan/runtime/api/memory/Allocator.h>
Expand Down
4 changes: 2 additions & 2 deletions backends/vulkan/runtime/api/memory/Allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

#include <executorch/backends/vulkan/runtime/api/vk_api.h>

#include <executorch/backends/vulkan/runtime/api/Utils.h>

#include <executorch/backends/vulkan/runtime/api/memory/vma_api.h>

#include <executorch/backends/vulkan/runtime/api/memory/Allocation.h>
#include <executorch/backends/vulkan/runtime/api/memory/Buffer.h>
#include <executorch/backends/vulkan/runtime/api/memory/Image.h>

#include <executorch/backends/vulkan/runtime/api/utils/VecUtils.h>

namespace vkcompute {
namespace api {

Expand Down
2 changes: 1 addition & 1 deletion backends/vulkan/runtime/api/memory/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <executorch/backends/vulkan/runtime/api/vk_api.h>

#include <executorch/backends/vulkan/runtime/api/Utils.h>
#include <executorch/backends/vulkan/runtime/api/utils/VecUtils.h>

#include <executorch/backends/vulkan/runtime/api/memory/vma_api.h>

Expand Down
2 changes: 1 addition & 1 deletion backends/vulkan/runtime/api/memory/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <executorch/backends/vulkan/runtime/api/vk_api.h>

#include <executorch/backends/vulkan/runtime/api/Utils.h>
#include <executorch/backends/vulkan/runtime/api/utils/VecUtils.h>

#include <executorch/backends/vulkan/runtime/api/memory/vma_api.h>

Expand Down
16 changes: 16 additions & 0 deletions backends/vulkan/runtime/api/utils/MacroUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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

// Suppress an unused variable. Copied from C10_UNUSED
#if defined(_MSC_VER) && !defined(__clang__)
#define VK_UNUSED __pragma(warning(suppress : 4100 4101))
#else
#define VK_UNUSED __attribute__((__unused__))
#endif //_MSC_VER
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
#pragma once
// @lint-ignore-every CLANGTIDY facebook-hte-LocalUncheckedArrayBounds

#include <exception>
#include <ostream>
#include <sstream>
#include <string>
#include <vector>

namespace vkcompute {
namespace api {
namespace utils {

namespace detail {

Expand Down Expand Up @@ -86,5 +84,5 @@ inline std::string concat_str(const Args&... args) {
typename detail::CanonicalizeStrTypes<Args>::type...>::call(args...);
}

} // namespace api
} // namespace utils
} // namespace vkcompute
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@

#include <executorch/backends/vulkan/runtime/api/Exception.h>

// Compiler Macros

// Suppress an unused variable. Copied from C10_UNUSED
#if defined(_MSC_VER) && !defined(__clang__)
#define VK_UNUSED __pragma(warning(suppress : 4100 4101))
#else
#define VK_UNUSED __attribute__((__unused__))
#endif //_MSC_VER

namespace vkcompute {
namespace utils {

Expand Down Expand Up @@ -459,12 +450,4 @@ inline int64_t multiply_integers(Iter begin, Iter end) {
}

} // namespace utils

namespace api {

inline VkExtent3D create_extent3d(const utils::uvec3& extents) {
return VkExtent3D{extents.data[0u], extents.data[1u], extents.data[2u]};
}

} // namespace api
} // namespace vkcompute
2 changes: 1 addition & 1 deletion backends/vulkan/runtime/graph/Logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#include <executorch/backends/vulkan/runtime/api/Utils.h>
#include <executorch/backends/vulkan/runtime/api/api.h>

#include <optional>
#include <ostream>
Expand Down
2 changes: 1 addition & 1 deletion backends/vulkan/runtime/graph/ops/impl/Arange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/

#include <executorch/backends/vulkan/runtime/api/Utils.h>
#include <executorch/backends/vulkan/runtime/api/api.h>

#include <executorch/backends/vulkan/runtime/graph/ops/OperatorRegistry.h>

Expand Down
Loading