Skip to content

Commit

Permalink
fix checking DiskBuffer is opened [pr] (#8547)
Browse files Browse the repository at this point in the history
`assert self.device.mem is not None` did not assert because `.mem` triggers AttributeError first
  • Loading branch information
chenyuxyz authored Jan 9, 2025
1 parent 62447c2 commit 88661cd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tinygrad/runtime/ops_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, device:DiskDevice, size:int, offset=0):
self.device, self.size, self.offset = device, size, offset
def __repr__(self): return f"<DiskBuffer size={self.size} offset={self.offset}>"
def _buf(self) -> memoryview:
assert self.device.mem is not None, "DiskBuffer wasn't opened"
assert hasattr(self.device, "mem"), "DiskBuffer wasn't opened"
return memoryview(self.device.mem)[self.offset:self.offset+self.size]

MAP_LOCKED, MAP_POPULATE = 0 if OSX else 0x2000, getattr(mmap, "MAP_POPULATE", 0 if OSX else 0x008000)
Expand Down

0 comments on commit 88661cd

Please sign in to comment.