-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lce benchmark and interpreter flags #717
Conversation
…te/deactivate XNNPACK delegate
- added two cmdline flags use_reference_bconv/use_indirect_bgemm as global variables in lce_benchmark_main.cc to register respective kernels - implemented LceBenchmarkTfLiteModel as a child class of BenchmarkTfLiteModel to use builtin flags instead of manually parsing them in lce_benchmark_main.cc - modified lce_benchmark_main.cc to use LceBenchmarkTfLiteModel, the global flags are set upon calling overriden Run() method by passing them as an internal reference - added build options for lce_benchmark_tflite_model.h same as in TFLite's benchmark_tflite_model.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks a lot!
@Tombana my pleasure. was also thinking about overriding ValidParams() to check when both on the other hand there's a platform check to discretely register the regular bconv kernel if the optimized BGEMM kernel is not available. this might be also valuable to throw a warning for the caller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. But can you explain your use case a bit, I'm curious why you need to turn off XNNPack in the interpreter.
@@ -40,11 +42,17 @@ def __init__( | |||
flatbuffer_model: bytes, | |||
num_threads: int = 1, | |||
use_reference_bconv: bool = False, | |||
use_indirect_bgemm: bool = False, | |||
use_xnnpack: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this changes the default or am I missing something? I think that's fine, but can you explain the reasoning behind it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @lgeiger. you're correct. following the discussion on #713 I've implemented it like this.
A) one reason to include this flag in the LceInterpreter is to make it reflect more the behavior of the benchmark binary.
B) the second reason is dynamic allocation, thus having models with allocation_type==kTfLiteDynamic
.
we had models like this and when we set use_xnnpack=true
in the benchmark_model there will be an error thrown. this would be true for LCEInterpreter as well, as under the hood XNNPACK is "silently" applied.
That sounds good yes. It's probably easiest to do it in
It seems that the TFLite conv kernels don't have any warnings there either, so I think we can leave those like it is. |
…h set to true in lce_ops_register.h
perfect. I've added this as you suggested with the |
I'm not sure, I think you might need |
I think the PR is finished, right @simonmaurer ? Then it can be merged. |
yessir 💪 |
In general, this PR allows registering of the different kernel implementations of LceBconv2D (
lce_register_ops.h
) by additional parameters in LceInterpreter and flags in lce_benchmark_model binaryWhat do these changes do?
lce_benchmark_model
use_reference_bconv
/use_indirect_bgemm
as global variables to register respective kernel implementationsLceInterpreter
use_indirect_bgemm
to register optimized indirect BGEMM kernel usingRegister_BCONV_2D_OPT_INDIRECT_BGEMM()
in lce_register_ops.huse_xnnpack
in interpreter_wrapper_lite.cc to applyBuiltinOpResolver
when true, otherwiseBuiltinOpResolverWithoutDefaultDelegates
Related issue number
#711, #713