Skip to content

Commit

Permalink
clean up & script for shader compilation & readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhylkaaa committed May 19, 2020
1 parent e2d6162 commit 2239650
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
15 changes: 15 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,28 @@ $ glslc -o dense.comp.spv dense.comp

To compile and run use:
```bash
$ chmod u+x compile_shaders.sh
$ ./compile_shaders.sh
$ mkdir build
$ cd build
$ cmake ..
$ make
$ ./vulkan_perceptron
```

## Quick reference

to define perceptron you need vector with output sizes of each layer (input size will be inferred from previous layer)
and vector of strings containing names of activations for each layer.
also you need to specify input size and batch size (**Note:** that for sake of simplicity you can use forward only with matrix of size `batch_size x input_size`)

Activation list:
- relu - Rectified linear unit
- id - identity (not a layer actually, it's just omitted)
- softmax - softmax function, not actually an activation function, but it's hear for sake of simplicity

You can refer to `line 10,11,12 of main.cpp` for usage example.

## TODOs
- Switch to using Tensor instead of VkBuffer
- Implement trainers for different tasks
Expand Down
9 changes: 9 additions & 0 deletions compile_shaders.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

SHADER_DIR=shaders

shader_list=$(ls $SHADER_DIR | grep -E '.*\.comp$')

for shader_name in $shader_list; do
glslc -o ${SHADER_DIR}/${shader_name}.spv ${SHADER_DIR}/${shader_name}
done
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

int main() {

std::vector<int> layers{10};
std::vector<std::string> activations{"softmax"};
std::vector<int> layers{512, 10};
std::vector<std::string> activations{"relu", "softmax"};
MLP mlp = MLP(784, 32, layers, activations);

mlp.forward_initialize();
Expand Down
Binary file removed shaders/dense.comp.spv
Binary file not shown.

0 comments on commit 2239650

Please sign in to comment.