MCPcopy
hub / github.com/tinygrad/tinygrad / shard_like

Method shard_like

tinygrad/tensor.py:405–411  ·  view source on GitHub ↗

Shards the tensor the same way as `y` (same devices and axis).

(self, y:Tensor)

Source from the content-addressed store, hash-verified

403 return self.replace(self.shard(devices, axis))
404
405 def shard_like(self, y:Tensor) -> Tensor:
406 """
407 Shards the tensor the same way as `y` (same devices and axis).
408 """
409 if y.device is None: return self
410 if isinstance(y.device, str): return self.to(y.device)
411 return self if isinstance(self.device, tuple) and (y.device, y.uop.axis) == (self.device, self.uop.axis) else self.shard(y.device, y.uop.axis)
412
413 CHUNK_SIZE = 2**20
414 def fs_load(self, size:int) -> Tensor:

Callers 3

_stepMethod · 0.80
test_shard_likeMethod · 0.80
_apply_updateMethod · 0.80

Calls 2

toMethod · 0.95
shardMethod · 0.95

Tested by 1

test_shard_likeMethod · 0.64