intel / intel-extension-for-tensorflow

Intel® Extension for TensorFlow*
Other
311 stars 39 forks source link

OneDNN Graph API for Hugging face models #70

Closed akote123 closed 1 month ago

akote123 commented 2 months ago

With reference to https://github.com/oneapi-src/oneDNN/issues/1930,I have tried export ITEX_ONEDNN_GRAPH=1 flag and also _ITEX_ONEDNN_GRAPH_ALL_TYPE=1 in intel extension for tensorflow for hugging face bert and transformer xl model, But when I check onednn log, graph apis are not seen. Is there anything else need to be changed? I have checked same flags with the example :https://github.com/intel/intel-extension-for-tensorflow/blob/e027c47edb49d947020c42e202b802878dba55c3/test/llga/train_resnet_keras.py and able to see graph apis in onednn log. Is enablement of graph api requires keras layers? @yitingw1

feng-intel commented 2 months ago

Hi @akote123 I checked there is "ITEX_ONEDNN_GRAPH" config in ./itex/core/graph/xpu_graph.cc I don't think it requres keras layers. Which example you used to verify onednn log? And what the onednn graph apis you seen for train_resnet_keras.py ?

akote123 commented 2 months ago

@feng-intel ,One of the example graph api observed in in train_resnet_keras.py : onednn_verbose,graph,exec,cpu,100041,misc_post_ops,gradient_tape/model/re_lu/ReluGrad,,in0_f32:59:strided:undef:1x32x32x3:3072s96s3s1 in1_f32:90:strided:undef:1x32x32x3:3072s96s3s1 out0_f32:91:strided:undef:1x32x32x3:3072s96s3s1,fpm:strict,dnnl_backend,0.0410156 But this is not seen when I run huggingface resnet50 model inference

feng-intel commented 2 months ago

@akote123 oneDNN graph is a graph optimizer, which will behave differently for different graphs. What do you want to achieve with oneDNN graph?

akote123 commented 2 months ago

@feng-intel ,wanted to understand what layers are being fused here and also to check is it possible to gain performance with this .

feng-intel commented 2 months ago

we don't have a good log mechanism for why it does not fusion in it. You can deep dive to the source code. I writed an article about the source code for your reference. https://www.intel.com/content/www/us/en/developer/articles/technical/intel-extension-for-tensorflow-code.html

akote123 commented 2 months ago

@feng-intel , Thank you