diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 00000000..84197c89 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +5.3.2 diff --git a/.github/actions/lyra-builder/action.yml b/.github/actions/lyra-builder/action.yml index fb14b3f7..af809062 100644 --- a/.github/actions/lyra-builder/action.yml +++ b/.github/actions/lyra-builder/action.yml @@ -20,11 +20,17 @@ runs: - shell: bash run: | export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/21.4.7075529" - bazel build -c opt lyra/cli_example:encoder_main ${{ inputs.build-options }} + if [[ "${{inputs.platform}}" != "android" ]]; then + bazelisk test -c opt lyra/cli_example:encoder_main_lib_test ${{ inputs.build-options }} + fi + bazelisk build -c opt lyra/cli_example:encoder_main ${{ inputs.build-options }} - shell: bash run: | export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/21.4.7075529" - bazel build -c opt lyra/cli_example:decoder_main ${{ inputs.build-options }} + if [[ "${{inputs.platform}}" != "android" ]]; then + bazelisk test -c opt lyra/cli_example:decoder_main_lib_test ${{ inputs.build-options }} + fi + bazelisk build -c opt lyra/cli_example:decoder_main ${{ inputs.build-options }} - shell: bash run: | mkdir action-product diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5bda4026..79946e7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: shell: bash run: | export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/21.4.7075529" - bazel build lyra/android_example:lyra_android_example --config=android_arm64 --copt=-DBENCHMARK + bazelisk build lyra/android_example:lyra_android_example --config=android_arm64 --copt=-DBENCHMARK - name: Copy artifacts shell: bash run: | diff --git a/README.md b/README.md index c3b534db..c1c39945 100644 --- a/README.md +++ b/README.md @@ -154,15 +154,15 @@ If you press 'Benchmark', you should see something like the following in logcat on a Pixel 6 Pro when running the benchmark: ```shell -lyra_benchmark: feature_extractor: max: 0.575 ms min: 0.131 ms mean: 0.139 ms stdev: 0.004 ms -lyra_benchmark: quantizer_quantize: max: 0.304 ms min: 0.105 ms mean: 0.109 ms stdev: 0.002 ms -lyra_benchmark: quantizer_decode: max: 0.103 ms min: 0.025 ms mean: 0.026 ms stdev: 0.000 ms -lyra_benchmark: model_decode: max: 0.462 ms min: 0.187 ms mean: 0.197 ms stdev: 0.001 ms -lyra_benchmark: total: max: 1.160 ms min: 0.452 ms mean: 0.473 ms stdev: 0.009 ms +lyra_benchmark: feature_extractor: max: 1.836 ms min: 0.132 ms mean: 0.153 ms stdev: 0.042 ms +lyra_benchmark: quantizer_quantize: max: 1.042 ms min: 0.120 ms mean: 0.130 ms stdev: 0.028 ms +lyra_benchmark: quantizer_decode: max: 0.103 ms min: 0.026 ms mean: 0.029 ms stdev: 0.003 ms +lyra_benchmark: model_decode: max: 0.820 ms min: 0.191 ms mean: 0.212 ms stdev: 0.031 ms +lyra_benchmark: total: max: 2.536 ms min: 0.471 ms mean: 0.525 ms stdev: 0.088 ms ``` This shows that decoding a 50Hz frame (each frame is 20 milliseconds) takes -0.473 milliseconds on average. So decoding is performed at around 42 (20/0.473) +0.525 milliseconds on average. So decoding is performed at around 38 (20/0.525) times faster than realtime. To build your own android app, you can either use the cc_library target outputs diff --git a/WORKSPACE b/WORKSPACE index d659d079..388661cb 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -168,9 +168,9 @@ maven_install( git_repository( name = "org_tensorflow", remote = "https://github.com/tensorflow/tensorflow.git", - # Below is reproducible and equivalent to `tag = "v2.9.0"` - commit = "8a20d54a3c1bfa38c03ea99a2ad3c1b0a45dfa95", - shallow_since = "1652465115 -0700" + # Below is reproducible and equivalent to `tag = "v2.11.0"` + commit = "d5b57ca93e506df258271ea00fc29cf98383a374", + shallow_since = "1668561432 -0800" ) # Check bazel version requirement, which is stricter than TensorFlow's. diff --git a/lyra/android_example/java/com/example/android/lyra/MainActivity.java b/lyra/android_example/java/com/example/android/lyra/MainActivity.java index 9ec678cf..5b921b09 100644 --- a/lyra/android_example/java/com/example/android/lyra/MainActivity.java +++ b/lyra/android_example/java/com/example/android/lyra/MainActivity.java @@ -50,6 +50,7 @@ public class MainActivity extends AppCompatActivity { private static final int REQUEST_RECORD_AUDIO_PERMISSION = 200; private static final int SAMPLE_RATE = 16000; + private static final int LYRA_NUM_RANDOM_FEATURE_VECTORS = 10000; private static final String[] permissions = {Manifest.permission.RECORD_AUDIO}; private boolean hasStartedDecode = false; @@ -252,7 +253,7 @@ public void runBenchmark(View view) { Log.i(TAG, "Starting lyraBenchmark()"); // Example of a call to a C++ lyra method on a background // thread. - lyraBenchmark(2000, weightsDirectory); + lyraBenchmark(LYRA_NUM_RANDOM_FEATURE_VECTORS, weightsDirectory); Log.i(TAG, "Finished lyraBenchmark()"); tv.post(() -> tv.setText(R.string.benchmark_finished)); button.post(() -> button.setEnabled(true)); diff --git a/lyra/lyra_config.cc b/lyra/lyra_config.cc index effdb15e..28f201b2 100644 --- a/lyra/lyra_config.cc +++ b/lyra/lyra_config.cc @@ -31,7 +31,7 @@ const int kVersionMajor = 1; // |identifier| field needs to be set in lyra_config.textproto to match this. const int kVersionMinor = 3; // The micro version is for other things like a release of bugfixes. -const int kVersionMicro = 1; +const int kVersionMicro = 2; const int kNumFeatures = 64; const int kNumMelBins = 160; diff --git a/lyra/tflite_model_wrapper.cc b/lyra/tflite_model_wrapper.cc index e3229405..fc3b6b2f 100644 --- a/lyra/tflite_model_wrapper.cc +++ b/lyra/tflite_model_wrapper.cc @@ -63,9 +63,8 @@ std::unique_ptr TfLiteModelWrapper::Create( if (use_xnn) { // Enable XXNPack. auto options = TfLiteXNNPackDelegateOptionsDefault(); - if (int8_quantized) { - options.flags |= TFLITE_XNNPACK_DELEGATE_FLAG_QS8; - } + // TODO(b/219786261) Remove once XNNPACK is enabled by default. + options.flags |= TFLITE_XNNPACK_DELEGATE_FLAG_QU8; options.num_threads = 1; auto delegate = std::unique_ptr >(