Skip to content

Commit 04079f4

Browse files
committed
update readme
1 parent cfc85d1 commit 04079f4

File tree

1 file changed

+101
-39
lines changed

1 file changed

+101
-39
lines changed

README.md

Lines changed: 101 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<div align=center><img src="picture/image-20200418210521131.png" alt="image-20200418210521131" /></div>
2+
3+
14
# Edge-Computing-Engine
25

36
An open-source scientific computing engine designed for matrix computation and machine learning tasks, with CUDA acceleration support.
@@ -7,7 +10,7 @@ An open-source scientific computing engine designed for matrix computation and m
710
[![Edge passing](https://img.shields.io/badge/Edge--CI-passing-blue)](https://github.com/AllenZYJ/Edge-Computing-Engine/actions)
811
[![GitHub license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://raw.githubusercontent.com/tesseract-ocr/tesseract/master/LICENSE)
912

10-
## Overview
13+
# Overview
1114

1215
Edge-Computing-Engine provides a flexible computational graph implementation that supports:
1316

@@ -17,9 +20,9 @@ Edge-Computing-Engine provides a flexible computational graph implementation tha
1720

1821
The computational graph is built using nodes representing operations such as matrix multiplication, element-wise operations, and activation functions.
1922

20-
## GPU Features
23+
# 1. GPU Features
2124

22-
### Operation Types
25+
### 1.1 Operation Types
2326

2427
The framework supports the following operations:
2528

@@ -34,13 +37,13 @@ The framework supports the following operations:
3437
- **OP_TANH**: Tanh activation function (declared but not implemented)
3538
- **OP_SOFTMAX**: Softmax function (declared but not implemented)
3639

37-
### Core Classes
40+
### 1.2 Core Classes
3841

3942
1. **Matrix_CU**: A custom matrix class with CUDA support
4043
2. **ComputeNode**: Represents a node in the computational graph
4144
3. **ComputeGraph**: Manages the graph, including node creation, forward and backward propagation
4245

43-
### CUDA Kernels
46+
### 1.3 CUDA Kernels
4447

4548
The code includes several CUDA kernel functions:
4649

@@ -51,27 +54,8 @@ The code includes several CUDA kernel functions:
5154
- **divBackwardKernel**: Backward propagation for element-wise division
5255
- **negGradKernel**: Helper kernel for computing negative gradients
5356

54-
## CPU Features
55-
56-
- `read_csv(string &file_path)`: Reads a formatted file (csv) and returns a matrix with automatically calculated dimensions
57-
- Formatted file writing interface (similar to `pandas.to_csv`)
58-
- Broadcasting mechanism for matrices with padding interface
59-
- Fully connected layer forward and backward propagation interfaces with automatic differentiation support
60-
- Matrix differentiation and automatic differentiation interfaces
61-
- Various matrix operations:
62-
- `create(row,cols)`: Creates a matrix with specified dimensions
63-
- `add`, `subtract`, `mul`: Basic matrix operations
64-
- `get_T`: Matrix transposition
65-
- `flatten`: Returns a flattened array
66-
- `matrix_rs`: Matrix structure compression
67-
- `matrix_sum`, `matrix_mean`: Statistical operations
68-
- `iloc`: Matrix slicing
69-
- And many more
70-
- Activation functions (Relu)
71-
- Loss functions (MSE)
72-
- Neural network components (convolutional layers, pooling layers)
7357

74-
## Usage Example
58+
### 1.4 CUDA Example
7559

7660
```cpp
7761
// Create a computational graph
@@ -95,14 +79,85 @@ graph.forward();
9579
// Compute gradients via backward propagation
9680
graph.backward(output_node);
9781
```
82+
### 1.5 GPU_Usage
83+
84+
```shell
85+
root@5353:/backup# nvcc -arch=sm_80 -I/usr/local/cuda/include -L/usr/local/cuda/lib64 cuda_mat/mat_grad.cu -o main && ./main
86+
root@5353:/backup# ./main
87+
====== Configuration ======
88+
Input matrix: 10000 x 1000
89+
Weight matrix: 1000 x 500
90+
Batch size: 32
91+
Activation: ReLU
92+
93+
====== CUDA Results ======
94+
Input first 5x5:
95+
0.840188 0.394383 0.783099 0.79844 0.911647
96+
0.45724 0.640368 0.717092 0.460067 0.54114
97+
0.0860517 0.180886 0.426423 0.0470658 0.306902
98+
0.0587587 0.0138811 0.622212 0.0391351 0.221551
99+
0.456151 0.24875 0.0699601 0.742097 0.216935
100+
Weight first 5x5:
101+
0.817311 0.0247108 0.0146763 0.939293 0.502699
102+
0.604392 0.921644 0.675689 0.948712 0.58803
103+
0.824073 0.747934 0.0448163 0.757354 0.858343
104+
0.308744 0.659798 0.941692 0.255731 0.539655
105+
0.89383 0.609149 0.799556 0.726306 0.640965
106+
Output first 5x5:
107+
256.076 253.23 258.393 259.965 255.971
108+
250.843 246.827 252.131 253.493 244.151
109+
247.064 244.543 251.723 247.424 250.466
110+
249.944 250.359 256.148 252.21 249.615
111+
246.675 238.295 252.572 242.94 243.512
112+
Input gradient first 5x5:
113+
244.628 251.341 255.388 250.4 249.891
114+
244.628 251.341 255.388 250.4 249.891
115+
244.628 251.341 255.388 250.4 249.891
116+
244.628 251.341 255.388 250.4 249.891
117+
244.628 251.341 255.388 250.4 249.891
118+
Weight gradient first 5x5:
119+
159791 159791 159791 159791 159791
120+
160010 160010 160010 160010 160010
121+
160266 160266 160266 160266 160266
122+
159899 159899 159899 159899 159899
123+
159964 159964 159964 159964 159964
124+
125+
====== Performance ======
126+
CUDA computation time: 2201.45 ms
127+
```
98128

99-
## Requirements
129+
### 1.6 Requirements
100130

101131
- CUDA-capable NVIDIA GPU (for GPU features)
102132
- CUDA Toolkit
103133
- C++11 or above
134+
- nvcc: NVIDIA (R) Cuda compiler driver
135+
Copyright (c) 2005-2024 NVIDIA Corporation
136+
Built on Thu_Mar_28_02:18:24_PDT_2024
137+
Cuda compilation tools, release 12.4, V12.4.131
138+
Build cuda_12.4.r12.4/compiler.34097967_0
139+
140+
141+
# 2. CPU Features
104142

105-
## Installation
143+
- `read_csv(string &file_path)`: Reads a formatted file (csv) and returns a matrix with automatically calculated dimensions
144+
- Formatted file writing interface (similar to `pandas.to_csv`)
145+
- Broadcasting mechanism for matrices with padding interface
146+
- Fully connected layer forward and backward propagation interfaces with automatic differentiation support
147+
- Matrix differentiation and automatic differentiation interfaces
148+
- Various matrix operations:
149+
- `create(row,cols)`: Creates a matrix with specified dimensions
150+
- `add`, `subtract`, `mul`: Basic matrix operations
151+
- `get_T`: Matrix transposition
152+
- `flatten`: Returns a flattened array
153+
- `matrix_rs`: Matrix structure compression
154+
- `matrix_sum`, `matrix_mean`: Statistical operations
155+
- `iloc`: Matrix slicing
156+
- And many more
157+
- Activation functions (Relu)
158+
- Loss functions (MSE)
159+
- Neural network components (convolutional layers, pooling layers)
160+
### 2.1 CPU_autodiff_Installation
106161

107162
```shell
108163
git clone git@github.com:AllenZYJ/Edge-Computing-Engine.git
@@ -111,21 +166,28 @@ cd Edge-Computing-Engine/install_diff && make && make install
111166

112167
Note: If you're not a root user, you may need to add sudo to the make install command.
113168

114-
## Usage
169+
### 2.2 CPU_Usage
115170

116171
```shell
117-
g++ main.cpp -o main -lautodiff
118-
./main
172+
root@5353:/backup# .g++ main.cpp -o main -lautodiff
173+
root@5353:/backup# ./main
174+
0.000000+-0.000378*1.000000
175+
-0.000378+0.000000*1.000000
176+
....
177+
-0.000378+0.000000*1.000000
178+
0.000000+-0.000378*1.000000
179+
-0.000378+0.000000*1.000000
180+
-0.000378+0.000000*1.000000
181+
weight_1_grad:
182+
[
183+
-0.000378 -0.000378 -0.000378
184+
-0.000378 -0.000378 -0.000378
185+
-0.000378 -0.000378 -0.000378
186+
]
187+
neraul end;
119188
```
120189

121-
## Performance
122-
123-
The code includes an optional CPU verification step that:
124-
1. Computes the same operations on CPU
125-
2. Compares the results between CUDA and CPU implementations
126-
3. Measures the performance difference between GPU and CPU execution
127-
128-
## Contributing
190+
# 3. Contributing
129191

130192
Contributions are welcome. To contribute:
131193

@@ -148,4 +210,4 @@ Please ensure your code adheres to the existing style and passes tests before su
148210

149211
## License
150212

151-
Edge-Computing-Engine is released under the Apache 2.0 License. See the `LICENSE` file for details.
213+
Edge-Computing-Engine is released under the Apache 2.0 License. See the [`LICENSE`](https://www.apache.org/licenses/LICENSE-2.0) file for details.

0 commit comments

Comments
 (0)