MCPcopy Create free account
hub / github.com/pytorch/pytorch / _insert_fc_ops

Method _insert_fc_ops

caffe2/python/layers/fc.py:138–169  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers 1

_add_opsMethod · 0.95

Calls 4

ExceptionClass · 0.85
FCMethod · 0.80
field_blobsMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected