Skip to content

buffer

Provide internal nodes that host compilers can target for the buffer/view substrate without defining a user-facing array API.

Classes:

BufferOwnerType

BufferOwnerType()

Bases: OpaqueHandleType

Methods:

Source code in src/irx/astx/buffer.py
28
29
30
31
32
def __init__(self) -> None:
    """
    title: Initialize the buffer owner handle type.
    """
    super().__init__("irx_buffer_owner_handle")

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in src/irx/astx/ffi.py
101
102
103
104
105
106
107
108
109
110
111
112
113
114
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for an opaque-handle type.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    return self._prepare_struct(
        f"OPAQUE-HANDLE[{self.handle_name}]",
        self.handle_name,
        simplified,
    )

BufferViewDescriptor

BufferViewDescriptor(
    metadata: BufferViewMetadata,
    element_type: DataType | None = None,
)

Bases: DataType

Methods:

Source code in src/irx/astx/buffer.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
def __init__(
    self,
    metadata: BufferViewMetadata,
    element_type: astx.DataType | None = None,
) -> None:
    """
    title: Initialize one buffer view descriptor.
    parameters:
      metadata:
        type: BufferViewMetadata
      element_type:
        type: astx.DataType | None
    """
    super().__init__()
    self.metadata = metadata
    self.type_ = BufferViewType(element_type)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in src/irx/astx/buffer.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    _ = simplified
    return self._prepare_struct(
        "BufferViewDescriptor",
        cast(astx.base.ReprStruct, repr(self.metadata)),
        simplified,
    )

BufferViewIndex

BufferViewIndex(base: AST, indices: Sequence[AST])

Bases: DataType

Reads one scalar element by computing offset_bytes plus the sum of index*stride byte offsets over the canonical buffer view descriptor. attributes: base: type: astx.AST indices: type: list[astx.AST] type_: type: astx.DataType

Methods:

Source code in src/irx/astx/buffer.py
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
def __init__(
    self,
    base: astx.AST,
    indices: Sequence[astx.AST],
) -> None:
    """
    title: Initialize one low-level indexed read.
    parameters:
      base:
        type: astx.AST
      indices:
        type: Sequence[astx.AST]
    """
    super().__init__()
    if not indices:
        raise ValueError(
            "buffer view indexing requires at least one index"
        )
    self.base = base
    self.indices = list(indices)
    self.type_ = AnyType()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in src/irx/astx/buffer.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "base": self.base.get_struct(simplified),
        "indices": [
            index.get_struct(simplified) for index in self.indices
        ],
    }
    return self._prepare_struct(
        "BufferViewIndex",
        cast(astx.base.ReprStruct, value),
        simplified,
    )

BufferViewRelease

BufferViewRelease(view: AST)

Bases: DataType

Methods:

Source code in src/irx/astx/buffer.py
381
382
383
384
385
386
387
388
389
390
def __init__(self, view: astx.AST) -> None:
    """
    title: Initialize one buffer release helper call.
    parameters:
      view:
        type: astx.AST
    """
    super().__init__()
    self.view = view
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in src/irx/astx/buffer.py
392
393
394
395
396
397
398
399
400
401
402
403
404
405
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    return self._prepare_struct(
        "BufferViewRelease",
        self.view.get_struct(simplified),
        simplified,
    )

BufferViewRetain

BufferViewRetain(view: AST)

Bases: DataType

Methods:

Source code in src/irx/astx/buffer.py
340
341
342
343
344
345
346
347
348
349
def __init__(self, view: astx.AST) -> None:
    """
    title: Initialize one buffer retain helper call.
    parameters:
      view:
        type: astx.AST
    """
    super().__init__()
    self.view = view
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in src/irx/astx/buffer.py
351
352
353
354
355
356
357
358
359
360
361
362
363
364
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    return self._prepare_struct(
        "BufferViewRetain",
        self.view.get_struct(simplified),
        simplified,
    )

BufferViewStore

BufferViewStore(
    base: AST, indices: Sequence[AST], value: AST
)

Bases: DataType

Stores one scalar element by computing the canonical descriptor element address. This is not a user-facing array mutation API. attributes: base: type: astx.AST indices: type: list[astx.AST] value: type: astx.AST type_: type: astx.Int32

Methods:

Source code in src/irx/astx/buffer.py
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
def __init__(
    self,
    base: astx.AST,
    indices: Sequence[astx.AST],
    value: astx.AST,
) -> None:
    """
    title: Initialize one low-level indexed store.
    parameters:
      base:
        type: astx.AST
      indices:
        type: Sequence[astx.AST]
      value:
        type: astx.AST
    """
    super().__init__()
    if not indices:
        raise ValueError(
            "buffer view indexing requires at least one index"
        )
    self.base = base
    self.indices = list(indices)
    self.value = value
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in src/irx/astx/buffer.py
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "base": self.base.get_struct(simplified),
        "indices": [
            index.get_struct(simplified) for index in self.indices
        ],
        "value": self.value.get_struct(simplified),
    }
    return self._prepare_struct(
        "BufferViewStore",
        cast(astx.base.ReprStruct, value),
        simplified,
    )

BufferViewType

BufferViewType(element_type: DataType | None = None)

Bases: AnyType

Source code in src/irx/astx/buffer.py
54
55
56
57
58
59
60
61
62
def __init__(self, element_type: astx.DataType | None = None) -> None:
    """
    title: Initialize a buffer view descriptor type.
    parameters:
      element_type:
        type: astx.DataType | None
    """
    super().__init__()
    self.element_type = element_type

BufferViewWrite

BufferViewWrite(
    view: AST, value: AST, *, byte_offset: int = 0
)

Bases: DataType

Writes one 8-bit integer at offset_bytes + byte_offset. This is not a generic typed element store or user-facing array mutation API. attributes: view: type: astx.AST value: type: astx.AST byte_offset: type: int type_: type: astx.Int32

Methods:

Source code in src/irx/astx/buffer.py
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
def __init__(
    self,
    view: astx.AST,
    value: astx.AST,
    *,
    byte_offset: int = 0,
) -> None:
    """
    title: Initialize one low-level view write.
    parameters:
      view:
        type: astx.AST
      value:
        type: astx.AST
      byte_offset:
        type: int
    """
    super().__init__()
    self.view = view
    self.value = value
    self.byte_offset = byte_offset
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in src/irx/astx/buffer.py
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "view": self.view.get_struct(simplified),
        "value": self.value.get_struct(simplified),
        "byte_offset": self.byte_offset,
    }
    return self._prepare_struct(
        "BufferViewWrite",
        cast(astx.base.ReprStruct, value),
        simplified,
    )