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

Method Compute

oneflow/user/kernels/copy_kernel.cpp:29–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28 private:
29 void Compute(user_op::KernelComputeContext* ctx) const override {
30 const user_op::Tensor* in = ctx->Tensor4ArgNameAndIndex("in", 0);
31 user_op::Tensor* out = ctx->Tensor4ArgNameAndIndex("out", 0);
32 const ShapeView& in_shape = in->shape_view();
33 CHECK_EQ(out->shape_view(), in_shape);
34 const DataType in_data_type = in->data_type();
35 CHECK_EQ(out->data_type(), in_data_type);
36 if (in_shape.elem_cnt() == 0) {
37 // 0 shape tensor do not need copy
38 return;
39 } else {
40 AutoMemcpy(ctx->stream(), out->mut_raw_dptr(), in->raw_dptr(),
41 in_shape.elem_cnt() * GetSizeOfDataType(in_data_type), out->mem_case(),
42 in->mem_case());
43 }
44 }
45 bool AlwaysComputeWhenAllOutputsEmpty() const override { return false; }
46};
47

Callers

nothing calls this directly

Calls 9

AutoMemcpyFunction · 0.85
GetSizeOfDataTypeFunction · 0.85
shape_viewMethod · 0.45
data_typeMethod · 0.45
elem_cntMethod · 0.45
streamMethod · 0.45
mut_raw_dptrMethod · 0.45
raw_dptrMethod · 0.45

Tested by

no test coverage detected