MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / LocalTensorTo

Function LocalTensorTo

oneflow/core/functional/impl/array_functor.cpp:3087–3094  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3085namespace {
3086
3087Maybe<Tensor> LocalTensorTo(const std::shared_ptr<Tensor>& x, Symbol<Device> device,
3088 const Symbol<DType>& dtype, const bool& copy) {
3089 std::shared_ptr<Tensor> tensor = x;
3090 if (device != JUST(x->device())) { tensor = JUST(Copy(tensor, device, /*pin_memory=*/false)); }
3091 if (dtype != x->dtype()) { tensor = JUST(Cast(tensor, dtype, /*pin_memory=*/false)); }
3092 if (copy && tensor == x) { tensor = JUST(Copy(tensor, device, /*pin_memory=*/false)); }
3093 return tensor;
3094}
3095
3096Maybe<Tensor> GlobalTensorTo(const std::shared_ptr<Tensor>& x, const std::string& device_type,
3097 const Symbol<DType>& dtype, const bool& copy) {

Callers 6

GlobalTensorToFunction · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85

Calls 4

CopyClass · 0.85
CastClass · 0.50
deviceMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected