xref: /aosp_15_r20/external/executorch/backends/vulkan/runtime/graph/containers/SharedObject.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 // @lint-ignore-every CLANGTIDY facebook-hte-BadMemberName
12 
13 #include <executorch/backends/vulkan/runtime/api/api.h>
14 
15 #include <executorch/backends/vulkan/runtime/vk_api/Types.h>
16 
17 #include <executorch/backends/vulkan/runtime/graph/GraphConfig.h>
18 
19 #include <executorch/backends/vulkan/runtime/graph/containers/Value.h>
20 
21 namespace vkcompute {
22 
23 class ComputeGraph;
24 
25 struct SharedObject {
26   friend class ComputeGraph;
27 
28   explicit SharedObject() = default;
29 
30   VkMemoryRequirements aggregate_memory_requirements;
31   std::vector<ValueRef> users;
32   vkapi::Allocation allocation;
33 
34   bool has_user(const ValueRef idx) const;
35   void add_user(ComputeGraph* const graph, const ValueRef idx);
36   void allocate(ComputeGraph* const graph);
37   void bind_users(ComputeGraph* const graph);
38 };
39 
40 } // namespace vkcompute
41