MCPcopy
hub / github.com/OpenPPL/ppq / forward

Method forward

ppq/executor/torch.py:366–410  ·  view source on GitHub ↗

Forward function of this executor. Notice this forward function will never store and compute gradients. Args: inputs (Union[dict, list, torch.Tensor]): [input tensor or somewhat] output_names (List[str], optional): onnx output node names, wh

(
        self,
        inputs: Union[dict, list, torch.Tensor],
        output_names:List[str] = None,
        hooks: Dict[str, RuntimeHook] = None
    )

Source from the content-addressed store, hash-verified

364
365 @ torch.no_grad()
366 def forward(
367 self,
368 inputs: Union[dict, list, torch.Tensor],
369 output_names:List[str] = None,
370 hooks: Dict[str, RuntimeHook] = None
371 ) -> List[torch.Tensor]:
372 """Forward function of this executor.
373
374 Notice this forward function will never store and compute gradients.
375
376 Args:
377 inputs (Union[dict, list, torch.Tensor]): [input tensor or somewhat]
378
379 output_names (List[str], optional):
380 onnx output node names, which used to confirm a output order.
381
382 Defaults to None.
383
384 hooks (Dict[str, RuntimeHook], optional):
385 A hook table for customizing operation behaviour and collate data during executing.
386 All hooks should inherit from class RuntimeHook, with all necessary methods implemented.
387 See also: ppq.executor.base.RuntimeHook
388
389 Executor calls hook.pre_forward_hook(operation, input_data) before dispatching operation,
390 by using this feature, you can dynamically dispatch operation during executing,
391 or processing input data as you want.(remember to return processed input data)
392
393 Executor calls hook.post_forward_hook(operation, output_data) after the execution,
394 you are supposed to gather all necessary data from execution via this feature.
395
396 For Quantable Operation, a much more powerful class:
397 ppq.executor.base.QuantOpRuntimeHook is provided.
398 see also: ppq.executor.base.QuantOpRuntimeHook
399
400 Defaults to None.
401
402 Returns:
403 List[torch.Tensor]: [executing result, list of tensor objects.]
404 """
405 return self.__forward(
406 inputs=inputs,
407 output_names=output_names,
408 executing_order=self._executing_order,
409 hooks=hooks
410 )
411
412 def forward_with_gradient(
413 self,

Callers 9

TestAlignmentFunction · 0.95
evaluationFunction · 0.95
layerwise_error_analyseFunction · 0.95
variable_analyseFunction · 0.95
graphwise_error_analyseFunction · 0.95
statistical_analyseFunction · 0.95
infer_shapeMethod · 0.95
dummy_forwardMethod · 0.95
dump_internal_resultsFunction · 0.95

Calls 1

__forwardMethod · 0.95

Tested by

no test coverage detected