You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Paddle/paddle/fluid/inference/analysis
Leo Chen 90805e2df7
Register op_version for new attribute use_addto (#28463)
4 years ago
..
ir_passes Register op_version for new attribute use_addto (#28463) 4 years ago
passes use iwyu clean include (#27267) 4 years ago
CMakeLists.txt Fix the cmake-function named inference_download_and_uncompress on Windows (#26512) 5 years ago
README.md [DOC] Fix dead link (#26154) 5 years ago
analysis_pass.cc rename pass.h/.cc to analysis_pass 7 years ago
analysis_pass.h fix container not cleared (#14231) 6 years ago
analyzer.cc Enhance infer error info message (#26731) 4 years ago
analyzer.h fea/infer memory optim2 (#14953) 6 years ago
analyzer_tester.cc Enhance infer error info message (#26731) 4 years ago
argument.cc Feature/pass manager (#11440) 7 years ago
argument.h TensorRT中ernie模型推理性能优化,支持变长输入 (#28367) 4 years ago
device.h clean up codes 7 years ago
dot.h fea/fuse attention lstm simplify.with fusion lstm.with sequnce expand (#13006) 7 years ago
dot_tester.cc Combine Inference Analysis with IR (#13914) 6 years ago
flags.h test/add text-classification test (#13081) 7 years ago
helper.cc Add TRT input shape check between model and runtime (#19864) 5 years ago
helper.h Enhance infer error info message (#26731) 4 years ago
ir_pass_manager.cc Add bfloat16 softmax and gelu (#28394) 4 years ago
ir_pass_manager.h Add an inference interface to disable FC padding (#22097) 5 years ago
ut_helper.h Combine Inference Analysis with IR (#13914) 6 years ago

README.md

Inference Analysis

The inference/analysis module is used to analyze and optimize the inference program, it references some philosophy from LLVM/analysis, and make the various optimization features be pluggable and co-exist in a pipeline.

We borrowed some concepts from LLVM, such as

  • Passes to implement optimization that traverse the inference program,
  • Graph to represent the data flow graph built from a program,
  • PassManager to manage a sequence of Passes over a graph.

There are some other basic concepts here

  • Node, the node in a Graph,
    • Function, the Operator in Fluid,
    • Value, the Variable in Fluid;
  • Argument, the argument that treat as the input and output of all Passes in the pipeline,

How it works

The inference/analysis module make all the passes in a pipeline, and works in such way:

  1. Build a Graph from a Fluid inference ProgramDesc,
  2. Call the middle passes one by one, the same Graph is passed across all the passes,
  3. Transform a new ProgramDesc from the modified Graph.

The new optimization features can be added as an independent Pass and controlled by gflags, each pass will generate unified debug information or visualization for better debugging.

Supported Passes

FluidToDataFlowGraphPass

Transform the fluid ProgramDesc to a DataFlowGraph to give an abstract representation for all the middle passes, this should be the first pass of the pipeline.

DataFlowGraphToFluidPass

Generate a final ProgramDesc from a data flow graph, this should be the last pass of the pipeline.

TensorRTSubgraphNodeMarkPass

Mark the Node that are supported by TensorRT, this pass will generate a visualization file which can be used for debugging.

TensorRTSubGraphPass

Split the sub-graph that are can be accelerated by TensorRT.

DFG_GraphvizDrawPass

This pass is just for debug, it will visualize the DataFlowGraph using the graphviz tool.

It can be used as a helper class that draws the modified graph after each pass.

Utilities

There is some helper legacy/function/class for analysis.

  • dot.h give a easy to use interface for generating DOT codes,
  • graph_traits.h contains the interfaces of the graph traversal algorithms, it uses iteratorto make the algorithms easy to share across different passes, there are some implementations in graph_helper.cc , such as BFS and DFS..