Skip to content

Commit e7acb44

Browse files
committed
Update readme for better instructions.
1 parent fd6ed8c commit e7acb44

2 files changed

Lines changed: 102 additions & 1 deletion

File tree

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,88 @@ Note: To change the maximum `rank` of `staticTensor(rank,eltType)`, you can spec
9999
```bash
100100
$ chpl -M <ChAI>/lib -sEnv.maxNeededRank=15 my_program.chpl
101101
```
102+
103+
104+
105+
# Current Status
106+
107+
Currently, you need to have a working installation of CMake, PyThon, and Chapel to use ChAI.
108+
109+
## General build instructions
110+
111+
After cloning,
112+
```bash
113+
$ git clone https://github.com/chapel-lang/ChAI.git
114+
$ cd ChAI
115+
```
116+
117+
use CMake to build the project.
118+
119+
```bash
120+
$ mkdir build
121+
$ cd build
122+
$ cmake -DCMAKE_BUILD_TYPE=Release ..
123+
```
124+
125+
This will create a `build` directory and run CMake to generate the necessary build files.
126+
127+
To test if the build environment is working, you can run the following command:
128+
```bash
129+
$ make MyExample && make TorchTestBridge
130+
131+
$ ./MyExample
132+
Hello, world!
133+
a: ndarray([[ 0, 1, 2],
134+
[ 3, 4, 5],
135+
[ 6, 7, 8]],
136+
shape = (3, 3),
137+
rank = 2)
138+
139+
b: ndarray([[ 0, 1, 2],
140+
[ 3, 4, 5],
141+
[ 6, 7, 8]],
142+
shape = (3, 3),
143+
rank = 2)
144+
145+
c: ndarray([[15, 18, 21],
146+
[42, 54, 66],
147+
[69, 90, 111]],
148+
shape = (3, 3),
149+
rank = 2)
150+
151+
$ ./TorchTestBridge
152+
Input: [1, 3, 10, 10]
153+
Output: [1, 3, 10, 10]
154+
155+
```
156+
157+
The first command will compile the `MyExample` program, which is a simple "Hello, world!" program that uses ChAI. The second command will compile the `TorchTestBridge` program, which tests the PyTorch interop functionality of ChAI.
158+
159+
See `docker-dev-run.md` for instructions on how to run the examples in a Docker container. This is useful if either of these build steps fail on your system.
160+
161+
162+
You may also try
163+
```bash
164+
$ cd examples/vgg
165+
$ python3 dump_weights.py
166+
$ cd ../..
167+
$ make vgg
168+
$ ./vgg images/frog.jpg
169+
VGG Example Directory: .../ChAI/examples/vgg
170+
Loading labels from .../ChAI/examples/vgg/imagenet/LOC_synset_mapping.txt
171+
Loaded 1000 labels.
172+
Constructing VGG16 model.
173+
Constructed VGG16 model.
174+
Loading VGG16 model weights.
175+
Loaded VGG16 model.
176+
Read file: .../ChAI/build/images/frog.jpg with ext: jpg
177+
imageData shape: (3, 720, 1280)
178+
normalizedImageData shape: (3, 720, 1280)
179+
inputImage shape: (size = 3, sizes = 3 720 1280)
180+
For 'images/frog.jpg' the top 5 predictions are:
181+
0: label=tree frog, tree-frog; confidence=27%
182+
1: label=tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui; confidence=8.2%
183+
2: label=leafhopper; confidence=4.5%
184+
3: label=leaf beetle, chrysomelid; confidence=1.9%
185+
4: label=weevil; confidence=1.5%
186+
```

docker-dev-run.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,23 @@ root@chai-vm:/app/demos/torchtest/build# ./MyProject
2929
Input: [1, 3, 10, 10]
3030
Output: [1, 3, 10, 10]
3131
```
32-
32+
OR
33+
```bash
34+
root@chai-vm:/app# cd build
35+
root@chai-vm:/app/build# cmake -DCMAKE_BUILD_TYPE=Release ..
36+
root@chai-vm:/app/build# make -j2
37+
root@chai-vm:/app/build# ./MyExample
38+
...
39+
root@chai-vm:/app/build# ./examples/torch_model_loading/TorchLoad images/dog.jpg
40+
Read file: /app/build/images/dog.jpg with ext: jpg
41+
Resized image: (3, 224, 224)
42+
Read file: /app/build/images/dog.jpg with ext: jpg
43+
Batched image: (1, 3, 734, 1100)
44+
Batched image resized: (1, 3, 734, 1100)
45+
Squeezed image: (3, 734, 1100)
46+
root@chai-vm:/app/build# ./vgg images/frog.jpg
47+
# no pytorch installed, and no weights preprocessed.
48+
```
3349

3450

3551

0 commit comments

Comments
 (0)