Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

build.gradle 3.9 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  1. apply plugin: 'com.android.application'
  2. repositories {
  3. mavenCentral()
  4. maven {
  5. url "https://oss.sonatype.org/content/repositories/snapshots"
  6. }
  7. flatDir {
  8. dirs 'aars'
  9. }
  10. }
  11. android {
  12. configurations {
  13. extractForNativeBuild
  14. }
  15. compileOptions {
  16. sourceCompatibility 1.8
  17. targetCompatibility 1.8
  18. }
  19. compileSdkVersion rootProject.compileSdkVersion
  20. buildToolsVersion rootProject.buildToolsVersion
  21. defaultConfig {
  22. applicationId "org.pytorch.testapp"
  23. minSdkVersion rootProject.minSdkVersion
  24. targetSdkVersion rootProject.targetSdkVersion
  25. versionCode 1
  26. versionName "1.0"
  27. ndk {
  28. abiFilters ABI_FILTERS.split(",")
  29. }
  30. externalNativeBuild {
  31. cmake {
  32. abiFilters ABI_FILTERS.split(",")
  33. arguments "-DANDROID_STL=c++_shared"
  34. }
  35. }
  36. buildConfigField("String", "MODULE_ASSET_NAME", "\"frcnn_mnetv3.pt\"")
  37. buildConfigField("String", "LOGCAT_TAG", "@string/app_name")
  38. buildConfigField("long[]", "INPUT_TENSOR_SHAPE", "new long[]{3, 96, 96}")
  39. addManifestPlaceholders([APP_NAME: "@string/app_name", MAIN_ACTIVITY: "org.pytorch.testapp.MainActivity"])
  40. }
  41. buildTypes {
  42. debug {
  43. minifyEnabled false
  44. debuggable true
  45. }
  46. release {
  47. minifyEnabled false
  48. }
  49. }
  50. flavorDimensions "model", "activity", "build"
  51. productFlavors {
  52. frcnnMnetv3 {
  53. dimension "model"
  54. applicationIdSuffix ".frcnnMnetv3"
  55. buildConfigField("String", "MODULE_ASSET_NAME", "\"frcnn_mnetv3.pt\"")
  56. addManifestPlaceholders([APP_NAME: "TV_FRCNN_MNETV3"])
  57. buildConfigField("String", "LOGCAT_TAG", "\"pytorch-frcnn-mnetv3\"")
  58. }
  59. camera {
  60. dimension "activity"
  61. addManifestPlaceholders([APP_NAME: "TV_CAMERA_FRCNN"])
  62. addManifestPlaceholders([MAIN_ACTIVITY: "org.pytorch.testapp.CameraActivity"])
  63. }
  64. base {
  65. dimension "activity"
  66. }
  67. aar {
  68. dimension "build"
  69. }
  70. local {
  71. dimension "build"
  72. }
  73. }
  74. packagingOptions {
  75. doNotStrip '**.so'
  76. pickFirst '**.so'
  77. }
  78. // Filtering for CI
  79. if (!testAppAllVariantsEnabled.toBoolean()) {
  80. variantFilter { variant ->
  81. def names = variant.flavors*.name
  82. if (names.contains("aar")) {
  83. setIgnore(true)
  84. }
  85. }
  86. }
  87. }
  88. tasks.all { task ->
  89. // Disable externalNativeBuild for all but nativeBuild variant
  90. if (task.name.startsWith('externalNativeBuild')
  91. && !task.name.contains('NativeBuild')) {
  92. task.enabled = false
  93. }
  94. }
  95. dependencies {
  96. implementation 'com.android.support:appcompat-v7:28.0.0'
  97. implementation 'com.facebook.soloader:nativeloader:0.8.0'
  98. localImplementation project(':ops')
  99. implementation "org.pytorch:pytorch_android:$pytorchAndroidVersion"
  100. implementation "org.pytorch:pytorch_android_torchvision:$pytorchAndroidVersion"
  101. aarImplementation(name: 'pytorch_android-release', ext: 'aar')
  102. aarImplementation(name: 'pytorch_android_torchvision-release', ext: 'aar')
  103. def camerax_version = "1.0.0-alpha05"
  104. implementation "androidx.camera:camera-core:$camerax_version"
  105. implementation "androidx.camera:camera-camera2:$camerax_version"
  106. implementation 'com.google.android.material:material:1.0.0-beta01'
  107. }
  108. task extractAARForNativeBuild {
  109. doLast {
  110. configurations.extractForNativeBuild.files.each {
  111. def file = it.absoluteFile
  112. copy {
  113. from zipTree(file)
  114. into "$buildDir/$file.name"
  115. include "headers/**"
  116. include "jni/**"
  117. }
  118. }
  119. }
  120. }
  121. tasks.whenTaskAdded { task ->
  122. if (task.name.contains('externalNativeBuild')) {
  123. task.dependsOn(extractAARForNativeBuild)
  124. }
  125. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...