MCPcopy
hub / github.com/tinygrad/tinygrad / to_

Method to_

tinygrad/tensor.py:375–381  ·  view source on GitHub ↗

Moves the tensor to the given device in place.

(self, device:str|tuple[str, ...]|None)

Source from the content-addressed store, hash-verified

373 return ret.is_param_(self.is_param)
374
375 def to_(self, device:str|tuple[str, ...]|None) -> Tensor:
376 """
377 Moves the tensor to the given device in place.
378 """
379 real = self.to(device)
380 if self.grad is not None and real.grad is not None: self.grad.replace(real.grad)
381 return self.replace(real)
382
383 def shard(self, devices:tuple[str, ...], axis:int|None=None) -> Tensor:
384 """

Callers 15

test_bertMethod · 0.80
test_lamb_cpu_offloadMethod · 0.80
test_toMethod · 0.80
test_gradientMethod · 0.80
test_const_copy_multiMethod · 0.80
helper_test_opFunction · 0.80
test_multi_gpuMethod · 0.80
get_cond_stage_modelFunction · 0.80

Calls 2

toMethod · 0.95
replaceMethod · 0.95

Tested by 13

test_bertMethod · 0.64
test_lamb_cpu_offloadMethod · 0.64
test_toMethod · 0.64
test_gradientMethod · 0.64
test_const_copy_multiMethod · 0.64
helper_test_opFunction · 0.64
test_multi_gpuMethod · 0.64
get_cond_stage_modelFunction · 0.64