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

Method deduce_layout

dnn/src/cuda/convpooling/opr_impl.cpp:44–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44void ConvPoolingForwardImpl::deduce_layout(
45 const TensorLayout& srcl, const TensorLayout& filterl,
46 const TensorLayout& /*bias*/, TensorLayout& dstl) {
47 megdnn_assert_contiguous(srcl);
48 megdnn_assert_contiguous(filterl);
49 auto& src = srcl.shape;
50 auto& filter = filterl.shape;
51 // auto &wsp = workspace.shape;
52 // wsp = TensorShape({0, 0, 0, 0});
53 // megdnn_assert(src.ndim == 4_z, "%s", errmsg_c);
54 // megdnn_assert(filter.ndim == 4_z, "%s", errmsg_c);
55 megdnn_assert(srcl.ndim == 4_z, "%s", "src.ndim != 4");
56 megdnn_assert(filterl.ndim == 4_z, "%s", "filter.ndim != 4");
57 size_t n = src[0];
58 size_t ic = src[1];
59 size_t ih = src[2];
60 size_t iw = src[3];
61 size_t oc = filter[0];
62 megdnn_assert(filter[1] == ic, "%s", "filter[1] != ic");
63 size_t fh = filter[2];
64 size_t fw = filter[3];
65 size_t conv_sh = this->param().conv_stride_h;
66 size_t conv_sw = this->param().conv_stride_w;
67 size_t pool_sh = this->param().pool_stride_h;
68 size_t pool_sw = this->param().pool_stride_w;
69 size_t conv_ph = this->param().conv_pad_h;
70 size_t conv_pw = this->param().conv_pad_w;
71 size_t pool_ph = this->param().pool_pad_h;
72 size_t pool_pw = this->param().pool_pad_w;
73 size_t poolh = this->param().pool_shape_h;
74 size_t poolw = this->param().pool_shape_w;
75 size_t conv_oh, conv_ow, oh, ow;
76 // Shape of the output of convoluation.
77 get_dest_shape(
78 ih, iw, fh, fw, conv_sh, conv_sw, conv_ph, conv_pw, conv_oh, conv_ow);
79 // Shape of the output of pooling.
80 get_dest_shape(
81 conv_oh, conv_ow, poolh, poolw, pool_sh, pool_sw, pool_ph, pool_pw, oh, ow);
82
83 dstl = TensorLayout(TensorShape{n, oc, oh, ow}, srcl.dtype);
84 // workspace = Workspace(NULL, 0);
85 // workspace.gen_default_stride();
86}
87
88void ConvPoolingForwardImpl::check_layout(
89 const TensorLayout& src, const TensorLayout& filter, const TensorLayout& bias,

Callers 3

deduce_reformat_layoutFunction · 0.45
deduce_reformat_layoutFunction · 0.45

Calls 3

get_dest_shapeFunction · 0.85
TensorLayoutClass · 0.85
paramMethod · 0.45

Tested by

no test coverage detected