Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Paddle] add remove pass option #1141

Merged
merged 1 commit into from
Aug 4, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ public void load(Path modelPath, String prefix, Map<String, ?> options) throws I
if (System.getenv().containsKey("PADDLE_ENABLE_MKLDNN")) {
JniUtils.enableMKLDNN(config);
}
if (options != null && options.containsKey("removePass")) {
String[] values = ((String) options.get("removePass")).split(",");
for (String value : values) {
JniUtils.removePass(config, value);
}
}
paddlePredictor = new PaddlePredictor(JniUtils.createPredictor(config));
JniUtils.deleteConfig(config);
setBlock(new PpSymbolBlock(paddlePredictor));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public static void enableMKLDNN(long config) {
PaddleLibrary.LIB.analysisConfigEnableMKLDNN(config);
}

public static void removePass(long config, String pass) {
PaddleLibrary.LIB.analysisConfigRemovePass(config, pass);
}

public static void useFeedFetchOp(long config) {
PaddleLibrary.LIB.useFeedFetchOp(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ private PaddleLibrary() {}

native void analysisConfigEnableMKLDNN(long handle);

native void analysisConfigRemovePass(long handle, String pass);

native void useFeedFetchOp(long handle);

native void deleteAnalysisConfig(long handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ JNIEXPORT void JNICALL Java_ai_djl_paddlepaddle_jni_PaddleLibrary_analysisConfig
config_ptr->EnableMKLDNN();
}

JNIEXPORT void JNICALL Java_ai_djl_paddlepaddle_jni_PaddleLibrary_analysisConfigRemovePass(
JNIEnv* env, jobject jthis, jlong jhandle, jstring jpass) {
auto* config_ptr = reinterpret_cast<paddle::AnalysisConfig*>(jhandle);
config_ptr->pass_builder()->DeletePass(djl::utils::jni::GetStringFromJString(env, jpass));
}

JNIEXPORT void JNICALL Java_ai_djl_paddlepaddle_jni_PaddleLibrary_deleteAnalysisConfig(
JNIEnv* env, jobject jthis, jlong jhandle) {
const auto* config_ptr = reinterpret_cast<paddle::AnalysisConfig*>(jhandle);
Expand Down