MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / exec

Method exec

dnn/src/cuda/resize/forward.cpp:95–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void ResizeImpl::exec(
96 _megdnn_tensor_in src, _megdnn_tensor_in dst, _megdnn_workspace workspace) {
97 check_exec(src.layout, dst.layout, workspace.size);
98 auto stream = cuda_stream(this->handle());
99 bool is_nhwc = param().format == param::Resize::Format::NHWC;
100 size_t C, IH, IW, OH, OW;
101 ptrdiff_t S_IN = 0, S_IC = 0, S_IH = 0, S_IW = 0;
102 if (is_nhwc) {
103 if (param().imode != Param::InterpolationMode::LINEAR &&
104 is_nhwc_contig_wc(src.layout)) {
105 resize_cv_proxy(
106 src, dst, resize::get_imode(param().imode), workspace.raw_ptr,
107 stream);
108 return;
109 }
110 C = src.layout.shape[3];
111 IH = src.layout.shape[1];
112 IW = src.layout.shape[2];
113 OH = dst.layout.shape[1];
114 OW = dst.layout.shape[2];
115 } else if (param().format == param::Resize::Format::NCHW) {
116 C = src.layout.shape[1];
117 IH = src.layout.shape[2];
118 IW = src.layout.shape[3];
119 OH = dst.layout.shape[2];
120 OW = dst.layout.shape[3];
121 S_IN = src.layout.stride[0];
122 S_IC = src.layout.stride[1];
123 S_IH = src.layout.stride[2];
124 S_IW = src.layout.stride[3];
125 } else {
126 megdnn_assert(
127 param().format == param::Resize::Format::NCHW4,
128 "invalid resize format");
129 megdnn_assert(src.layout.dtype.enumv() == DTypeEnum::QuantizedS8);
130 C = src.layout.shape[1] * 4;
131 IH = src.layout.shape[2];
132 IW = src.layout.shape[3];
133 OH = dst.layout.shape[2];
134 OW = dst.layout.shape[3];
135 resize::forward_proxy_nchw4(
136 src.compatible_ptr<int8_t>(), dst.compatible_ptr<int8_t>(),
137 src.layout[0], C, IH, IW, OH, OW, stream);
138 return;
139 }
140 megdnn_assert(
141 param().imode == Param::InterpolationMode::LINEAR ||
142 param().imode == Param::InterpolationMode::NEAREST ||
143 param().imode == Param::InterpolationMode::INTER_CUBIC,
144 "unsupported interpolation mode for NCHW format");
145
146 if (src.layout.dtype == dtype::Float32{}) {
147 resize::forward_proxy(
148 is_nhwc, resize::get_imode((param().imode)), src.ptr<dt_float32>(),
149 dst.ptr<dt_float32>(), src.layout[0], C, IH, IW, OH, OW, S_IN, S_IC,
150 S_IH, S_IW, stream);
151 } else if (src.layout.dtype == dtype::Float16{}) {
152 resize::forward_proxy(

Callers

nothing calls this directly

Calls 7

cuda_streamFunction · 0.85
resize_cv_proxyFunction · 0.85
get_imodeFunction · 0.70
paramFunction · 0.50
handleMethod · 0.45
enumvMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected