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

Method testUseInput

caffe2/python/core_gradients_test.py:245–264  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

243 operators, {'sink': 'sink_grad'})
244
245 def testUseInput(self):
246 operators = [
247 CreateOperator('Direct', 'in', 'hidden'),
248 CreateOperator('UseInput', 'hidden', 'out'),
249 CreateOperator('Direct', 'out', 'sink'),
250 ]
251 desired_grad_operators = [
252 CreateOperator('DirectGradient', 'sink_grad', 'out_grad'),
253 CreateOperator(
254 'UseInputGradient',
255 ['hidden', 'out_grad'], 'hidden_grad'
256 ),
257 CreateOperator(
258 'DirectGradient',
259 'hidden_grad', 'in_grad'
260 ),
261 ]
262 gradients, _ = GradientRegistry.GetBackwardPass(
263 operators, {'sink': 'sink_grad'})
264 self.assertOperatorListEqual(gradients, desired_grad_operators)
265
266 def testUseInputButInputHasBeenChanged(self):
267 """Test gradient for the following case:

Callers

nothing calls this directly

Calls 3

CreateOperatorFunction · 0.90
GetBackwardPassMethod · 0.45

Tested by

no test coverage detected