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

Method Compute

oneflow/user/kernels/fold_kernel.cpp:63–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62 private:
63 void Compute(KernelComputeContext* ctx) const override {
64 const Tensor* input = ctx->Tensor4ArgNameAndIndex("x", 0);
65 Tensor* output = ctx->Tensor4ArgNameAndIndex("y", 0);
66
67 const std::vector<int32_t> output_size = ctx->Attr<std::vector<int32_t>>("output_size");
68 const std::vector<int32_t> kernel_size = ctx->Attr<std::vector<int32_t>>("kernel_size");
69 const std::vector<int32_t> dilation = ctx->Attr<std::vector<int32_t>>("dilation_rate");
70 const std::vector<int32_t> padding = ctx->Attr<std::vector<int32_t>>("padding");
71 const std::vector<int32_t> stride = ctx->Attr<std::vector<int32_t>>("strides");
72
73 const auto& state_ptr = CreateFoldOpKernelState<INDEX_T, NDIM, SDIM>(
74 input->shape_view(), output_size, kernel_size, padding, stride, dilation);
75 const FoldParams<INDEX_T, NDIM, SDIM> params = state_ptr->params();
76 size_t out_bytes_size =
77 output->shape_view().elem_cnt() * GetSizeOfDataType(output->data_type());
78 Memset<device_type>(ctx->stream(), output->mut_dptr<T>(), 0, out_bytes_size);
79 FoldKernelUtil<device_type, T, INDEX_T, NDIM, SDIM>::Forward(
80 ctx->stream(), &params, input->dptr<T>(), output->mut_dptr<T>());
81 }
82
83 bool AlwaysComputeWhenAllOutputsEmpty() const override { return false; }
84};

Callers

nothing calls this directly

Calls 7

GetSizeOfDataTypeFunction · 0.85
ForwardFunction · 0.85
shape_viewMethod · 0.45
elem_cntMethod · 0.45
data_typeMethod · 0.45
streamMethod · 0.45

Tested by

no test coverage detected