Args: net: the caffe2 net to insert operator params: weight and bias for FC outputs: the output blobs version: support fp32 and fp16 for now.
(self, net, params, outputs, version)
| 136 | return output_dim_vec |
| 137 | |
| 138 | def _insert_fc_ops(self, net, params, outputs, version): |
| 139 | """ |
| 140 | Args: |
| 141 | net: the caffe2 net to insert operator |
| 142 | params: weight and bias for FC |
| 143 | outputs: the output blobs |
| 144 | version: support fp32 and fp16 for now. |
| 145 | """ |
| 146 | if version == "fp32": |
| 147 | if self.transposed: |
| 148 | return net.FCTransposed( |
| 149 | self.input_record.field_blobs() + params, |
| 150 | outputs, |
| 151 | axis=self.axis, |
| 152 | **self.kwargs |
| 153 | ) |
| 154 | else: |
| 155 | return net.FC( |
| 156 | self.input_record.field_blobs() + params, |
| 157 | outputs, |
| 158 | axis=self.axis, |
| 159 | **self.kwargs |
| 160 | ) |
| 161 | elif version == "fp16": |
| 162 | return net.FbFCPacked( |
| 163 | self.input_record.field_blobs() + params, |
| 164 | outputs, |
| 165 | axis=self.axis, |
| 166 | **self.kwargs |
| 167 | ) |
| 168 | else: |
| 169 | raise Exception("unsupported FC type version {}".format(version)) |
| 170 | |
| 171 | def _add_ops(self, net, params, version): |
| 172 | """ |
no test coverage detected