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

Method add_global_constant

caffe2/python/layer_model_helper.py:170–188  ·  view source on GitHub ↗
(
        self, name, array=None, dtype=None, initializer=None
    )

Source from the content-addressed store, hash-verified

168 return initializer_op
169
170 def add_global_constant(
171 self, name, array=None, dtype=None, initializer=None
172 ):
173 assert isinstance(name, str), (
174 'name should be a string as we are using it as map key')
175 # This is global namescope for constants. They will be created in all
176 # init_nets and there should be very few of them.
177 assert name not in self.global_constants, \
178 "%s already added in global_constants" % name
179 blob_name = self.net.NextBlob(name)
180 self.global_constants[name] = blob_name
181 initializer_op = LayerModelHelper._get_global_constant_initializer_op(
182 blob_name, array, dtype, initializer
183 )
184 assert blob_name not in self.global_constant_initializers, \
185 "there is already a initializer op associated with blob %s" % \
186 blob_name
187 self.global_constant_initializers[blob_name] = initializer_op
188 return blob_name
189
190 def maybe_add_global_constant(self, name, *args, **kwargs):
191 # To ad hoc add new global constants without duplication

Callers 9

__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
set_smooth_matrixMethod · 0.80
init_weightMethod · 0.80

Calls 3

isinstanceFunction · 0.85
NextBlobMethod · 0.80