Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package org.pytorch.executorch;

import android.util.Log;
import com.facebook.jni.HybridData;
import com.facebook.jni.annotations.DoNotStrip;
import com.facebook.soloader.nativeloader.NativeLoader;
Expand All @@ -18,6 +17,7 @@
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Logger;
import org.pytorch.executorch.annotations.Experimental;

/**
Expand All @@ -27,6 +27,7 @@
*/
@Experimental
public class Module {
private static final Logger LOGGER = Logger.getLogger("ExecuTorch");

static {
if (!NativeLoader.isInitialized()) {
Expand Down Expand Up @@ -139,7 +140,7 @@ public EValue[] execute(String methodName, EValue... inputs) {
try {
mLock.lock();
if (!mHybridData.isValid()) {
Log.e("ExecuTorch", "Attempt to use a destroyed module");
LOGGER.severe("Attempt to use a destroyed module");
return new EValue[0];
}
return executeNative(methodName, inputs);
Expand All @@ -164,7 +165,7 @@ public int loadMethod(String methodName) {
try {
mLock.lock();
if (!mHybridData.isValid()) {
Log.e("ExecuTorch", "Attempt to use a destroyed module");
LOGGER.severe("Attempt to use a destroyed module");
return 0x2; // InvalidState
}
return loadMethodNative(methodName);
Expand Down Expand Up @@ -251,8 +252,7 @@ public void destroy() {
mLock.unlock();
}
} else {
Log.w(
"ExecuTorch",
LOGGER.warning(
"Destroy was called while the module was in use. Resources will not be immediately"
+ " released.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package org.pytorch.executorch;

import android.util.Log;
import com.facebook.jni.HybridData;
import com.facebook.jni.annotations.DoNotStrip;
import java.nio.Buffer;
Expand All @@ -21,6 +20,7 @@
import java.nio.ShortBuffer;
import java.util.Arrays;
import java.util.Locale;
import java.util.logging.Logger;
import org.pytorch.executorch.annotations.Experimental;

/**
Expand All @@ -44,6 +44,7 @@
*/
@Experimental
public abstract class Tensor {
private static final Logger LOGGER = Logger.getLogger("ExecuTorch");
private static final String ERROR_MSG_DATA_BUFFER_NOT_NULL = "Data buffer must be not null";
private static final String ERROR_MSG_DATA_ARRAY_NOT_NULL = "Data array must be not null";
private static final String ERROR_MSG_SHAPE_NOT_NULL = "Shape must be not null";
Expand Down Expand Up @@ -846,8 +847,7 @@ private Tensor_unsupported(ByteBuffer data, long[] shape, DType dtype) {
super(shape);
this.data = data;
this.mDtype = dtype;
Log.e(
"ExecuTorch",
LOGGER.severe(
toString() + " in Java. Please consider re-export the model with proper return type");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

package org.pytorch.executorch.training;

import android.util.Log;
import com.facebook.jni.HybridData;
import com.facebook.jni.annotations.DoNotStrip;
import com.facebook.soloader.nativeloader.NativeLoader;
import com.facebook.soloader.nativeloader.SystemDelegate;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.pytorch.executorch.EValue;
import org.pytorch.executorch.Tensor;
import org.pytorch.executorch.annotations.Experimental;
Expand All @@ -27,6 +27,7 @@
*/
@Experimental
public class TrainingModule {
private static final Logger LOGGER = Logger.getLogger("ExecuTorch");

static {
if (!NativeLoader.isInitialized()) {
Expand Down Expand Up @@ -88,7 +89,7 @@ public static TrainingModule load(final String modelPath) {
*/
public EValue[] executeForwardBackward(String methodName, EValue... inputs) {
if (!mHybridData.isValid()) {
Log.e("ExecuTorch", "Attempt to use a destroyed module");
LOGGER.severe("Attempt to use a destroyed module");
return new EValue[0];
}
return executeForwardBackwardNative(methodName, inputs);
Expand All @@ -99,7 +100,7 @@ public EValue[] executeForwardBackward(String methodName, EValue... inputs) {

public Map<String, Tensor> namedParameters(String methodName) {
if (!mHybridData.isValid()) {
Log.e("ExecuTorch", "Attempt to use a destroyed module");
LOGGER.severe("Attempt to use a destroyed module");
return new HashMap<String, Tensor>();
}
return namedParametersNative(methodName);
Expand All @@ -110,7 +111,7 @@ public Map<String, Tensor> namedParameters(String methodName) {

public Map<String, Tensor> namedGradients(String methodName) {
if (!mHybridData.isValid()) {
Log.e("ExecuTorch", "Attempt to use a destroyed module");
LOGGER.severe("Attempt to use a destroyed module");
return new HashMap<String, Tensor>();
}
return namedGradientsNative(methodName);
Expand Down