• Home
Name Date Size #Lines LOC

..--

.gitignoreD12-May-202410 21

CMakeLists.txtD12-May-2024859 3427

README.mdD12-May-20242.6 KiB7146

associations.txtD12-May-202411.7 KiB11

build_lib.pyD12-May-20246.1 KiB157101

crop.shD12-May-20244.8 KiB188139

cropper_configure.pyD12-May-202413.8 KiB395278

dependencies.txtD12-May-20241.1 MiB11

parser.pyD12-May-20242.5 KiB8554

README.md

1
2# Objective
3
4The goal of this tool is to allow the user to reduce the size of MindData lite package they ship with their code.
5
6# How to run
7
8This tool has two parts: the first part only needs to be run once, when the source code for mindspore is changed
9while the second part should be run every time the user code changes.
10
11Note that you need to run this tool on the server side if you are planning to use your code on an edge device.
12
13## Step 1: Configure the cropper tool
14
15You need to have mindspore installed on your system to run this python script.
16Additionally, you need to have the mindspore source code present in your system
17as this script processes mindspore's source code.
18
19To execute the first part simply run:
20
21```console
22python cropper_configure.py
23```
24
25## Step 2: Crop the MindData lite package
26
27The second part needs to be run every time the user adds or removes one of MD operators in their code.
28
29For the second part, you need to run:
30
31```console
32./crop.sh -p <path to mindspore package> <source files>
33```
34
35Note that you need to provide the name of all files that are using any of the MindData functionalities.
36
37`ANDROID_NDK` environment variable needs to be set as well if the target device is android.
38
39Example: `./crop.sh -p ~/mindspore/ foo.cc foo.h bar.cc bar.h`
40
41This code will create the __libminddata-lite_min.so__ library specific to your code and will also print for you a list of
42shared objects that your code depends on (including __libminddata-lite\_min.so__).
43Note that you need to copy these files to your target device and set the linker flag accordingly.
44
45# How it works
46
47The first step (configuration) creates a few of files that are needed in the second step.
48These files include _dependencies.txt_, _associations.txt_, and _debug.txt_.
49While the third file (_debug.txt_) is only for debugging purposes (debugging cropper tool),
50the other two files are used in the second part.
51_associations.txt_ contains the entry points (IR level source files) for ops that the user may use in their code.
52The other file, _dependencies.txt_, contains all dependencies for all those entry points.
53
54When the user runs the crop script, _parser.py_ will be run on their code to find the ops they have used.
55Afterwards, the text files will be used to keep the needed object files
56(by removing unnecessary object files from the static library containing all of them).
57Finally, the remaining object files will be used to create a new shared object file (_libminddata-lite\_min.so_).
58
59# Requirements
60
61Step 1:
62
63* Python3
64* mindspore
65* mindspore source code
66
67Step 2:
68
69* Python3
70* cmake
71* Android NDK (if target device is android)