| 1044 | run_with_param(2, 4, 2, 3, 2, 2, 2, 1); |
| 1045 | } |
| 1046 | void convolution3d_brute( |
| 1047 | const std::vector<std::shared_ptr<HostTensorND>>& in_tensor, |
| 1048 | std::shared_ptr<HostTensorND>& out_tensor, |
| 1049 | const opr::Convolution3D::Param& param) { |
| 1050 | mgb_assert(in_tensor.size() == 2); |
| 1051 | auto in = in_tensor[0], filter = in_tensor[1]; |
| 1052 | mgb_assert(in->shape().ndim == 5); |
| 1053 | mgb_assert(filter->shape().ndim == 5); |
| 1054 | |
| 1055 | int batch_size = in->shape().shape[0]; |
| 1056 | int ic = in->shape().shape[1]; |
| 1057 | int id = in->shape().shape[2]; |
| 1058 | int ih = in->shape().shape[3]; |
| 1059 | int iw = in->shape().shape[4]; |
| 1060 | |
| 1061 | int fd = filter->shape().shape[2]; |
| 1062 | int fh = filter->shape().shape[3]; |
| 1063 | int fw = filter->shape().shape[4]; |
| 1064 | |
| 1065 | int pd = param.pad_d; |
| 1066 | int ph = param.pad_h; |
| 1067 | int pw = param.pad_w; |
| 1068 | |
| 1069 | int sd = param.stride_d; |
| 1070 | int sh = param.stride_h; |
| 1071 | int sw = param.stride_w; |
| 1072 | |
| 1073 | int dd = param.dilate_d; |
| 1074 | int dh = param.dilate_h; |
| 1075 | int dw = param.dilate_w; |
| 1076 | |
| 1077 | mgb_assert(id + 2 * pd >= (fd - 1) * dd + 1); |
| 1078 | mgb_assert(ih + 2 * ph >= (fh - 1) * dh + 1); |
| 1079 | mgb_assert(iw + 2 * pw >= (fw - 1) * dw + 1); |
| 1080 | int od = (id + 2 * pd - ((fd - 1) * dd + 1)) / sd + 1; |
| 1081 | int oh = (ih + 2 * ph - ((fh - 1) * dh + 1)) / sh + 1; |
| 1082 | int ow = (iw + 2 * pw - ((fw - 1) * dw + 1)) / sw + 1; |
| 1083 | mgb_assert(static_cast<size_t>(ic) == filter->shape().shape[1]); |
| 1084 | int oc = filter->shape().shape[0]; |
| 1085 | |
| 1086 | out_tensor = std::make_shared<HostTensorND>( |
| 1087 | CompNode::load("xpu0"), |
| 1088 | TensorShape{ |
| 1089 | static_cast<size_t>(batch_size), static_cast<size_t>(oc), |
| 1090 | static_cast<size_t>(od), static_cast<size_t>(oh), |
| 1091 | static_cast<size_t>(ow)}); |
| 1092 | |
| 1093 | int pn, poc, pod, poh, pow, pic, pid, pih, piw, pfd, pfh, pfw; |
| 1094 | for (pn = 0; pn < batch_size; ++pn) |
| 1095 | for (poc = 0; poc < oc; ++poc) |
| 1096 | for (pod = 0, pid = -pd; pod < od; ++pod, pid += sd) |
| 1097 | for (poh = 0, pih = -ph; poh < oh; ++poh, pih += sh) |
| 1098 | for (pow = 0, piw = -pw; pow < ow; ++pow, piw += sw) { |
| 1099 | float& target = out_tensor->ptr<float>( |
| 1100 | {static_cast<size_t>(pn), static_cast<size_t>(poc), |
| 1101 | static_cast<size_t>(pod), static_cast<size_t>(poh), |
| 1102 | static_cast<size_t>(pow)})[0]; |
| 1103 | target = 0; |
no test coverage detected