/usr/local/lib64/python3.6/site-packages/torch/nn/qat/modules/__pycache__
NameSizeModeActions
conv.cpython-36.pyc51410644editdlrm
linear.cpython-36.pyc25110644editdlrm
__init__.cpython-36.pyc2970644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/nn/qat/modules/__pycache__/linear.cpython-36.pyc (2511B)
3 Eg @s@ddlZddljZddljjZddlmZGdddejZdS)N) LinearReLUcsJeZdZdZejZd ddfdd ZddZe d d Z d d Z Z S)Lineara A linear module attached with FakeQuantize modules for weight, used for quantization aware training. We adopt the same interface as `torch.nn.Linear`, please see https://pytorch.org/docs/stable/nn.html#torch.nn.Linear for documentation. Similar to `torch.nn.Linear`, with FakeQuantize modules initialized to default. Attributes: weight: fake quant module for weight TN)returncsB||d}tj|||f||s*td||_|j|d|_dS)N)devicedtypez'qconfig must be provided for QAT module)factory_kwargs)super__init__AssertionErrorqconfigweightweight_fake_quant)self in_features out_featuresbiasr rrr) __class__G/usr/local/lib64/python3.6/site-packages/torch/nn/qat/modules/linear.pyr s   zLinear.__init__cCstj||j|j|jS)N)Flinearr r r)rinputrrrforwardszLinear.forwardcCst||jks(td|jd|jjt|ds:td|jsHtdt|tkr\|d}|j}||j|j|j dk |d}|j |_ |j |_ |S) zCreate a qat module from a float module or qparams_dict Args: `mod` a float module, either produced by torch.quantization utilities or directly from user z qat.z.from_float only works for r z,Input float module must have qconfig definedz,Input float module must have a valid qconfigrN)rr ) type _FLOAT_MODULEr __name__hasattrr rrrrr )clsmodr Z qat_linearrrr from_float"s  zLinear.from_floatcCs\tjj|j|j|jdk }tjj|jj|_|jdk rLtjj|jj|_|j |j |S)N) torchnnrrrr Parameterr detachZtrainZtraining)rrrrrto_float6s   zLinear.to_float)TNNN) r __module__ __qualname____doc__r!rrr r classmethodrr$ __classcell__rr)rrrs r) r Ztorch.nnr!Ztorch.nn.functionalZ functionalrZtorch.nn.intrinsicrrrrrrs