Closed huningxin closed 5 years ago
@huningxin
Now the issues of compile dependency seem to be solved. But I find the googlesource/ml's latest version don't match the tensorflow/tflite's latest version. And it seems that googlesource/ml lags behind tensorflow/tflite. For example,
in ml:
tflite::optimized_ops::Conv(
inputData, convertShapeToDims(inputShape),
filterData, convertShapeToDims(filterShape),
biasData, convertShapeToDims(biasShape),
stride_width, stride_height,
dilationWidthFactor, dilationHeightFactor,
paddingWidth, paddingHeight,
output_activation_min, output_activation_max,
outputData, convertShapeToDims(outputShape),
im2colData, im2colDim);
but in tensorflow/tflite:
inline void Conv(const ConvParams& params, const RuntimeShape& input_shape,
const float* input_data, const RuntimeShape& filter_shape,
const float* filter_data, const RuntimeShape& bias_shape,
const float* bias_data, const RuntimeShape& output_shape,
float* output_data, const RuntimeShape& im2col_shape,
float* im2col_data)
Now use the latest version of ml and version r1.10 of tensorflow, but softmaxfloat32 still doesn't match. So I use the old implement of it temporarily. I will test the performance later and find if there are more suitable versions for each other. The source code is in https://github.com/Wenzhao-Xiang/webml-polyfill-wasm.
Performance compare:
mobilenet_v2:
Environment Information
UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Platform: Linux x86_64
Configuration
framework: webml-polyfill.js
backend: WASM
modelName: mobilenet_v2
iteration: 201
old nn_ops.js:
Compute Time: 259.62+-5.42 [ms]
nn_ops.js with tflite optimization:
Compute Time: 252.90+-2.00 [ms]
mobilenet_v1:
Environment Information
UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Platform: Linux x86_64
Configuration
framework: webml-polyfill.js
backend: WASM
modelName: mobilenet_v1
iteration: 201
old nn_ops.js:
Compute Time: 397.57+-4.99 [ms]
nn_ops.js with tflite optimization:
Compute Time: 391.40+-4.46 [ms]
inception_v3:
Environment Information
UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Platform: Linux x86_64
Configuration
framework: webml-polyfill.js
backend: WASM
modelName: inception_v3
iteration: 201
old nn_ops.js:
Compute Time: 3421.93+-50.19 [ms]
nn_ops.js with tflite optimization:
Compute Time: 3283.26+-41.40 [ms]
The performance have a 2%~3% improvement with tflite optimization.
Current nn ops is compiled from source code of Android O. It needs to be updated to Android P which shares the ops implementation with TensorFlow Lite.