Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tvm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cld
ml
tvm
Commits
7d5d9ec9
Commit
7d5d9ec9
authored
7 years ago
by
ziheng
Committed by
Tianqi Chen
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[iOS] Better RPC guide and bug fix (#357)
parent
422bf824
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/ios_rpc/README.md
+15
-7
15 additions, 7 deletions
apps/ios_rpc/README.md
apps/ios_rpc/init_proj.py
+30
-0
30 additions, 0 deletions
apps/ios_rpc/init_proj.py
src/runtime/metal/metal_device_api.mm
+1
-1
1 addition, 1 deletion
src/runtime/metal/metal_device_api.mm
with
46 additions
and
8 deletions
apps/ios_rpc/README.md
+
15
−
7
View file @
7d5d9ec9
...
...
@@ -4,20 +4,29 @@ This folder contains iOS RPC app that allows us to launch an rpc server on a iOS
and connect to it through python script and do testing on the python side as normal TVM RPC.
You will need XCode and an iOS device to use this.
## Building
Before start, please run
```init_proj.py```
to update XCode developer metadata. After this step, open
```
tvmrpc.xcodeproj``` by using XCode, build the App and install the App on the phone. Usually, we
**do not** use the iOS App directly.
## Workflow
Due to security restriction of iOS10. We cannot upload dynamic libraries to the App and load it from sandbox.
Instead, we need to build a list of libraries, pack them into the app bundle, launch the RPC server and
connect to test the bundled libraries. We use ```xcodebuild test``` to automate this process.
See
[
tests/ios_rpc_test.py
](
tests/ios_rpc_test.py
)
for an example.
## Environment Variables
To use the utilities, you need to configure the following environment variables
The test script [tests/ios_rpc_test.py](tests/ios_rpc_test.py) is a good template for the workflow. With this
script, we don't need to manually operate the iOS App, this script will build the app, run it and collect the results automatically.
To run the script, you need to configure the following environment variables
-
```TVM_IOS_CODESIGN```
The signature you use to codesign the app and libraries(e.g.
```iPhone Developer: Name (XXXX)```
)
- ```TVM_IOS_CODESIGN``` The signature you use to codesign the app and libraries
(e.g. ```iPhone Developer: Name (XXXX)```)
- ```TVM_IOS_RPC_ROOT``` The root directory of the iOS rpc project
- ```TVM_IOS_RPC_PROXY_HOST``` The RPC proxy address
- ```TVM_IOS_RPC_DESTINATION``` The Xcode target device(e.g. ```platform=iOS,name=xxxx```)
##
Launch RPC from XCode IDE
Let us
first
explain how it works, the project look for
```rpc_config.txt```
file in the project root folder.
##
How it works
Let us explain how it works, the project look for ```rpc_config.txt``` file in the project root folder.
The ```rpc_config.txt``` file should be in the following format:
```
<url>
<port>
<key>
...
...
@@ -35,6 +44,5 @@ and connect to the specified RPC proxy, start serving loop.
So if we want to start the RPC from XCode IDE, simply manually modify ```rpc_config.txt``` file and click test.
Then connect to the proxy via the python script.
## Use RPC via App
We can also use the RPC App directly, by typing in the address and press connect to connect to the proxy.
However, the restriction is we can only load the modules that are bundled to the App.
This diff is collapsed.
Click to expand it.
apps/ios_rpc/init_proj.py
0 → 100644
+
30
−
0
View file @
7d5d9ec9
import
argparse
import
re
parser
=
argparse
.
ArgumentParser
(
description
=
'
Update tvmrpc.xcodeproj
\
developer information
'
)
parser
.
add_argument
(
'
--org_unit
'
,
type
=
str
,
required
=
True
,
help
=
'
Your own Organization Unit.
\n\
The Organization Unit can be found by following:
\n\
1. Open Keychain Access.
\n\
2. Find out your own iPhone Developer certificate.
\n\
3. Right click certificate, choose ```Get Info```.
\n\
4. Read & copy your Organization Unit.
'
)
parser
.
add_argument
(
'
--bundle_identifier
'
,
type
=
str
,
required
=
False
,
default
=
"
tvmrpc
"
,
help
=
'
The new bundle identifier
'
)
args
=
parser
.
parse_args
()
org_unit
=
args
.
org_unit
bundle_identifier
=
args
.
bundle_identifier
fi
=
open
(
"
tvmrpc.xcodeproj/project.pbxproj
"
)
proj_config
=
fi
.
read
()
fi
.
close
()
proj_config
=
proj_config
.
replace
(
"
3FR42MXLK9
"
,
org_unit
)
proj_config
=
proj_config
.
replace
(
"
ml.dmlc.tvmrpc
"
,
bundle_identifier
)
fo
=
open
(
"
tvmrpc.xcodeproj/project.pbxproj
"
,
"
w
"
)
fo
.
write
(
proj_config
)
fo
.
close
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/runtime/metal/metal_device_api.mm
+
1
−
1
View file @
7d5d9ec9
...
...
@@ -191,7 +191,7 @@ void MetalWorkspace::CopyDataFromTo(const void* from,
}
}
else
if
(
from_dev_type
==
kCPU
&&
to_dev_type
==
kMetal
)
{
id
<
MTLBuffer
>
to_buf
=
(
__bridge
id
<
MTLBuffer
>
)(
to
);
if
(
to_buf
.
storageMode
=
=
MTLStorageModeShared
)
{
if
(
to_buf
.
storageMode
!
=
MTLStorageModeShared
)
{
id
<
MTLBuffer
>
temp
=
MetalThreadEntry
::
ThreadLocal
()
->
GetTempBuffer
(
ctx_to
,
size
);
memcpy
([
temp
contents
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment