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

Method DeduplicateGradientSlices

caffe2/python/core.py:2194–2203  ·  view source on GitHub ↗
(self, g, aggregator='sum')

Source from the content-addressed store, hash-verified

2192 self.AddExternalOutput(*outputs)
2193
2194 def DeduplicateGradientSlices(self, g, aggregator='sum'):
2195 assert isinstance(g, GradientSlice)
2196 unique, remapping = self.Unique([g.indices], 2, engine='SparseHash')
2197 if aggregator.lower() == 'sum':
2198 new_g = self.UnsortedSegmentSum([g.values, remapping], 1)
2199 elif aggregator.lower() == 'mean':
2200 new_g = self.UnsortedSegmentMean([g.values, remapping], 1)
2201 else:
2202 raise ValueError('{} is not supported'.format(aggregator))
2203 return GradientSlice(indices=unique, values=new_g)
2204
2205 @staticmethod
2206 def _RunAllOnGPU(net, gpu_id=0, use_cudnn=False):

Callers 1

dedupMethod · 0.80

Calls 3

isinstanceFunction · 0.85
lowerMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected