Skip to content
Snippets Groups Projects
Commit 9dcc3f20 authored by Noam Zerah's avatar Noam Zerah
Browse files

Rebasing with latest MR on dev

parents e144d3be 89f78f40
No related branches found
No related tags found
2 merge requests!24Adding MulCompensation Nodes to the PTQ pipeline,!22Refactor: removing scaling nodes
Checking pipeline status
......@@ -20,11 +20,11 @@ include:
- '.gitlab/ci/ubuntu_python.gitlab-ci.yml'
- '.gitlab/ci/release/cibuildwheel_ubuntu.gitlab-ci.yml'
# - '.gitlab/ci/windows_cpp.gitlab-ci.yml'
- '.gitlab/ci/windows_cpp.gitlab-ci.yml'
- '.gitlab/ci/windows_python.gitlab-ci.yml'
- '.gitlab/ci/release/cibuildwheel_windows.gitlab-ci.yml'
# - '.gitlab/ci/windows_python.gitlab-ci.yml'
# - '.gitlab/ci/release/cibuildwheel_windows.gitlab-ci.yml'
test:ubuntu_python:
......@@ -49,28 +49,28 @@ coverage:ubuntu_python:
release:pip:ubuntu:
before_script:
- !reference [.retrieve_deps:apt, script]
- DEPS_NAMES=("aidge_core" "aidge_backend_cpu" "aidge_onnx")
- DEPS_NAMES=("aidge_core" "aidge_backend_cpu" "aidge_backend_cuda" "aidge_onnx")
- DEPENDENCY_JOB="build:ubuntu_python"
- !reference [.ubuntu:download:repositories, script] # located in common.gitlab-ci.yml
- curl -sSL https://get.docker.com/ | sh
release:pip:windows:
before_script:
- (Get-WmiObject -Class Win32_OperatingSystem).OSArchitecture
- (Get-WmiObject -Class Win32_OperatingSystem).Caption
- $PSVersionTable.PSVersion
# Install Chocolatey
- Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install dependencies
- choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' -Y
- choco install git -Y
- choco install python --version=$python_version -Y
# Update PATH
- $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
- python -m pip install cibuildwheel==2.17.0
# Download repositories
- $DEPS_NAMES = "aidge_core","aidge_backend_cpu","aidge_onnx"
- $DEPENDENCY_JOB="build:windows_python"
- !reference [.windows:download:repositories, script]
# release:pip:windows:
# before_script:
# - (Get-WmiObject -Class Win32_OperatingSystem).OSArchitecture
# - (Get-WmiObject -Class Win32_OperatingSystem).Caption
# - $PSVersionTable.PSVersion
# # Install Chocolatey
# - Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# # Install dependencies
# - choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' -Y
# - choco install git -Y
# - choco install python --version=$python_version -Y
# # Update PATH
# - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# - python -m pip install cibuildwheel==2.17.0
# # Download repositories
# - $DEPS_NAMES = "aidge_core","aidge_backend_cpu","aidge_backend_cuda","aidge_onnx"
# - $DEPENDENCY_JOB="build:windows_python"
# - !reference [.windows:download:repositories, script]
# CMake >= 3.18 is required for good support of FindCUDAToolkit
cmake_minimum_required(VERSION 3.18) # XXX 3.18
set(CXX_STANDARD 14)
file(READ "${CMAKE_SOURCE_DIR}/version.txt" version)
file(READ "${CMAKE_SOURCE_DIR}/project_name.txt" project)
......@@ -25,6 +26,7 @@ option(WERROR "Warning as error" OFF)
option(TEST "Enable tests" ON)
option(COVERAGE "Enable coverage" OFF)
option(CUDA "Enable CUDA backend" ON) # XXX OFF
option(ENABLE_ASAN "Enable ASan (AddressSanitizer) for runtime analysis of memory use (over/underflow, memory leak, ...)" OFF)
##############################################
# Import utils CMakeLists
......@@ -43,6 +45,14 @@ if(CUDA)
add_definitions(-DCUDA_COMPILER_VERSION="${CMAKE_CUDA_COMPILER_VERSION}")
endif()
if(NOT $ENV{AIDGE_INSTALL} STREQUAL "")
set(CMAKE_INSTALL_PREFIX $ENV{AIDGE_INSTALL})
list(APPEND CMAKE_PREFIX_PATH $ENV{AIDGE_INSTALL})
message(WARNING "Env var AIDGE_INSTALL detected : $ENV{AIDGE_INSTALL}. Set CMAKE_INSTALL_PREFIX to AIDGE_INSTALL & added to CMAKE_PREFIX_PATH"
"\n\tCMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}"
"\n\tCMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}")
endif()
# ##############################################
# Find system dependencies
Include(FetchContent)
......
......@@ -18,7 +18,6 @@
#include "aidge/quantization/PTQ/CLE.hpp"
#include "aidge/quantization/PTQ/PTQ.hpp"
#include "aidge/hook/Hook.hpp"
#include "aidge/graph/GraphView.hpp"
namespace py = pybind11;
......@@ -94,7 +93,7 @@ void init_PTQ(py::module &m) {
:type verbose: bool
)mydelimiter");
m.def("quantize_network", &quantizeNetwork ,py::arg("network"), py::arg("nb_bits"), py::arg("input_dataset"), py::arg("clipping_mode") = Clipping::MAX , py::arg("apply_rounding") = true, py::arg("optimize_signs") = false, py::arg("single_shift") = false, py::arg("use_cuda"), py::arg("verbose") = false,
m.def("quantize_network", &quantizeNetwork ,py::arg("network"), py::arg("nb_bits"), py::arg("input_dataset"), py::arg("clipping_mode") = Clipping::MAX , py::arg("no_quantization") = true, py::arg("optimize_signs") = false, py::arg("single_shift") = false, py::arg("use_cuda") = false, py::arg("verbose") = false,
R"mydelimiter(
Main quantization routine. Performs every step of the quantization pipeline.
:param network: The GraphView to be quantized.
......
......@@ -13,7 +13,6 @@
#include <pybind11/stl.h>
#include "aidge/quantization/QAT/QAT_FixedQ.hpp"
#include "aidge/hook/Hook.hpp"
#include "aidge/graph/GraphView.hpp"
namespace py = pybind11;
......
......@@ -13,7 +13,6 @@
#include <pybind11/stl.h>
#include "aidge/quantization/QAT/QAT_LSQ.hpp"
#include "aidge/hook/Hook.hpp"
#include "aidge/graph/GraphView.hpp"
namespace py = pybind11;
......
......@@ -13,7 +13,7 @@
#include <pybind11/stl.h>
#include "aidge/recipes/QuantRecipes.hpp"
#include "aidge/hook/Hook.hpp"
//#include "aidge/hook/Hook.hpp"
#include "aidge/graph/GraphView.hpp"
namespace py = pybind11;
......
......@@ -88,11 +88,19 @@ void QuantLSQ::insertQuantizers(std::shared_ptr<GraphView> graphView, size_t nbB
static float getTensorAbsMean(std::shared_ptr<Tensor> tensor)
{
auto backend = tensor->backend();
if (backend == "cuda")
tensor->setBackend("cpu");
float acc = 0;
float* castedTensor = static_cast<float *> (tensor->getImpl()->rawPtr());
for(std::size_t i = 0; i < tensor->size(); i++)
acc += std::abs(castedTensor[i]);
acc /= static_cast<float> (tensor->size());
if (backend == "cuda")
tensor->setBackend("cuda");
return acc;
}
......@@ -107,7 +115,7 @@ static std::map<std::string, float> collectInputStats(std::shared_ptr<GraphView>
// Store the input tensor statistics
if (useCuda)
graphView->setBackend("cpu");
graphView->setBackend("cpu");
std::map<std::string, float> inputStats;
for (auto node : graphView->getNodes())
......@@ -192,6 +200,7 @@ void QuantLSQ::insertAndInitQuantizers(std::shared_ptr<GraphView> graphView, siz
// Collect the tensor statisics
auto inputStats = collectInputStats(graphView, calibrationData, useCuda);
auto paramStats = collectParamStats(graphView, useCuda);
// Insert the quantizers
......
......@@ -62,7 +62,7 @@ void insertBatchNormNodes(std::shared_ptr<GraphView> graphView)
std::cout << " NB CHANNELS = " << nb_channels << std::endl; // TODO : remove this ...
std::string batchnormNodeName = makeUniqueName(parentNode->name() + "_BN", graphView);
std::shared_ptr<Node> batchnormNode = BatchNorm<2>(nb_channels, 1e-5, 0.1, /*0,*/ batchnormNodeName);
std::shared_ptr<Node> batchnormNode = BatchNorm<2>(nb_channels, 1e-5, 0.1, batchnormNodeName);
batchnormNode->getOperator()->setDataType(DataType::Float32);
batchnormNode->getOperator()->setBackend("cpu");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment