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

Function fc_decomp

caffe2/python/helpers/fc.py:65–95  ·  view source on GitHub ↗

FC_Decomp version Here we assume that the rank of original input is bigger than 5.

(
    model, blob_in, blob_out, dim_in, dim_out,
    rank_approx=5, weight_init=None, bias_init=None,
    WeightInitializer=None, BiasInitializer=None, **kwargs
)

Source from the content-addressed store, hash-verified

63
64
65def fc_decomp(
66 model, blob_in, blob_out, dim_in, dim_out,
67 rank_approx=5, weight_init=None, bias_init=None,
68 WeightInitializer=None, BiasInitializer=None, **kwargs
69):
70 """FC_Decomp version
71 Here we assume that the rank of original input is bigger than 5.
72 """
73 WeightInitializer = initializers.update_initializer(
74 WeightInitializer, weight_init, ("XavierFill", {})
75 )
76 BiasInitializer = initializers.update_initializer(
77 BiasInitializer, bias_init, ("ConstantFill", {})
78 )
79 blob_out = blob_out or model.net.NextName()
80 u = model.create_param(
81 param_name=blob_out + '_u',
82 shape=[dim_out, rank_approx],
83 initializer=WeightInitializer,
84 )
85 v = model.create_param(
86 param_name=blob_out + '_v',
87 shape=[dim_in, rank_approx],
88 initializer=WeightInitializer,
89 )
90 bias = model.create_param(
91 param_name=blob_out + '_b',
92 shape=[dim_out, ],
93 initializer=BiasInitializer,
94 )
95 return model.net.FC_Decomp([blob_in, u, v, bias], blob_out, **kwargs)
96
97
98def fc_prune(

Callers

nothing calls this directly

Calls 3

NextNameMethod · 0.80
FC_DecompMethod · 0.80
create_paramMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…