Skip to content

Commit d956392

Browse files
committed
Fix
1 parent 0d38a99 commit d956392

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

extension/android/executorch_android/src/androidTest/java/org/pytorch/executorch/LlmModuleInstrumentationTest.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ import android.Manifest
1111
import androidx.test.InstrumentationRegistry
1212
import androidx.test.ext.junit.runners.AndroidJUnit4
1313
import androidx.test.rule.GrantPermissionRule
14-
import java.io.File
15-
import java.io.IOException
16-
import java.net.URISyntaxException
1714
import org.apache.commons.io.FileUtils
1815
import org.json.JSONException
1916
import org.json.JSONObject
@@ -24,6 +21,9 @@ import org.junit.Test
2421
import org.junit.runner.RunWith
2522
import org.pytorch.executorch.extension.llm.LlmCallback
2623
import org.pytorch.executorch.extension.llm.LlmModule
24+
import java.io.File
25+
import java.io.IOException
26+
import java.net.URISyntaxException
2727

2828
/** Unit tests for [org.pytorch.executorch.extension.llm.LlmModule]. */
2929
@RunWith(AndroidJUnit4::class)
@@ -101,7 +101,8 @@ class LlmModuleInstrumentationTest : LlmCallback {
101101
val promptEvalEndMs = jsonObject.getInt("prompt_eval_end_ms")
102102
tps = numGeneratedTokens.toFloat() / (inferenceEndMs - promptEvalEndMs) * 1000
103103
tokensPerSecond.add(tps)
104-
} catch (_: JSONException) {}
104+
} catch (_: JSONException) {
105+
}
105106
}
106107

107108
companion object {

extension/android/executorch_android/src/androidTest/java/org/pytorch/executorch/ModuleE2ETest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import android.graphics.BitmapFactory
1313
import androidx.test.InstrumentationRegistry
1414
import androidx.test.ext.junit.runners.AndroidJUnit4
1515
import androidx.test.rule.GrantPermissionRule
16-
import java.io.File
17-
import java.io.IOException
18-
import java.net.URISyntaxException
1916
import org.apache.commons.io.FileUtils
2017
import org.junit.Assert
2118
import org.junit.Rule
2219
import org.junit.Test
2320
import org.junit.runner.RunWith
2421
import org.pytorch.executorch.TensorImageUtils.bitmapToFloat32Tensor
22+
import java.io.File
23+
import java.io.IOException
24+
import java.net.URISyntaxException
2525

2626
/** Unit tests for [Module]. */
2727
@RunWith(AndroidJUnit4::class)

extension/android/executorch_android/src/androidTest/java/org/pytorch/executorch/ModuleInstrumentationTest.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ import android.Manifest
1111
import androidx.test.InstrumentationRegistry
1212
import androidx.test.ext.junit.runners.AndroidJUnit4
1313
import androidx.test.rule.GrantPermissionRule
14-
import java.io.File
15-
import java.io.IOException
16-
import java.net.URISyntaxException
17-
import java.util.concurrent.CountDownLatch
18-
import java.util.concurrent.TimeUnit
19-
import java.util.concurrent.atomic.AtomicInteger
2014
import org.apache.commons.io.FileUtils
2115
import org.junit.Assert
2216
import org.junit.Before
2317
import org.junit.Rule
2418
import org.junit.Test
2519
import org.junit.runner.RunWith
20+
import java.io.File
21+
import java.io.IOException
22+
import java.net.URISyntaxException
23+
import java.util.concurrent.CountDownLatch
24+
import java.util.concurrent.TimeUnit
25+
import java.util.concurrent.atomic.AtomicInteger
2626

2727
/** Unit tests for [Module]. */
2828
@RunWith(AndroidJUnit4::class)
@@ -152,7 +152,8 @@ class ModuleInstrumentationTest {
152152
val results = module.forward()
153153
Assert.assertTrue(results[0].isTensor)
154154
completed.incrementAndGet()
155-
} catch (_: InterruptedException) {}
155+
} catch (_: InterruptedException) {
156+
}
156157
}
157158

158159
val threads = arrayOfNulls<Thread>(numThreads)

extension/android/executorch_android/src/androidTest/java/org/pytorch/executorch/TensorImageUtils.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ import java.nio.FloatBuffer
1616
* [android.media.Image] source.
1717
*/
1818
object TensorImageUtils {
19-
@JvmField var TORCHVISION_NORM_MEAN_RGB: FloatArray = floatArrayOf(0.485f, 0.456f, 0.406f)
19+
@JvmField
20+
var TORCHVISION_NORM_MEAN_RGB: FloatArray = floatArrayOf(0.485f, 0.456f, 0.406f)
2021

21-
@JvmField var TORCHVISION_NORM_STD_RGB: FloatArray = floatArrayOf(0.229f, 0.224f, 0.225f)
22+
@JvmField
23+
var TORCHVISION_NORM_STD_RGB: FloatArray = floatArrayOf(0.229f, 0.224f, 0.225f)
2224

2325
/**
2426
* Creates new [Tensor] from full [android.graphics.Bitmap], normalized with specified in
@@ -144,9 +146,9 @@ object TensorImageUtils {
144146
private fun checkRotateCWDegrees(rotateCWDegrees: Int) {
145147
require(
146148
!(rotateCWDegrees != 0 &&
147-
rotateCWDegrees != 90 &&
148-
rotateCWDegrees != 180 &&
149-
rotateCWDegrees != 270)
149+
rotateCWDegrees != 90 &&
150+
rotateCWDegrees != 180 &&
151+
rotateCWDegrees != 270)
150152
) {
151153
"rotateCWDegrees must be one of 0, 90, 180, 270"
152154
}

extension/android/jni/jni_layer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ class ExecuTorchJni : public facebook::jni::HybridClass<ExecuTorchJni> {
480480
facebook::jni::local_ref<facebook::jni::JArrayInt> ret =
481481
facebook::jni::JArrayInt::newArray(num_inputs);
482482

483-
int i = 0;
484483
for (int i = 0; i < num_inputs; i++) {
485484
ret->pin()[i] = static_cast<uint32_t>(method_meta.input_tag(i).get());
486485
}
@@ -495,7 +494,6 @@ class ExecuTorchJni : public facebook::jni::HybridClass<ExecuTorchJni> {
495494
facebook::jni::local_ref<facebook::jni::JArrayInt> ret =
496495
facebook::jni::JArrayInt::newArray(num_outputs);
497496

498-
int i = 0;
499497
for (int i = 0; i < num_outputs; i++) {
500498
ret->pin()[i] = static_cast<uint32_t>(method_meta.output_tag(i).get());
501499
}

0 commit comments

Comments
 (0)