Skip to content

Commit

Permalink
chore(android): format
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Jul 22, 2024
1 parent f933e32 commit 9722026
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions android/src/main/java/com/rnllama/LlamaContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,33 +237,33 @@ public void release() {
static {
Log.d(NAME, "Primary ABI: " + Build.SUPPORTED_ABIS[0]);
if (LlamaContext.isArm64V8a()) {
String cpuFeatures = LlamaContext.getCpuFeatures();
Log.d(NAME, "CPU features: " + cpuFeatures);
String cpuFeatures = LlamaContext.getCpuFeatures();
Log.d(NAME, "CPU features: " + cpuFeatures);

boolean hasFp16 = cpuFeatures.contains("fp16") || cpuFeatures.contains("fphp");
boolean hasDotProd = cpuFeatures.contains("dotprod") || cpuFeatures.contains("asimddp");
boolean isAtLeastArmV82 = cpuFeatures.contains("asimd") && cpuFeatures.contains("crc32") && cpuFeatures.contains("aes");
boolean isAtLeastArmV84 = cpuFeatures.contains("dcpop") && cpuFeatures.contains("uscat");
boolean hasFp16 = cpuFeatures.contains("fp16") || cpuFeatures.contains("fphp");
boolean hasDotProd = cpuFeatures.contains("dotprod") || cpuFeatures.contains("asimddp");
boolean isAtLeastArmV82 = cpuFeatures.contains("asimd") && cpuFeatures.contains("crc32") && cpuFeatures.contains("aes");
boolean isAtLeastArmV84 = cpuFeatures.contains("dcpop") && cpuFeatures.contains("uscat");

if (isAtLeastArmV84 && hasFp16 && hasDotProd) {
Log.d(NAME, "Loading librnllama_v8_4_fp16_dotprod.so");
System.loadLibrary("rnllama_v8_4_fp16_dotprod");
} else if (isAtLeastArmV82 && hasFp16 && hasDotProd) {
Log.d(NAME, "Loading librnllama_v8_2_fp16_dotprod.so");
System.loadLibrary("rnllama_v8_2_fp16_dotprod");
} else if (isAtLeastArmV82 && hasFp16) {
Log.d(NAME, "Loading librnllama_v8_2_fp16.so");
System.loadLibrary("rnllama_v8_2_fp16");
} else {
Log.d(NAME, "Loading librnllama_v8.so");
System.loadLibrary("rnllama_v8");
}
if (isAtLeastArmV84 && hasFp16 && hasDotProd) {
Log.d(NAME, "Loading librnllama_v8_4_fp16_dotprod.so");
System.loadLibrary("rnllama_v8_4_fp16_dotprod");
} else if (isAtLeastArmV82 && hasFp16 && hasDotProd) {
Log.d(NAME, "Loading librnllama_v8_2_fp16_dotprod.so");
System.loadLibrary("rnllama_v8_2_fp16_dotprod");
} else if (isAtLeastArmV82 && hasFp16) {
Log.d(NAME, "Loading librnllama_v8_2_fp16.so");
System.loadLibrary("rnllama_v8_2_fp16");
} else {
Log.d(NAME, "Loading librnllama_v8.so");
System.loadLibrary("rnllama_v8");
}
} else if (LlamaContext.isX86_64()) {
Log.d(NAME, "Loading librnllama_x86_64.so");
System.loadLibrary("rnllama_x86_64");
Log.d(NAME, "Loading librnllama_x86_64.so");
System.loadLibrary("rnllama_x86_64");
} else {
Log.d(NAME, "Loading default librnllama.so");
System.loadLibrary("rnllama");
Log.d(NAME, "Loading default librnllama.so");
System.loadLibrary("rnllama");
}
}

Expand Down

0 comments on commit 9722026

Please sign in to comment.