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

Function runOpOnInput

caffe2/python/hypothesis_test_util.py:369–398  ·  view source on GitHub ↗
(
    device_option,
    op,
    inputs,
    input_device_options=None,
)

Source from the content-addressed store, hash-verified

367
368
369def runOpOnInput(
370 device_option,
371 op,
372 inputs,
373 input_device_options=None,
374):
375 op = copy.deepcopy(op)
376 op.device_option.CopyFrom(device_option)
377
378 with temp_workspace():
379 if (len(op.input) > len(inputs)):
380 raise ValueError(
381 'must supply an input for each input on the op: %s vs %s' %
382 (op.input, inputs))
383 _input_device_options = input_device_options or \
384 core.InferOpBlobDevicesAsDict(op)[0]
385 for (n, b) in zip(op.input, inputs):
386 workspace.FeedBlob(
387 n,
388 b,
389 device_option=_input_device_options.get(n, device_option)
390 )
391 workspace.RunOperatorOnce(op)
392 outputs_to_check = list(range(len(op.output)))
393 outs = []
394 for output_index in outputs_to_check:
395 output_blob_name = op.output[output_index]
396 output = workspace.FetchBlob(output_blob_name)
397 outs.append(output)
398 return outs
399
400
401class HypothesisTestCase(test_util.TestCase):

Callers

nothing calls this directly

Calls 5

temp_workspaceFunction · 0.85
listFunction · 0.85
rangeFunction · 0.50
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…