1717"""USMP Utilities and Data Structures"""
1818# pylint: disable=invalid-name
1919
20- from typing import Dict , Optional
20+ from typing import Dict , Optional , List
2121
2222from tvm ._ffi import register_object
2323from tvm .runtime import Object
2727CANDIDATE_MEMORY_POOL_ATTR = "candidate_memory_pools"
2828
2929
30+ @register_object ("tir.usmp.PoolInfo" )
31+ class PoolInfo (Object ):
32+ """PoolInfo object holds information related to memory pools
33+ where the statically sized allocate nodes will pooled into.
34+
35+ Parameters
36+ ----------
37+ pool_name : str
38+ The name of the memory pool
39+
40+ target_access : Dict[Target, str]
41+ A dictionary where keys describe which targets could
42+ access the pool where value could take the values :
43+ a) "rw" : read-write access
44+ b) "ro" : write-only acesss
45+
46+ size_hint_bytes : Optional[int]
47+ The expected size hint to be used by the allocator.
48+ The default value would be -1 which means the pool
49+ is not size restricted.
50+
51+ """
52+
53+ READ_WRITE_ACCESS = "rw"
54+ READ_ONLY_ACCESS = "ro"
55+
56+ def __init__ (
57+ self , pool_name : str , target_access : Dict [Target , str ], size_hint_bytes : Optional [int ] = - 1
58+ ):
59+ self .__init_handle_by_constructor__ (
60+ _ffi_api .PoolInfo , # type: ignore # pylint: disable=no-member
61+ pool_name ,
62+ target_access ,
63+ size_hint_bytes ,
64+ )
65+
66+
3067@register_object ("tir.usmp.BufferInfo" )
3168class BufferInfo (Object ):
3269 """BufferInfo object holds information related to buffers
@@ -41,7 +78,10 @@ class BufferInfo(Object):
4178 size_bytes : int
4279 The size in bytes
4380
44- alignment : int
81+ pool_candidates : List[PoolInfo]
82+ The list of candidates pools this buffer could be placed
83+
84+ alignment : Optional[int]
4585 The byte alignment required in the workspace memory
4686
4787 """
@@ -50,12 +90,14 @@ def __init__(
5090 self ,
5191 name_hint : str ,
5292 size_bytes : int ,
53- alignment : int = None ,
93+ pool_candidates : List [PoolInfo ],
94+ alignment : Optional [int ] = None ,
5495 ):
5596 self .__init_handle_by_constructor__ (
5697 _ffi_api .BufferInfo , # type: ignore # pylint: disable=no-member
5798 name_hint ,
5899 size_bytes ,
100+ pool_candidates ,
59101 alignment ,
60102 )
61103
@@ -72,43 +114,6 @@ def set_conflicts(self, conflicts: list):
72114 _ffi_api .BufferInfoSetConflicts (self , conflicts )
73115
74116
75- @register_object ("tir.usmp.PoolInfo" )
76- class PoolInfo (Object ):
77- """PoolInfo object holds information related to memory pools
78- where the statically sized allocate nodes will pooled into.
79-
80- Parameters
81- ----------
82- pool_name : str
83- The name of the memory pool
84-
85- target_access : Dict[Target, str]
86- A dictionary where keys describe which targets could
87- access the pool where value could take the values :
88- a) "rw" : read-write access
89- b) "ro" : write-only acesss
90-
91- size_hint_bytes : Optional[int]
92- The expected size hint to be used by the allocator.
93- The default value would be -1 which means the pool
94- is not size restricted.
95-
96- """
97-
98- READ_WRITE_ACCESS = "rw"
99- READ_ONLY_ACCESS = "ro"
100-
101- def __init__ (
102- self , pool_name : str , target_access : Dict [Target , str ], size_hint_bytes : Optional [int ] = - 1
103- ):
104- self .__init_handle_by_constructor__ (
105- _ffi_api .PoolInfo , # type: ignore # pylint: disable=no-member
106- pool_name ,
107- target_access ,
108- size_hint_bytes ,
109- )
110-
111-
112117@register_object ("tir.usmp.PoolAllocation" )
113118class PoolAllocation (Object ):
114119 """PoolAllocation object holds information related to an allocation
0 commit comments