mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-09 23:18:04 -05:00
one less branch in Buffer.view [pr] (#13829)
This commit is contained in:
@@ -199,8 +199,7 @@ class Buffer:
|
|||||||
return mv
|
return mv
|
||||||
def view(self, size:int, dtype:DType, offset:int) -> Buffer:
|
def view(self, size:int, dtype:DType, offset:int) -> Buffer:
|
||||||
assert offset < self.nbytes, "offset must be less than nbytes"
|
assert offset < self.nbytes, "offset must be less than nbytes"
|
||||||
if self._base is not None: return Buffer(self.device, size, dtype, base=self._base, offset=self.offset+offset)
|
return Buffer(self.device, size, dtype, base=self.base, offset=self.offset+offset)
|
||||||
return Buffer(self.device, size, dtype, base=self, offset=offset)
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class DMACPURef:
|
class DMACPURef:
|
||||||
|
|||||||
Reference in New Issue
Block a user