Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ jobs:
build-linux:
strategy:
matrix:
build_type: [DEBUG, RELEASE]
include:
- build_type: DEBUG
- build_type: RELEASE
stats: false
- build_type: RELEASE
stats: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -34,7 +39,10 @@ jobs:
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DOPENCV_PATH=3rdparty/opencv/build
-DOPENCV_PATH=3rdparty/opencv/build \
${{ matrix.stats && '-DENABLE_STATISTIC_TENSORS=ON' || '' }} \
${{ matrix.stats && '-DENABLE_STATISTIC_TIME=ON' || '' }} \
${{ matrix.stats && '-DENABLE_STATISTIC_WEIGHTS=ON' || '' }}
cmake --build build --parallel
env:
CTEST_OUTPUT_ON_FAILURE: 1
Expand All @@ -48,7 +56,7 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: mnist-${{ matrix.build_type }}
name: mnist-${{ matrix.build_type }}${{ matrix.stats && '-stats' || '' }}
path: |
build/bin/ACC_MNIST*
build/bin/opencv_libs/*
Expand Down Expand Up @@ -83,7 +91,7 @@ jobs:
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
-DCMAKE_CXX_COMPILER=clang++
cmake --build build --parallel
- name: Test
run: cmake --build build -t test
Expand Down
4 changes: 4 additions & 0 deletions include/layers/ConcatLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class ConcatLayer : public Layer {

static std::string get_name() { return "ConcatLayer"; }

#ifdef ENABLE_STATISTIC_WEIGHTS
Tensor get_weights() override { return Tensor(); }
#endif

private:
int64_t axis_;

Expand Down
3 changes: 3 additions & 0 deletions include/layers/DropOutLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class DropOutLayer : public Layer {
DropOutLayer(double drop_rate) { drop_rate_ = drop_rate; }
static std::string get_name() { return "DropOut layer"; }
void run(const Tensor& input, Tensor& output) override;
#ifdef ENABLE_STATISTIC_WEIGHTS
Tensor get_weights() override { return Tensor(); }
#endif
};

} // namespace it_lab_ai
3 changes: 3 additions & 0 deletions include/layers/FlattenLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class FlattenLayer : public Layer {
FlattenLayer(const std::vector<size_t>& order) : order_(order) {}
static std::string get_name() { return "Flatten layer"; }
void run(const Tensor& input, Tensor& output) override;
#ifdef ENABLE_STATISTIC_WEIGHTS
Tensor get_weights() override { return Tensor(); }
#endif
};

template <typename ValueType>
Expand Down
4 changes: 4 additions & 0 deletions include/layers/ReduceLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class ReduceLayer : public Layer {

static std::string get_name() { return "ReduceLayer"; }

#ifdef ENABLE_STATISTIC_WEIGHTS
Tensor get_weights() override { return Tensor(); }
#endif

private:
Operation op_;
int64_t keepdims_;
Expand Down
29 changes: 20 additions & 9 deletions test/inference/test_inference.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <stdexcept>
#include <vector>

#include "graph/graph.hpp"
Expand Down Expand Up @@ -42,41 +43,46 @@ TEST(bfs, check_result_vec) {
std::vector<int> res = {81, 81, 81};
#ifdef ENABLE_STATISTIC_TENSORS
std::vector<Tensor> tensors = graph.getTensors();
for (int i = 0; i < tensors.size(); i++) {
for (size_t i = 0; i < tensors.size(); i++) {
std::vector<int> ten = *tensors[i].as<int>();
for (int j = 0; j < ten.size(); j++) {
for (size_t j = 0; j < ten.size(); j++) {
std::cout << ten[j] << ' ';
}
std::cout << '\n';
}
#endif
#ifdef ENABLE_STATISTIC_TIME
std::vector<std::string> times = graph.getTimeInfo();
for (int j = 0; j < times.size(); j++) {
for (size_t j = 0; j < times.size(); j++) {
std::cout << times[j] << ' ';
}
std::cout << '\n';
#endif
#ifdef ENABLE_STATISTIC_WEIGHTS
std::vector<Tensor> weights = graph.getWEIGHTS();
for (int i = 0; i < weights.size(); i++) {
for (size_t i = 0; i < weights.size(); i++) {
switch (weights[i].get_type()) {
case Type::kInt: {
std::vector<int> ten = *weights[i].as<int>();
for (int j = 0; j < ten.size(); j++) {
for (size_t j = 0; j < ten.size(); j++) {
std::cout << ten[j] << ' ';
}
std::cout << '\n';
break;
}
case Type::kFloat: {
std::vector<float> ten = *weights[i].as<float>();
for (int j = 0; j < ten.size(); j++) {
for (size_t j = 0; j < ten.size(); j++) {
std::cout << ten[j] << ' ';
}
std::cout << '\n';
break;
}
case Type::kUnknown:
default: {
throw std::runtime_error("Unknown tensor type encountered");
break;
}
}
}
#endif
Expand Down Expand Up @@ -112,24 +118,29 @@ TEST(bfs, check_end_to_end) {
graph.inference();
#ifdef ENABLE_STATISTIC_WEIGHTS
std::vector<Tensor> weights = graph.getWEIGHTS();
for (int i = 0; i < weights.size(); i++) {
for (size_t i = 0; i < weights.size(); i++) {
switch (weights[i].get_type()) {
case Type::kInt: {
std::vector<int> ten = *weights[i].as<int>();
for (int j = 0; j < ten.size(); j++) {
for (size_t j = 0; j < ten.size(); j++) {
std::cout << ten[j] << ' ';
}
std::cout << '\n';
break;
}
case Type::kFloat: {
std::vector<float> ten = *weights[i].as<float>();
for (int j = 0; j < ten.size(); j++) {
for (size_t j = 0; j < ten.size(); j++) {
std::cout << ten[j] << ' ';
}
std::cout << '\n';
break;
}
case Type::kUnknown:
default: {
throw std::runtime_error("Unknown tensor type encountered");
break;
}
}
}
#endif
Expand Down
Loading