| 80 | } |
| 81 | |
| 82 | SymbolVar Network::add_deconv( |
| 83 | SymbolVar f, size_t ratio, size_t output_channels, DType out_dtype) { |
| 84 | static int weight_idx = 0; |
| 85 | size_t kernel = ratio * 2 - ratio % 2; |
| 86 | size_t pad = ratio / 2; |
| 87 | |
| 88 | size_t input_channels = f.node()->shape()[1]; |
| 89 | auto weight = add_cvar( |
| 90 | ssprintf("w%d", weight_idx).c_str(), |
| 91 | {input_channels, output_channels, kernel, kernel}); |
| 92 | |
| 93 | if (out_dtype.category() == DTypeCategory::QUANTIZED) { |
| 94 | weight = add_type_cvt(weight, out_dtype); |
| 95 | } |
| 96 | opr::ConvolutionBackwardData::Param param; |
| 97 | param.stride_h = param.stride_w = ratio; |
| 98 | param.pad_h = param.pad_w = pad; |
| 99 | |
| 100 | auto deconv = opr::ConvolutionBackwardData::make( |
| 101 | weight, f, param, {}, OperatorNodeConfig{out_dtype}); |
| 102 | weight_idx++; |
| 103 | return deconv; |
| 104 | } |
| 105 | |
| 106 | SymbolVar Network::add_elemwise( |
| 107 | const SymbolVarArray inps, DType out_dtype, opr::Elemwise::Param::Mode mode) { |
no test coverage detected