Skip to content

Commit

Permalink
Update minibench to allow qnn
Browse files Browse the repository at this point in the history
  • Loading branch information
kirklandsign committed Sep 12, 2024
1 parent 4b3f1c5 commit e81c616
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build/build_android_llm_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ build_aar() {
find jni -type f -name "libexecutorch_jni.so" -exec bash -c 'mv "$1" "${1/_jni/}"' bash {} \;
# Zip all necessary files into the AAR file
zip -r executorch.aar libs jni/*/libexecutorch.so jni/*/libqnn*.so jni/*/libQnn*.so AndroidManifest.xml
zip -r executorch-llama.aar libs jni/*/libexecutorch.so jni/*/libqnn*.so jni/*/libQnn*.so AndroidManifest.xml
cp executorch.aar executorch-llama.aar
popd
}

Expand Down
4 changes: 4 additions & 0 deletions extension/android/benchmark/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
android:theme="@style/Theme.MiniBench"
tools:targetApi="31">

<uses-native-library
android:name="libcdsprpc.so"
android:required="false" />

<activity
android:name=".BenchmarkActivity"
android:exported="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.system.ErrnoException;
import android.system.Os;
import com.google.gson.Gson;
import java.io.File;
import java.io.FileWriter;
Expand All @@ -35,6 +37,12 @@ protected void onCreate(Bundle savedInstanceState) {

int numIter = intent.getIntExtra("num_iter", 10);

try {
Os.setenv("ADSP_LIBRARY_PATH", getApplicationInfo().nativeLibraryDir, true);
} catch (ErrnoException e) {
finish();
}

// TODO: Format the string with a parsable format
Stats stats = new Stats();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.system.ErrnoException;
import android.system.Os;
import android.util.Log;
import com.google.gson.Gson;
import java.io.File;
Expand Down Expand Up @@ -44,6 +46,12 @@ protected void onCreate(Bundle savedInstanceState) {
mPrompt = "The ultimate answer";
}

try {
Os.setenv("ADSP_LIBRARY_PATH", getApplicationInfo().nativeLibraryDir, true);
} catch (ErrnoException e) {
finish();
}

mStatsInfo = new StatsInfo();
mModelRunner = new ModelRunner(model.getPath(), tokenizerPath, temperature, this);
mStatsInfo.loadStart = System.currentTimeMillis();
Expand Down

0 comments on commit e81c616

Please sign in to comment.