Skip to content

Use nativeloader instead of system loader to load JNI library for soloader compatibility. #29350

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

Closed
wants to merge 5 commits into from

Conversation

xcheng16
Copy link
Contributor

@xcheng16 xcheng16 commented Nov 7, 2019

Stack from ghstack:

Differential Revision: D18352773

xcheng16 pushed a commit that referenced this pull request Nov 7, 2019
Differential Revision: [D18352773](https://our.internmc.facebook.com/intern/diff/D18352773/)

ghstack-source-id: 93421897
Pull Request resolved: #29350
xcheng16 pushed a commit that referenced this pull request Nov 7, 2019
Pull Request resolved: #29350


ghstack-source-id: 93453413

Differential Revision: [D18352773](https://our.internmc.facebook.com/intern/diff/D18352773/)
xcheng16 pushed a commit that referenced this pull request Nov 7, 2019
Pull Request resolved: #29350


ghstack-source-id: 93460392

Differential Revision: [D18352773](https://our.internmc.facebook.com/intern/diff/D18352773/)
xcheng16 pushed a commit that referenced this pull request Nov 7, 2019
Pull Request resolved: #29350


ghstack-source-id: 93469427

Differential Revision: [D18352773](https://our.internmc.facebook.com/intern/diff/D18352773/)
Copy link
Contributor

@dreiss dreiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The "T" in PyTorch is capitalized.

Title shouldn't have "[PyTorch]" in GitHub (ghimport should automatically add it internally).

Title should probably clearly state "Use NativeLoader instead of system loader to load JNI library", and should say why we want to do this (so it's compatible with SoLoader).

libtorch
-Wl,--no-whole-archive
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for the Android build. I don't think it needs to change.

torch
-Wl,--no-whole-archive
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I suspect this breaks the Linux build, which links with gold. Any way we can get both Mac and Linux builds to work?

Also, this is not related to the subject of the diff. Please use separate diffs for unrelated changes.

@@ -1,28 +1,22 @@
package org.pytorch;

import com.facebook.soloader.nativeloader.NativeLoader;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this file was reformatted. Can you do that as a separate diff first to make this change more self-contained?

NativeLoader.init(new SystemDelegate());
}
}
public static void setUpClass() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed.

public void setUp() {
System.loadLibrary("pytorch");
}
public void setUp() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed.

3.1415f,
-1,
0,
1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformat should be a separate diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when update the diff, it auto-format the file, i can revert it.

@@ -418,7 +418,7 @@ class JIValue : public facebook::jni::JavaClass<JIValue> {
} else if (JIValue::kTypeCodeLong == typeCode) {
static const auto jMethodGetLong =
JIValue::javaClassStatic()->getMethod<jlong()>("toLong");
return at::IValue{jMethodGetLong(jivalue)};
return at::IValue{(int64_t)jMethodGetLong(jivalue)};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the Mac PR, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, It is for mac, I will create separate pr for it.

xcheng16 pushed a commit that referenced this pull request Nov 7, 2019
Pull Request resolved: #29350


ghstack-source-id: 93491099

Differential Revision: [D18352773](https://our.internmc.facebook.com/intern/diff/D18352773/)
@xcheng16 xcheng16 changed the title [Pytorch] system loader to native loader. Use NativeLoader instead of system loader to load JNI library for soloader compatibility. Nov 7, 2019
@xcheng16 xcheng16 changed the title Use NativeLoader instead of system loader to load JNI library for soloader compatibility. Use nativeloader instead of system loader to load JNI library for soloader compatibility. Nov 7, 2019
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 8a33f11.

@facebook-github-bot facebook-github-bot deleted the gh/xcheng16/8/head branch November 11, 2019 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants