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

Method from_tensors

dnn/src/naive/resize/opr_impl.cpp:18–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17template <typename ctype>
18ResizeImpl::KernParam<ctype> ResizeImpl::KernParam<ctype>::from_tensors(
19 Format format, InterpolationMode imode, _megdnn_tensor_in src,
20 _megdnn_tensor_out dst, _megdnn_workspace workspace) {
21 KernParam<ctype> ret;
22 ret.format = format;
23 ret.imode = imode;
24 ret.n = src.layout.shape[0];
25 if (format == Format::NCHW) {
26 ret.c = src.layout.shape[1];
27 ret.ih = src.layout.shape[2];
28 ret.iw = src.layout.shape[3];
29 ret.oh = dst.layout.shape[2];
30 ret.ow = dst.layout.shape[3];
31 ret.s_in = src.layout.stride[0];
32 ret.s_ic = src.layout.stride[1];
33 ret.s_ih = src.layout.stride[2];
34 ret.s_iw = src.layout.stride[3];
35 } else if (format == Format::NHWC) {
36 ret.c = src.layout.shape[3];
37 ret.ih = src.layout.shape[1];
38 ret.iw = src.layout.shape[2];
39 ret.oh = dst.layout.shape[1];
40 ret.ow = dst.layout.shape[2];
41 } else if (format == Format::NCHW4) {
42 ret.c = src.layout.shape[1] * 4;
43 ret.ih = src.layout.shape[2];
44 ret.iw = src.layout.shape[3];
45 ret.oh = dst.layout.shape[2];
46 ret.ow = dst.layout.shape[3];
47 } else if (format == Format::NCHW44) {
48 ret.c = src.layout.shape[1] * 4;
49 ret.ih = src.layout.shape[2];
50 ret.iw = src.layout.shape[3];
51 ret.oh = dst.layout.shape[2];
52 ret.ow = dst.layout.shape[3];
53 } else if (format == Format::NCHW88) {
54 ret.c = src.layout.shape[1] * 8;
55 ret.ih = src.layout.shape[2];
56 ret.iw = src.layout.shape[3];
57 ret.oh = dst.layout.shape[2];
58 ret.ow = dst.layout.shape[3];
59 } else {
60 megdnn_assert(format == Format::NHWCD4);
61 ret.c = src.layout.shape[2] * 4;
62 ret.ih = src.layout.shape[1];
63 ret.iw = src.layout.shape[3];
64 ret.oh = dst.layout.shape[1];
65 ret.ow = dst.layout.shape[3];
66 }
67 if (src.layout.dtype.enumv() == DTypeEnum::Float32 ||
68 DNN_FLOAT16_SELECT(src.layout.dtype.enumv() == DTypeEnum::Float16, false) ||
69 src.layout.dtype.enumv() == DTypeEnum::Int8 ||
70 src.layout.dtype.enumv() == DTypeEnum::Uint8 ||
71 src.layout.dtype.enumv() == DTypeEnum::QuantizedS8 ||
72 src.layout.dtype.enumv() == DTypeEnum::Quantized8Asymm) {
73 ret.sptr = src.get_ref_ptr();
74 ret.dptr = dst.get_ref_ptr();
75 } else {

Callers

nothing calls this directly

Calls 3

enumvMethod · 0.45
get_ref_ptrMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected