rewrite 0 size loadop into a CONST (#2556)

* rewrite 0 size loadop into a CONST

* check alloc size

* EMPTY is better

* Revert "EMPTY is better"

This reverts commit 574fe0f9ed28f1b97da5a81afdfd2cd5d9a94ff9.

* no ast is created

* fix test
This commit is contained in:
chenyu
2023-12-01 18:29:06 -05:00
committed by GitHub
parent 4447188051
commit 67f4e03724
10 changed files with 25 additions and 20 deletions

View File

@@ -59,7 +59,6 @@ class CLAllocator(LRUAllocator):
self.device = device
super().__init__()
def _alloc(self, size:int, dtype:DType):
if size == 0: return None
if isinstance(dtype, ImageDType):
# NOTE: the memory is a bit off here due to padding, it's buf.row_pitch * buf.height * 4 * dtype.itemsize
assert size == prod(dtype.shape), f"image size mismatch {size} != {dtype.shape}"