Skip to content

[android] Custom build tutorial section #320

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

Conversation

IvanKobzarev
Copy link
Contributor

@IvanKobzarev IvanKobzarev commented Dec 17, 2019

Also we have to add all transitive dependencies of our aars. As pytorch_android depends on com.android.support:appcompat-v7:28.0.0 and com.facebook.soloader:nativeloader:0.8.0, we need to add them. (In case of using maven dependencies they are added automatically from pom.xml).

Also contains small sync for previous section about adding transitive dependencies when aar files are used directly.

```

After successful build you can integrate the result aar files to your android gradle project, following the steps from previous section of this tutorial (Building PyTorch Android from Source).

## More Details
Copy link
Contributor

@jlin27 jlin27 Dec 17, 2019

Choose a reason for hiding this comment

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

Rather than "More Details", should we change this header to something more descriptive? Suggestion - "API Docs" to match the header in iOS


## Custom Build

To reduce the size of binaries you can do custom build of pytorch android with only set of operators required by your model.
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalize "PyTorch Android" to stay consistent with rest of the document

To reduce the size of binaries you can do custom build of pytorch android with only set of operators required by your model.
This includes two steps: preparing the list of operators from your model, rebuilding pytorch android with specified list.

1\. Preparation of the list of operators.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove period at the end to stay consistent with the numbering in the rest of document

f = open('test.yaml', 'w')
yaml.dump(ops, f)
```
2\. Building pytorch android with prepared operators list.
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalize "PyTorch Android" and remove period for consistency

```
2\. Building pytorch android with prepared operators list.

To build pytorch android with prepared yaml list of operators you specify it in environment variable `SELECTED_OP_LIST` and specify as arguments of android ABIs for which you want to build it, by default it builds all 4 android ABIs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalize "PyTorch Android" for consistency

Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalize "Android ABIs"

Copy link
Contributor

@jlin27 jlin27 Dec 17, 2019

Choose a reason for hiding this comment

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

Suggested rewording to be more succinct -

To build PyTorch Android with the prepared yaml list of operators, specify it in the environment variable SELECTED_OP_LIST. Also in the arguments, specify which Android ABIs it should build; by default it builds all 4 Android ABIs.

Also consider adding link to docs for this environment variable and its arguments

@jlin27
Copy link
Contributor

jlin27 commented Dec 20, 2019

Changes for just android.md added into this PR to avoid pulling in the other file changes

#325

@jlin27 jlin27 closed this Dec 20, 2019
import torch, yaml
m = torch.jit.load("example.pt")
ops = torch.jit.export_opnames(m)
f = open('test.yaml', 'w')
Copy link

Choose a reason for hiding this comment

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

nit: shall we use 'with' statement?

with open('MobileNetV2.yaml', 'w') as file:
  yaml.dump(ops, file)

And I saw Android/iOS examples are slightly different in terms of file naming, shall we change both to 'MobileNetV2'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants