-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[android] Test application for profiling, CMake params for debug symbols #28406
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
[android] Test application for profiling, CMake params for debug symbols #28406
Conversation
73f2038 to
da13dbf
Compare
AshkanAliabadi
left a comment
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.
Awesome, thank you so much for doing this. You and Tao are life savers.
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.
Am I correct to assume that since I don't spot a loop here, we are calling PyTorch forward only one time? Or is this function called from a loop somewhere?
I am mainly asking this question to understand whether we are profiling one or multiple runs of a network here. I think it is worthwhile to be able to have the ability to run a network multiple times through a configurable parameter to be able to study thermal behavior.
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.
P.S. It can be the same image sent to the network over and over again to avoid image acquisition and decoding overhead.
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.
private final Runnable mModuleForwardRunnable = new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
handleResult(doModuleForward());
if (mBackgroundHandler != null) {
mBackgroundHandler.post(mModuleForwardRunnable);
}
}
});
}
};
We call doModuleForward() in a loop, but its organized with scheduling the same implementation of Runnable interface mModuleForwardRunnable on mBackgroundHandler which does queue
of Runnableprocessing.
So it will put it on queue of the thread mBackgroundThread = new HandlerThread(TAG + "_bg"); the name depends what we put in build.gradle as LOG_TAG
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.
P.S. It can be the same image sent to the network over and over again to avoid image acquisition and decoding overhead.
At the moment here we even do not have image - just allocating buffer of proper size and creating tensor from it - so we should not see any overhead from camera, image decoding etc.
da13dbf to
33af80c
Compare
android/test_app/app/build.gradle
Outdated
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.
nit: can you change the model names to mobilenet_v2 and resnet18 where it is used?
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.
Ok
33af80c to
0b010d1
Compare
|
I don't think we should check in the models, since they are quite big. That puts a tax on everyone using this repo. Maybe have the build script download them from somewhere? Also, we don't need the hdpi and x*hdpi icons. Scaling up mdpi is fine. Other than that, I think this is fine as long as it works for you and Ashkan. |
d449f0f to
1a86fbf
Compare
android/settings.gradle
Outdated
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.
Why isn't this ':test_app'?
android/test_app/build.gradle
Outdated
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.
Do we need this, since the top-level build.gradle already does it?
1a86fbf to
c9da33d
Compare
facebook-github-bot
left a comment
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.
@IvanKobzarev has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
c9da33d to
adee5e7
Compare
adee5e7 to
c0f5360
Compare
facebook-github-bot
left a comment
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.
@IvanKobzarev has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
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.
@IvanKobzarev has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
@IvanKobzarev merged this pull request in 92b9de1. |
Reason:
To have one-step build for test android application based on the current code state that is ready for profiling with simpleperf, systrace etc. to profile performance inside the application.
Parameters to control debug symbols stripping
Introducing /CMakeLists parameter
ANDROID_DEBUG_SYMBOLSto be able not to strip symbols for pytorch (not add linker flag-s)which is checked in
scripts/build_android.shOn gradle side stripping happens by default, and to prevent it we have to specify
which is now controlled by new gradle property
nativeLibsDoNotStripTest_App
android/test_app- android app with one MainActivity that does inference in cycleandroid/build_test_app.sh- script to build libtorch with debug symbols for specified android abis and addsNDK_DEBUG=1and-PnativeLibsDoNotStrip=trueto keep all debug symbols for profiling.Script assembles all debug flavors:
Different build configurations
Module for inference can be set in
android/test_app/app/build.gradleas a BuildConfig parameters:In that case we can setup several apps on the same device for comparison, to separate packages
applicationIdSuffix: 'org.pytorch.testapp.mobilenetQuant' and different application names and logcat tags asmanifestPlaceholderand another BuildConfig parameter:In future we can add another BuildConfig params e.g. single/multi threads and other configuration for profiling.
At the moment 2 flavors - for resnet18 and for mobilenetQuantized
which can be installed on connected device:
Testing:
Simpleperf report has all symbols:
