Skip to content
Snippets Groups Projects

Upd version 0.3.0

Merged Maxence Naud requested to merge upd_version_0-3-0 into dev
3 files
+ 28
28
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -31,7 +31,7 @@ void init_PTQ(py::module &m) {
@@ -31,7 +31,7 @@ void init_PTQ(py::module &m) {
.value("AA" , Clipping::AA)
.value("AA" , Clipping::AA)
.value("KL" , Clipping::KL);
.value("KL" , Clipping::KL);
m.def("check_architecture", &checkArchitecture, py::arg("network"),
m.def("check_architecture", &checkArchitecture, py::arg("network"),
R"mydelimiter(
R"mydelimiter(
Determine whether an input GraphView can be quantized or not.
Determine whether an input GraphView can be quantized or not.
:param network: The GraphView to be checked.
:param network: The GraphView to be checked.
@@ -40,15 +40,15 @@ void init_PTQ(py::module &m) {
@@ -40,15 +40,15 @@ void init_PTQ(py::module &m) {
:rtype: bool
:rtype: bool
)mydelimiter");
)mydelimiter");
m.def("insert_scaling_nodes", &insertScalingNodes, py::arg("network"),
m.def("insert_scaling_nodes", &insertScalingNodes, py::arg("network"),
R"mydelimiter(
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.
Also insert a scaling node in every purely residual branches.
:param network: The GraphView containing the affine nodes.
:param network: The GraphView containing the affine nodes.
:type network: :py:class:`aidge_core.GraphView`
:type network: :py:class:`aidge_core.GraphView`
)mydelimiter");
)mydelimiter");
m.def("normalize_parameters", &normalizeParameters, py::arg("network"),
m.def("normalize_parameters", &normalizeParameters, py::arg("network"),
R"mydelimiter(
R"mydelimiter(
Normalize the parameters of each parametrized node, so that they fit in the [-1:1] range.
Normalize the parameters of each parametrized node, so that they fit in the [-1:1] range.
:param network: The GraphView containing the parametrized nodes.
:param network: The GraphView containing the parametrized nodes.
@@ -69,17 +69,17 @@ void init_PTQ(py::module &m) {
@@ -69,17 +69,17 @@ void init_PTQ(py::module &m) {
)mydelimiter");
)mydelimiter");
m.def("normalize_activations", &normalizeActivations, py::arg("network"), py::arg("value_ranges"),
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.
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.
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.
:param network: The GraphView containing the affine nodes.
:type network: :py:class:`aidge_core.GraphView`
: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.
:type value_ranges: list of float.
)mydelimiter");
)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,
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.
Quantize an already normalized (in term of parameters and activations) network.
:param network: The GraphView to be quantized.
:param network: The GraphView to be quantized.
:type network: :py:class:`aidge_core.GraphView`
:type network: :py:class:`aidge_core.GraphView`
@@ -94,13 +94,13 @@ void init_PTQ(py::module &m) {
@@ -94,13 +94,13 @@ void init_PTQ(py::module &m) {
)mydelimiter");
)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,
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.
Main quantization routine. Performs every step of the quantization pipeline.
:param network: The GraphView to be quantized.
:param network: The GraphView to be quantized.
:type network: :py:class:`aidge_core.GraphView`
:type network: :py:class:`aidge_core.GraphView`
:param nb_bits: The desired number of bits of the quantization.
:param nb_bits: The desired number of bits of the quantization.
:type nb_bits: int
: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`
: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'.
:param clipping_mode: Type of the clipping optimization. Can be either 'MAX', 'MSE', 'AA' or 'KL'.
:type clipping_mode: string
:type clipping_mode: string
@@ -108,7 +108,7 @@ void init_PTQ(py::module &m) {
@@ -108,7 +108,7 @@ void init_PTQ(py::module &m) {
:type no_quantization: bool
:type no_quantization: bool
:param optimize_signs: Whether to take account of the IO signs of the operators or not.
:param optimize_signs: Whether to take account of the IO signs of the operators or not.
:type optimize_signs: bool
: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
:type single_shift: bool
:param verbose: Whether to print internal informations about the quantization process.
:param verbose: Whether to print internal informations about the quantization process.
:type verbose: bool
:type verbose: bool
@@ -155,9 +155,9 @@ void init_PTQ(py::module &m) {
@@ -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,
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(
R"mydelimiter(
Return a corrected map of the provided activation ranges.
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.
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'.
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.
:param clipping_mode: The method used to compute the optimal clippings.
:type clipping_mode: enum
:type clipping_mode: enum
:param value_ranges: The map associating each affine node to its output range.
:param value_ranges: The map associating each affine node to its output range.
@@ -177,28 +177,28 @@ void init_PTQ(py::module &m) {
@@ -177,28 +177,28 @@ void init_PTQ(py::module &m) {
m.def("compute_sign_map", &computeSignMap, py::arg("network"), py::arg("verbose") = false,
m.def("compute_sign_map", &computeSignMap, py::arg("network"), py::arg("verbose") = false,
R"mydelimiter(
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.
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.
: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.
: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).
: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");
)mydelimiter");
m.def("cross_layer_equalization", &crossLayerEqualization, py::arg("network"), py::arg("target_delta"),
m.def("cross_layer_equalization", &crossLayerEqualization, py::arg("network"), py::arg("target_delta"),
R"mydelimiter(
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).
Can only be applied to single branch networks (otherwise does not edit the graphView).
:param network: The GraphView to process.
: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)
:param target_delta: the stopping criterion (typical value : 0.01)
:type target_delta: float
:type target_delta: float
)mydelimiter");
)mydelimiter");
m.def("get_weight_ranges", &getWeightRanges, py::arg("network"),
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.
Compute the weight ranges of every affine nodes. Provided for debugging purposes.
:param network: The GraphView containing the affine nodes.
:param network: The GraphView containing the affine nodes.
:type network: :py:class:`aidge_core.GraphView`
:type network: :py:class:`aidge_core.GraphView`
@@ -206,18 +206,18 @@ void init_PTQ(py::module &m) {
@@ -206,18 +206,18 @@ void init_PTQ(py::module &m) {
:rtype: dict
:rtype: dict
)mydelimiter");
)mydelimiter");
m.def("clear_biases", &clearBiases, py::arg("network"),
m.def("clear_biases", &clearBiases, py::arg("network"),
R"mydelimiter(
R"mydelimiter(
Clear the affine nodes biases. Provided form debugging purposes.
Clear the affine nodes biases. Provided form debugging purposes.
:param network: The GraphView containing the affine nodes.
:param network: The GraphView containing the affine nodes.
:type network: :py:class:`aidge_core.GraphView`
:type network: :py:class:`aidge_core.GraphView`
)mydelimiter");
)mydelimiter");
m.def("dev_ptq", &devPTQ, py::arg("network"),
m.def("dev_ptq", &devPTQ, py::arg("network"),
R"mydelimiter(
R"mydelimiter(
Developement and test routine.
Developement and test routine.
:param network: The GraphView under test.
:param network: The GraphView under test.
:type network: :py:class:`aidge_core.GraphView`
:type network: :py:class:`aidge_core.GraphView`
)mydelimiter");
)mydelimiter");
m.def("prepare_network", &prepareNetwork, py::arg("network"), "prepare the network fo the PTQ");
m.def("prepare_network", &prepareNetwork, py::arg("network"), "prepare the network fo the PTQ");
Loading