MCPcopy Create free account
hub / github.com/apache/tvm / sblock_alloc_buffer

Function sblock_alloc_buffer

python/tvm/tirx/script/builder/ir.py:906–990  ·  view source on GitHub ↗

SBlock-level buffer allocation function. Parameters ---------- shape : Union[List[PrimExpr], Tuple[PrimExpr], PrimExpr, Integral] The type of the buffer prior to flattening. dtype : str The data type in the content of the buffer. data : Var The pointer to

(
    shape: list[PrimExpr] | tuple[PrimExpr] | PrimExpr | Integral,
    dtype: str = "float32",
    data: Var = None,
    strides: list[PrimExpr] | None = None,
    elem_offset: PrimExpr = None,
    scope: str = "global",
    align: int = -1,
    offset_factor: int = 0,
    buffer_type: str = "default",
    axis_separators: list[int] | None = None,
    layout: str | Layout | None = "default",
    allocated_addr: int | tuple[int, ...] | None = None,
)

Source from the content-addressed store, hash-verified

904
905
906def sblock_alloc_buffer(
907 shape: list[PrimExpr] | tuple[PrimExpr] | PrimExpr | Integral,
908 dtype: str = "float32",
909 data: Var = None,
910 strides: list[PrimExpr] | None = None,
911 elem_offset: PrimExpr = None,
912 scope: str = "global",
913 align: int = -1,
914 offset_factor: int = 0,
915 buffer_type: str = "default",
916 axis_separators: list[int] | None = None,
917 layout: str | Layout | None = "default",
918 allocated_addr: int | tuple[int, ...] | None = None,
919) -> Buffer:
920 """SBlock-level buffer allocation function.
921
922 Parameters
923 ----------
924 shape : Union[List[PrimExpr], Tuple[PrimExpr], PrimExpr, Integral]
925 The type of the buffer prior to flattening.
926 dtype : str
927 The data type in the content of the buffer.
928 data : Var
929 The pointer to the head of the data.
930 strides : List[PrimExpr]
931 The strides of each dimension.
932 elem_offset : PrimExpr
933 The offset in terms of number of dtype elements (including lanes).
934 scope : str
935 The optional storage scope of buffer data pointer.
936 align : int
937 The alignment requirement of data pointer in bytes.
938 offset_factor : int
939 The factor of elem_offset field.
940 buffer_type : str
941 The buffer type.
942 axis_separators : List[int]
943 The separators between input axes when generating flattened output axes.
944
945 layout: Optional[Union[str, Layout]]
946 The layout of the buffer.
947
948 allocated_addr: Optional[Union[int, Tuple[int]]]
949 The address of the allocated buffer. Might be multi-dimensional.
950 There can be pooled storage scopes on some devices. For example,
951 the Trainium device has a pooled storage scope for the SRAN buffers. ("trn.sbuf")
952 CUDA has a pooled storage scope for the shared memory ("shared.dyn")
953
954 Returns
955 -------
956 res : Buffer
957 The allocated buffer.
958 """
959 shape = (shape,) if isinstance(shape, PrimExpr | Integral) else shape
960 if strides is not None:
961 strides = [Var(s, "int32") if isinstance(s, str) else s for s in strides]
962 else:
963 strides = []

Callers

nothing calls this directly

Calls 5

_get_layoutFunction · 0.85
_record_meta_resourceFunction · 0.85
add_callbackMethod · 0.80
VarClass · 0.50
__enter__Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…