@@ -25,6 +25,9 @@ class Annotations:
2525 buffer: The memory type for the buffer. None means default memory type.
2626 Only meaningful when buffer_specified is True.
2727 buffer_specified: True if buffer was explicitly requested.
28+ pack: Pack configuration as (input_idx, mtype, pad). mtype is None for default.
29+ Only meaningful when pack_specified is True.
30+ pack_specified: True if pack was explicitly requested.
2831 """
2932
3033 unroll_factor : int | None = None
@@ -33,6 +36,8 @@ class Annotations:
3336 parallelize : bool = False
3437 buffer : str | None = None
3538 buffer_specified : bool = False
39+ pack : tuple [int , str | None , bool ] | None = None
40+ pack_specified : bool = False
3641
3742
3843@dataclass (frozen = True )
@@ -152,6 +157,8 @@ def _parse_annotations(self, value: dict[str, Any], context: str) -> Annotations
152157 parallelize = False
153158 buffer : str | None = None
154159 buffer_specified = False
160+ pack : tuple [int , str | None , bool ] | None = None
161+ pack_specified = False
155162
156163 for key , param in value .items ():
157164 if key == "unroll" :
@@ -186,6 +193,9 @@ def _parse_annotations(self, value: dict[str, Any], context: str) -> Annotations
186193 )
187194 buffer = None if param == "default" else param
188195 buffer_specified = True
196+ elif key == "pack" :
197+ pack = self ._parse_pack_param (param , context )
198+ pack_specified = True
189199 else :
190200 raise ScheduleParseError (f"Unknown annotation on { context } : { key } " )
191201
@@ -196,8 +206,42 @@ def _parse_annotations(self, value: dict[str, Any], context: str) -> Annotations
196206 parallelize = parallelize ,
197207 buffer = buffer ,
198208 buffer_specified = buffer_specified ,
209+ pack = pack ,
210+ pack_specified = pack_specified ,
199211 )
200212
213+ def _parse_pack_param (
214+ self , param : Any , context : str
215+ ) -> tuple [int , str | None , bool ]:
216+ """Parse pack parameter into (input_idx, mtype, pad) tuple."""
217+ if not isinstance (param , (list , tuple )) or len (param ) != 3 :
218+ raise ScheduleParseError (
219+ f'`{{"pack" = { param } }}` on { context } : pack parameter should be a tuple (input_idx, mtype, pad).'
220+ )
221+
222+ input_idx , mtype , pad = param
223+
224+ if not isinstance (input_idx , int ):
225+ raise ScheduleParseError (
226+ f'`{{"pack" = { param } }}` on { context } : input_idx should be an integer.'
227+ )
228+
229+ if mtype is not None and not isinstance (mtype , str ):
230+ raise ScheduleParseError (
231+ f'`{{"pack" = { param } }}` on { context } : mtype should be a string or None.'
232+ )
233+
234+ if not isinstance (pad , bool ):
235+ raise ScheduleParseError (
236+ f'`{{"pack" = { param } }}` on { context } : pad should be a boolean.'
237+ )
238+
239+ # Convert "default" to None for mtype
240+ if mtype == "default" :
241+ mtype = None
242+
243+ return (input_idx , mtype , pad )
244+
201245 def _parse_split_syntax (
202246 self , declaration : str
203247 ) -> tuple [str , int | None , int | None ]:
0 commit comments