MCPcopy Index your code
hub / github.com/pytorch/pytorch / _elementwise_linear

Function _elementwise_linear

caffe2/python/helpers/elementwise_linear.py:12–41  ·  view source on GitHub ↗

Elementwise_Linear

(
    model, op_call, blob_in, blob_out, dim,
    weight_init=None, bias_init=None, **kwargs
)

Source from the content-addressed store, hash-verified

10
11
12def _elementwise_linear(
13 model, op_call, blob_in, blob_out, dim,
14 weight_init=None, bias_init=None, **kwargs
15):
16 """Elementwise_Linear"""
17 weight_init = weight_init or ('ConstantFill', {'value': 1.0})
18 bias_init = bias_init or ('ConstantFill', {'value': 0.0})
19 blob_out = blob_out or model.net.NextName()
20 if model.init_params:
21 weight = model.param_init_net.__getattr__(weight_init[0])(
22 [],
23 blob_out + '_w',
24 shape=[dim],
25 **weight_init[1]
26 )
27 bias = model.param_init_net.__getattr__(bias_init[0])(
28 [],
29 blob_out + '_b',
30 shape=[dim],
31 **bias_init[1]
32 )
33 else:
34 weight = core.ScopedBlobReference(
35 blob_out + '_w', model.param_init_net)
36 bias = core.ScopedBlobReference(
37 blob_out + '_b', model.param_init_net)
38
39 model.AddParameter(weight, ParameterTags.WEIGHT)
40 model.AddParameter(bias, ParameterTags.BIAS)
41 return op_call([blob_in, weight, bias], blob_out, **kwargs)
42
43
44def elementwise_linear(model, *args, **kwargs):

Callers 1

elementwise_linearFunction · 0.85

Calls 3

NextNameMethod · 0.80
AddParameterMethod · 0.80
__getattr__Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…