| 21 | } |
| 22 | |
| 23 | static halide_type_t formatInput(VARP& src, bool fp = true) { |
| 24 | auto info = src->getInfo(); |
| 25 | auto dim = info->dim; |
| 26 | int height, width, channel; |
| 27 | getVARPSize(src, &height, &width, &channel); |
| 28 | if (dim.size() != 4) { |
| 29 | if (src->getInfo()->order == NHWC) { |
| 30 | src = _Reshape(src, {1, height, width, channel}); |
| 31 | } else { |
| 32 | src = _Convert(_Reshape(src, {1, channel, height, width}), NHWC); |
| 33 | } |
| 34 | } |
| 35 | if (fp && src->getInfo() && src->getInfo()->type.code != halide_type_float) { |
| 36 | src = _Cast(src, halide_type_of<float>()); |
| 37 | } |
| 38 | return info->type; |
| 39 | } |
| 40 | |
| 41 | static VARP formatOutput(VARP src, halide_type_t type) { |
| 42 | auto dim = src->getInfo()->dim; |
no test coverage detected