mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Fix syntax highlighting in android (#117439)
Hi i have found code blocks are not highlighted properly. This PR aims to fix that Pull Request resolved: https://github.com/pytorch/pytorch/pull/117439 Approved by: https://github.com/ezyang
This commit is contained in:
parent
735715e6d3
commit
3cd2c68fbe
|
|
@ -9,7 +9,7 @@ Demo applications with code walk-through can be find in [this github repo](https
|
||||||
##### Release
|
##### Release
|
||||||
Release artifacts are published to jcenter:
|
Release artifacts are published to jcenter:
|
||||||
|
|
||||||
```
|
```groovy
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
@ -32,7 +32,7 @@ dependencies {
|
||||||
Nightly(snapshots) builds are published every night from `master` branch to [nexus sonatype snapshots repository](https://oss.sonatype.org/#nexus-search;quick~pytorch_android)
|
Nightly(snapshots) builds are published every night from `master` branch to [nexus sonatype snapshots repository](https://oss.sonatype.org/#nexus-search;quick~pytorch_android)
|
||||||
|
|
||||||
To use them repository must be specified explicitly:
|
To use them repository must be specified explicitly:
|
||||||
```
|
```groovy
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url "https://oss.sonatype.org/content/repositories/snapshots"
|
url "https://oss.sonatype.org/content/repositories/snapshots"
|
||||||
|
|
@ -62,7 +62,7 @@ The current nightly(snapshots) version is the value of `VERSION_NAME` in `gradle
|
||||||
In some cases you might want to use a local build of pytorch android, for example you may build custom libtorch binary with another set of operators or to make local changes.
|
In some cases you might want to use a local build of pytorch android, for example you may build custom libtorch binary with another set of operators or to make local changes.
|
||||||
|
|
||||||
For this you can use `./scripts/build_pytorch_android.sh` script.
|
For this you can use `./scripts/build_pytorch_android.sh` script.
|
||||||
```
|
```bash
|
||||||
git clone https://github.com/pytorch/pytorch.git
|
git clone https://github.com/pytorch/pytorch.git
|
||||||
cd pytorch
|
cd pytorch
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
|
@ -91,14 +91,14 @@ They are specified as environment variables:
|
||||||
|
|
||||||
After successful build you should see the result as aar file:
|
After successful build you should see the result as aar file:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$ find pytorch_android/build/ -type f -name *aar
|
$ find pytorch_android/build/ -type f -name *aar
|
||||||
pytorch_android/build/outputs/aar/pytorch_android.aar
|
pytorch_android/build/outputs/aar/pytorch_android.aar
|
||||||
pytorch_android_torchvision/build/outputs/aar/pytorch_android.aar
|
pytorch_android_torchvision/build/outputs/aar/pytorch_android.aar
|
||||||
```
|
```
|
||||||
|
|
||||||
It can be used directly in android projects, as a gradle dependency:
|
It can be used directly in android projects, as a gradle dependency:
|
||||||
```
|
```groovy
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
flatDir {
|
flatDir {
|
||||||
|
|
@ -126,7 +126,7 @@ You can check out [test app example](https://github.com/pytorch/pytorch/blob/mas
|
||||||
In some cases, you may want to use libtorch from your android native build.
|
In some cases, you may want to use libtorch from your android native build.
|
||||||
You can do it without building libtorch android, using native libraries from PyTorch android gradle dependency.
|
You can do it without building libtorch android, using native libraries from PyTorch android gradle dependency.
|
||||||
For that, you will need to add the next lines to your gradle build.
|
For that, you will need to add the next lines to your gradle build.
|
||||||
```
|
```groovy
|
||||||
android {
|
android {
|
||||||
...
|
...
|
||||||
configurations {
|
configurations {
|
||||||
|
|
@ -181,7 +181,7 @@ The added task will unpack them to gradle build directory.
|
||||||
In your native build you can link to them adding these lines to your CMakeLists.txt:
|
In your native build you can link to them adding these lines to your CMakeLists.txt:
|
||||||
|
|
||||||
|
|
||||||
```
|
```cmake
|
||||||
# Relative path of gradle build directory to CMakeLists.txt
|
# Relative path of gradle build directory to CMakeLists.txt
|
||||||
set(build_DIR ${CMAKE_SOURCE_DIR}/build)
|
set(build_DIR ${CMAKE_SOURCE_DIR}/build)
|
||||||
|
|
||||||
|
|
@ -209,7 +209,7 @@ target_link_libraries(${PROJECT_NAME}
|
||||||
If your CMakeLists.txt file is located in the same directory as your build.gradle, `set(build_DIR ${CMAKE_SOURCE_DIR}/build)` should work for you. But if you have another location of it, you may need to change it.
|
If your CMakeLists.txt file is located in the same directory as your build.gradle, `set(build_DIR ${CMAKE_SOURCE_DIR}/build)` should work for you. But if you have another location of it, you may need to change it.
|
||||||
|
|
||||||
After that, you can use libtorch C++ API from your native code.
|
After that, you can use libtorch C++ API from your native code.
|
||||||
```
|
```cpp
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ATen/NativeFunctions.h>
|
#include <ATen/NativeFunctions.h>
|
||||||
#include <torch/script.h>
|
#include <torch/script.h>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user