(
device_option,
op,
inputs,
input_device_options=None,
)
| 367 | |
| 368 | |
| 369 | def 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 | |
| 401 | class HypothesisTestCase(test_util.TestCase): |
nothing calls this directly
no test coverage detected
searching dependent graphs…