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

Method GetOptimizationParamInfo

caffe2/python/model_helper.py:349–367  ·  view source on GitHub ↗

Returns a map for param => grad. If params is not specified, all parameters will be considered.

(self, params=None)

Source from the content-addressed store, hash-verified

347 return param_to_grad
348
349 def GetOptimizationParamInfo(self, params=None):
350 '''
351 Returns a map for param => grad.
352 If params is not specified, all parameters will be considered.
353 '''
354 if not self.gradient_ops_added:
355 raise RuntimeError("Need to call AddGradientOperators first")
356
357 param_to_grad = self.param_to_grad
358 if params:
359 param_to_grad = self.get_param_to_grad(params)
360
361 return [
362 self.get_param_info(param) for param, grad in param_to_grad.items()
363 if (
364 not self.skip_sparse_optim or
365 not isinstance(grad, core.GradientSlice)
366 )
367 ]
368
369 def _Validate(self):
370 '''

Callers 4

_buildFunction · 0.80
add_post_sync_opsFunction · 0.80
add_post_sync_opsFunction · 0.80
add_post_sync_opsFunction · 0.80

Calls 4

get_param_to_gradMethod · 0.95
get_param_infoMethod · 0.95
isinstanceFunction · 0.85
itemsMethod · 0.45

Tested by 1

add_post_sync_opsFunction · 0.64