Created by: baojun-nervana
This PR includes the implementation of ngraph engine. Each function's role in the NgraphOperator class:
- GetNgInputShape : this uses the infershape to get the output shape as ngraph needs to know this info to define tensor;
- BuildNgIO : this is to get the input and output var list;
- BuildNgNode: this function call ngraph bridge function BuildNgGraph to translate ops and build the computation graph.
- BuildNgFunction : this is to build the function for ngraph as ngraph use a function call to execute the computation.
- GetNgFunction : ngraph function can be cached, so this api will check if a function is already available or otherwise it will call BuildNgFunction to build a new ngraph function; GetCacheKey is to generate the key to map the function;
- Run : will set the input and output tensor and call the function to execute. Input and output tensors were shared with paddle to save IO cost;
Note:
- The api VarIsTensor and class RuntimeInferShapeContex were promoted from operator.cc and operator.h, so it is accessible for ngraph_operator;
- I added ngraph object dependency in cmake to ensure ngraph is available before build ngraph_bridge and ngraph_operator (can be an issue to build in large system and the orders can be guaranteed this way);
- I added Relu and Tanh as examples in the bridge to show how the bridge works. More ops can be seen from https://github.com/PaddlePaddle/Paddle/pull/13389 (I have all resnet50 ops there, so you can run resnet to check performance).
CC: @luotao1 @panyx0718 @jianhang-liu