Skip to content

Commit a1e9c99

Browse files
committed
Make BlockSizeOrigin host_str return 1 for block_size=1 case
ghstack-source-id: 345b40f Pull-Request-resolved: #40
1 parent bd3d984 commit a1e9c99

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

helion/_compiler/variable_origin.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,18 @@ class BlockSizeOrigin(Origin):
224224
block_size_idx: int
225225

226226
def host_str(self) -> str:
227+
"""
228+
Get the host-side string representation of a block size variable.
229+
If the block size variable was not created (e.g., block size == 1),
230+
return the literal '1'.
231+
"""
227232
from .device_function import DeviceFunction
228233

229-
host_str = DeviceFunction.current().block_size_var(self.block_size_idx)
230-
assert host_str is not None
231-
return host_str
234+
# Look up the block size variable name; if not set (e.g., size==1), use literal 1
235+
var = DeviceFunction.current().block_size_var(self.block_size_idx)
236+
if var is None:
237+
return "1"
238+
return var
232239

233240

234241
@dataclasses.dataclass

0 commit comments

Comments
 (0)