Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions extension/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
allprojects {
buildscript {
ext {
minSdkVersion = 21
targetSdkVersion = 34
compileSdkVersion = 34
buildToolsVersion = '33.0.1'

fbjniJavaOnlyVersion = "0.7.0"
soLoaderNativeLoaderVersion = "0.10.5"
}
Expand Down
14 changes: 7 additions & 7 deletions extension/android/executorch_android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
Comment thread
kirklandsign marked this conversation as resolved.

sourceSets {
Expand All @@ -49,7 +49,7 @@ android {
}
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "11"
}
}

Expand All @@ -61,12 +61,12 @@ dependencies {
implementation 'com.facebook.fbjni:fbjni:0.7.0'
implementation 'com.facebook.soloader:nativeloader:0.10.5'
implementation libs.core.ktx
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.assertj:assertj-core:3.27.2'
testImplementation 'org.jetbrains.kotlin:kotlin-test:1.9.23'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'commons-io:commons-io:2.4'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test:rules:1.6.1'
androidTestImplementation 'commons-io:commons-io:2.18.0'
androidTestImplementation 'org.json:json:20250107'
androidTestImplementation 'org.jetbrains.kotlin:kotlin-test:1.9.23'
if (qnnVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class Module {

@DoNotStrip
private static native HybridData initHybrid(
String moduleAbsolutePath, int loadMode, int initHybrid);
String moduleAbsolutePath, int loadMode, int numThreads);

private Module(String moduleAbsolutePath, int loadMode, int numThreads) {
ExecuTorchRuntime runtime = ExecuTorchRuntime.getRuntime();
Expand Down Expand Up @@ -201,7 +201,7 @@ public int loadMethod(String methodName) {
*/
public MethodMetadata getMethodMetadata(String name) {
if (!mMethodMetadata.containsKey(name)) {
throw new RuntimeException("method " + name + "does not exist for this module");
throw new RuntimeException("method " + name + " does not exist for this module");
}

MethodMetadata methodMetadata = mMethodMetadata.get(name);
Expand Down
10 changes: 7 additions & 3 deletions extension/android/jni/jni_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ class TensorHybrid : public facebook::jni::HybridClass<TensorHybrid> {
// Java wrapper currently only supports contiguous tensors.

const auto scalarType = tensor.scalar_type();
int jdtype = scalar_type_to_java_dtype.at(scalarType);
if (scalar_type_to_java_dtype.count(scalarType) == 0) {
std::stringstream ss;
ss << "executorch::aten::Tensor scalar [java] type: " << jdtype
<< " is not supported on java side";
ss << "executorch::aten::Tensor scalar type "
<< static_cast<int>(scalarType) << " is not supported on java side";
jni_helper::throwExecutorchException(
static_cast<uint32_t>(Error::InvalidArgument), ss.str().c_str());
Comment thread
kirklandsign marked this conversation as resolved.
return nullptr;
}
int jdtype = scalar_type_to_java_dtype.at(scalarType);

const auto& tensor_shape = tensor.sizes();
std::vector<jlong> tensor_shape_vec;
Expand Down Expand Up @@ -131,6 +132,7 @@ class TensorHybrid : public facebook::jni::HybridClass<TensorHybrid> {
ss << "Unknown Tensor jdtype: [" << jdtype << "]";
jni_helper::throwExecutorchException(
static_cast<uint32_t>(Error::InvalidArgument), ss.str().c_str());
return nullptr;
}
ScalarType scalar_type = java_dtype_to_scalar_type.at(jdtype);
const jlong dataCapacity = jni->GetDirectBufferCapacity(jbuffer.get());
Expand All @@ -139,6 +141,7 @@ class TensorHybrid : public facebook::jni::HybridClass<TensorHybrid> {
ss << "Tensor buffer is not direct or has invalid capacity";
jni_helper::throwExecutorchException(
static_cast<uint32_t>(Error::InvalidArgument), ss.str().c_str());
return nullptr;
}
const size_t elementSize = executorch::runtime::elementSize(scalar_type);
const jlong expectedElements = static_cast<jlong>(numel);
Expand All @@ -153,6 +156,7 @@ class TensorHybrid : public facebook::jni::HybridClass<TensorHybrid> {
<< " (element size bytes: " << elementSize << ")";
jni_helper::throwExecutorchException(
static_cast<uint32_t>(Error::InvalidArgument), ss.str().c_str());
return nullptr;
}
return from_blob(
jni->GetDirectBufferAddress(jbuffer.get()), shape_vec, scalar_type);
Expand Down
Loading