Skip to content
Snippets Groups Projects
Commit d199897e authored by Maxence Naud's avatar Maxence Naud
Browse files

Merge branch 'upd_version_0-3-0' into 'dev'

Upd version 0.3.0

See merge request eclipse/aidge/aidge_quantization!29
parents 4a52be5d 192bcf0f
No related branches found
No related tags found
2 merge requests!29Upd version 0.3.0,!28v0.3.0
Pipeline #61973 failed
......@@ -8,7 +8,7 @@ file(READ "${CMAKE_SOURCE_DIR}/project_name.txt" project)
message(STATUS "Project name: ${project}")
message(STATUS "Project version: ${version}")
# Note : project name is {project} and python module name is also {project}
# Note : project name is {project} and python module name is also {project}
set(module_name _${project}) # target name
project(${project})
......@@ -180,8 +180,8 @@ install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT ${project}-targets
FILE "${project}-targets.cmake"
DESTINATION ${INSTALL_CONFIGDIR}
COMPONENT ${module_name}
)
COMPONENT ${module_name}
)
#Create a ConfigVersion.cmake file
include(CMakePackageConfigHelpers)
......
......@@ -31,7 +31,7 @@ void init_PTQ(py::module &m) {
.value("AA" , Clipping::AA)
.value("KL" , Clipping::KL);
m.def("check_architecture", &checkArchitecture, py::arg("network"),
m.def("check_architecture", &checkArchitecture, py::arg("network"),
R"mydelimiter(
Determine whether an input GraphView can be quantized or not.
:param network: The GraphView to be checked.
......@@ -40,15 +40,15 @@ void init_PTQ(py::module &m) {
:rtype: bool
)mydelimiter");
m.def("insert_scaling_nodes", &insertScalingNodes, py::arg("network"),
m.def("insert_scaling_nodes", &insertScalingNodes, py::arg("network"),
R"mydelimiter(
Insert a scaling node after each affine node of the GraphView.
Insert a scaling node after each affine node of the GraphView.
Also insert a scaling node in every purely residual branches.
:param network: The GraphView containing the affine nodes.
:type network: :py:class:`aidge_core.GraphView`
)mydelimiter");
m.def("normalize_parameters", &normalizeParameters, py::arg("network"),
m.def("normalize_parameters", &normalizeParameters, py::arg("network"),
R"mydelimiter(
Normalize the parameters of each parametrized node, so that they fit in the [-1:1] range.
:param network: The GraphView containing the parametrized nodes.
......@@ -69,17 +69,17 @@ void init_PTQ(py::module &m) {
)mydelimiter");
m.def("normalize_activations", &normalizeActivations, py::arg("network"), py::arg("value_ranges"),
R"mydelimiter(
R"mydelimiter(
Normalize the activations of each affine node so that they fit in the [-1:1] range.
This is done by reconfiguring the scaling nodes, as well as rescaling the weights and biases tensors.
:param network: The GraphView containing the affine nodes.
:type network: :py:class:`aidge_core.GraphView`
:param value_ranges: The node output value ranges computed over the calibration dataset.
:param value_ranges: The node output value ranges computed over the calibration dataset.
:type value_ranges: list of float.
)mydelimiter");
m.def("quantize_normalized_network", &quantizeNormalizedNetwork, py::arg("network"), py::arg("nb_bits"), py::arg("no_quant")=false, py::arg("optimize_signs"), py::arg("verbose") = false,
R"mydelimiter(
R"mydelimiter(
Quantize an already normalized (in term of parameters and activations) network.
:param network: The GraphView to be quantized.
:type network: :py:class:`aidge_core.GraphView`
......@@ -94,13 +94,13 @@ void init_PTQ(py::module &m) {
)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("no_quantization") = true, py::arg("optimize_signs") = false, py::arg("single_shift") = false, py::arg("use_cuda") = false, py::arg("verbose") = false,
R"mydelimiter(
R"mydelimiter(
Main quantization routine. Performs every step of the quantization pipeline.
:param network: The GraphView to be quantized.
:type network: :py:class:`aidge_core.GraphView`
:param nb_bits: The desired number of bits of the quantization.
:type nb_bits: int
:param input_dataset: The input dataset on which the value ranges are computed.
:param input_dataset: The input dataset on which the value ranges are computed.
:type input_dataset: list of :py:class:`aidge_core.Tensor`
:param clipping_mode: Type of the clipping optimization. Can be either 'MAX', 'MSE', 'AA' or 'KL'.
:type clipping_mode: string
......@@ -108,7 +108,7 @@ void init_PTQ(py::module &m) {
:type no_quantization: bool
:param optimize_signs: Whether to take account of the IO signs of the operators or not.
:type optimize_signs: bool
:param single_shift: Whether to convert the scaling factors into powers of two. If true the approximations are compensated using the previous nodes weights.
:param single_shift: Whether to convert the scaling factors into powers of two. If true the approximations are compensated using the previous nodes weights.
:type single_shift: bool
:param verbose: Whether to print internal informations about the quantization process.
:type verbose: bool
......@@ -155,9 +155,9 @@ void init_PTQ(py::module &m) {
m.def("adjust_ranges", &adjustRanges, py::arg("clipping_mode"), py::arg("value_ranges"), py::arg("nb_bits"), py::arg("network"), py::arg("input_dataset"), py::arg("use_cuda"), py::arg("verbose") = false,
R"mydelimiter(
Return a corrected map of the provided activation ranges.
To do so compute the optimal clipping values for every node and multiply the input ranges by those values.
The method used to compute the clippings can be eihter 'MSE', 'AA', 'KL' or 'MAX'.
Return a corrected map of the provided activation ranges.
To do so compute the optimal clipping values for every node and multiply the input ranges by those values.
The method used to compute the clippings can be eihter 'MSE', 'AA', 'KL' or 'MAX'.
:param clipping_mode: The method used to compute the optimal clippings.
:type clipping_mode: enum
:param value_ranges: The map associating each affine node to its output range.
......@@ -177,28 +177,28 @@ void init_PTQ(py::module &m) {
m.def("compute_sign_map", &computeSignMap, py::arg("network"), py::arg("verbose") = false,
R"mydelimiter(
For each node, compute the sign of its input and output values.
For each node, compute the sign of its input and output values.
The goal of the routine is to maximize the number of unsigned IOs in order to double the value resolution when possible.
:param network: The GraphView to analyze.
:type network: :py:class:`aidge_core.GraphView`
:type network: :py:class:`aidge_core.GraphView`
:param verbose: Whether to print the sign map or not.
:type verbose: bool
:type verbose: bool
:return: A map associating a pair of signs to each node of the GraphView (a sign for the input and one for the output).
:rtype: dict
:rtype: dict
)mydelimiter");
m.def("cross_layer_equalization", &crossLayerEqualization, py::arg("network"), py::arg("target_delta"),
R"mydelimiter(
Equalize the ranges of the nodes parameters by proceding iteratively.
Equalize the ranges of the nodes parameters by proceding iteratively.
Can only be applied to single branch networks (otherwise does not edit the graphView).
:param network: The GraphView to process.
:type network: :py:class:`aidge_core.GraphView`
:type network: :py:class:`aidge_core.GraphView`
:param target_delta: the stopping criterion (typical value : 0.01)
:type target_delta: float
:type target_delta: float
)mydelimiter");
m.def("get_weight_ranges", &getWeightRanges, py::arg("network"),
R"mydelimiter(
R"mydelimiter(
Compute the weight ranges of every affine nodes. Provided for debugging purposes.
:param network: The GraphView containing the affine nodes.
:type network: :py:class:`aidge_core.GraphView`
......@@ -206,18 +206,18 @@ void init_PTQ(py::module &m) {
:rtype: dict
)mydelimiter");
m.def("clear_biases", &clearBiases, py::arg("network"),
m.def("clear_biases", &clearBiases, py::arg("network"),
R"mydelimiter(
Clear the affine nodes biases. Provided form debugging purposes.
:param network: The GraphView containing the affine nodes.
:type network: :py:class:`aidge_core.GraphView`
)mydelimiter");
m.def("dev_ptq", &devPTQ, py::arg("network"),
m.def("dev_ptq", &devPTQ, py::arg("network"),
R"mydelimiter(
Developement and test routine.
:param network: The GraphView under test.
:type network: :py:class:`aidge_core.GraphView`
:type network: :py:class:`aidge_core.GraphView`
)mydelimiter");
m.def("prepare_network", &prepareNetwork, py::arg("network"), "prepare the network fo the PTQ");
......
0.2.0
0.3.0
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