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

Class ActiveSet

python/tvm/tirx/exec_context.py:125–184  ·  view source on GitHub ↗

Active thread set represented by a TileLayout.

Source from the content-addressed store, hash-verified

123
124@dataclass(frozen=True)
125class ActiveSet:
126 """Active thread set represented by a TileLayout."""
127
128 layout: TileLayout
129
130 @staticmethod
131 def from_axes(axes: list[tuple[str, AxisRange]]) -> ActiveSet:
132 shard = [Iter(axis_range.extent, axis_range.stride, name) for name, axis_range in axes]
133 offset = {
134 Axis.get(name): axis_range.offset for name, axis_range in axes if axis_range.offset != 0
135 }
136 return ActiveSet(TileLayout.from_iters(shard, [], offset))
137
138 @property
139 def size(self) -> int:
140 result = 1
141 for it in self.layout.shard:
142 result *= int(it.extent)
143 return result
144
145 @property
146 def axis_names(self) -> list[str]:
147 return [str(it.axis.name) for it in self.layout.shard]
148
149 def axis(self, name: str) -> AxisRange:
150 for it in self.layout.shard:
151 if str(it.axis.name) != name:
152 continue
153 offset = 0
154 for axis, value in self.layout.offset.items():
155 if str(axis.name) == name:
156 offset = int(value)
157 break
158 return AxisRange(int(it.extent), offset, int(it.stride))
159 raise ValueError(f"unknown active-set axis: {name!r}")
160
161 def replace_axis(self, axis: str, axis_range: AxisRange) -> ActiveSet:
162 axes: list[tuple[str, AxisRange]] = []
163 found = False
164 for name in self.axis_names:
165 if name == axis:
166 axes.append((name, axis_range))
167 found = True
168 else:
169 axes.append((name, self.axis(name)))
170 if not found:
171 raise ValueError(f"unknown active-set axis: {axis!r}")
172 return ActiveSet.from_axes(axes)
173
174 @property
175 def laneid(self) -> AxisRange:
176 return self.axis("laneid")
177
178 @property
179 def warpid(self) -> AxisRange:
180 return self.axis("warpid")
181
182 @property

Callers 1

from_axesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…