xref: /aosp_15_r20/external/executorch/backends/vulkan/runtime/graph/Logging.h (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #pragma once
10 
11 #include <executorch/backends/vulkan/runtime/api/api.h>
12 
13 #include <optional>
14 #include <ostream>
15 #include <vector>
16 
17 namespace vkcompute {
18 
19 template <typename T>
20 inline std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
21   os << '[';
22   for (const auto& elem : vec) {
23     os << elem << ',';
24   }
25   os << ']';
26   return os; // Return the ostream to allow chaining
27 }
28 
29 inline std::ostream& operator<<(std::ostream& os, const utils::uvec3& v) {
30   return utils::operator<<(os, v);
31 }
32 
33 inline std::ostream& operator<<(std::ostream& os, const utils::uvec4& v) {
34   return utils::operator<<(os, v);
35 }
36 
37 inline std::ostream& operator<<(std::ostream& os, const utils::ivec3& v) {
38   return utils::operator<<(os, v);
39 }
40 
41 inline std::ostream& operator<<(std::ostream& os, const utils::ivec4& v) {
42   return utils::operator<<(os, v);
43 }
44 
45 template <typename T>
46 inline std::ostream& operator<<(std::ostream& os, const std::optional<T>& opt) {
47   os << "[";
48   if (opt) {
49     os << opt.value();
50   }
51   os << "]";
52   return os;
53 }
54 
55 } // namespace vkcompute
56