(
network: trt.INetworkDefinition,
weights: OrderedDict,
input: trt.ITensor,
cout: int,
n: int,
shortcut: bool,
group: int,
scale: float,
layer_name: str,
)
| 96 | |
| 97 | |
| 98 | def C2f( |
| 99 | network: trt.INetworkDefinition, |
| 100 | weights: OrderedDict, |
| 101 | input: trt.ITensor, |
| 102 | cout: int, |
| 103 | n: int, |
| 104 | shortcut: bool, |
| 105 | group: int, |
| 106 | scale: float, |
| 107 | layer_name: str, |
| 108 | ) -> trt.ILayer: |
| 109 | c_ = int(cout * scale) # e:expand param |
| 110 | conv1 = Conv(network, weights, input, 2 * c_, 1, 1, 1, layer_name + ".cv1") |
| 111 | y1 = conv1.get_output(0) |
| 112 | |
| 113 | b, _, h, w = y1.shape |
| 114 | slice = network.add_slice(y1, (0, c_, 0, 0), (b, c_, h, w), (1, 1, 1, 1)) |
| 115 | assert slice, "Add slice layer failed" |
| 116 | y2 = slice.get_output(0) |
| 117 | |
| 118 | input_tensors = [y1] |
| 119 | for i in range(n): |
| 120 | b = Bottleneck(network, weights, y2, c_, c_, shortcut, group, 1.0, layer_name + ".m." + str(i)) |
| 121 | y2 = b.get_output(0) |
| 122 | input_tensors.append(y2) |
| 123 | |
| 124 | cat = network.add_concatenation(input_tensors) |
| 125 | assert cat, "Add concatenation layer failed" |
| 126 | |
| 127 | conv2 = Conv(network, weights, cat.get_output(0), cout, 1, 1, 1, layer_name + ".cv2") |
| 128 | return conv2 |
| 129 | |
| 130 | |
| 131 | def SPPF( |
no test coverage detected