Skip to content
Snippets Groups Projects
Commit 3b7f66ad authored by Benjamin Halimi's avatar Benjamin Halimi
Browse files

setup the pybind QAT module

parent cd8f9543
No related branches found
No related tags found
1 merge request!15version 0.2.0
/********************************************************************************
* Copyright (c) 2023 CEA-List
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
#ifndef AIDGE_QUANTIZATION_QAT_FIXEDQ_H_
#define AIDGE_QUANTIZATION_QAT_FIXEDQ_H_
#include "aidge/graph/Node.hpp"
#include "aidge/graph/GraphView.hpp"
namespace Aidge {
//namespace QuantFixedQ {
/**
* @brief Insert FixedQ activation quantizer nodes.
* In practice, ReLU nodes are replaced with a FixedQ quantizer node.
* @param graphView The GraphView containing the graph the quantize.
* @param nbBits Number of quantization steps, in bits (steps = 2^N-1).
*/
//void insertActQuantizers(std::shared_ptr<GraphView> graphView, size_t nbBits);
/**
* @brief Insert FixedQ weights quantizer nodes.
* @param graphView The GraphView containing the graph the quantize.
* @param nbBits Number of quantization steps, in bits (steps = 2^N-1).
*/
//void insertParamQuantizers(std::shared_ptr<GraphView> graphView, size_t nbBits);
/**
* @brief Insert all FixedQ quantizer nodes (for weights and activations).
* @param graphView The GraphView containing the graph the quantize.
* @param nbBits Number of quantization steps, in bits (steps = 2^N-1).
*/
//void insertQuantizers(std::shared_ptr<GraphView> graphView, size_t nbBits);
/**
* @brief Developement and test routine.
* @param graphView The GraphView under test.
*/
void devQAT(std::shared_ptr<GraphView> graphView);
// }
}
#endif /* AIDGE_QUANTIZATION_QAT_FIXEDQ_H_ */
/********************************************************************************
* Copyright (c) 2023 CEA-List
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "aidge/quantization/QAT/QAT_FixedQ.hpp"
#include "aidge/hook/Hook.hpp"
#include "aidge/graph/GraphView.hpp"
namespace py = pybind11;
namespace Aidge {
void init_QuantQAT(py::module &m) {
m.def("dev_qat", &devQAT, py::arg("network"),
R"mydelimiter(
Developement and test routine.
:param network: The GraphView under test.
:type network: :py:class:`aidge_core.GraphView`
)mydelimiter");
}
} // namespace Aidge
......@@ -19,13 +19,18 @@ namespace py = pybind11;
namespace Aidge
{
void init_QuantPTQ(py::module &m);
void init_FixedQ(py::module& m);
void init_QuantPTQ(py::module &m);
void init_QuantQAT(py::module &m);
PYBIND11_MODULE(aidge_quantization, m)
{
init_QuantPTQ(m);
init_FixedQ(m);
init_QuantPTQ(m);
init_QuantQAT(m);
}
} // namespace Aidge
/********************************************************************************
* Copyright (c) 2023 CEA-List
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
/********************************************************************************
* Copyright (c) 2023 CEA-List
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
#include "aidge/quantization/QAT/QAT_FixedQ.hpp"
#include "aidge/data/Tensor.hpp"
#include "aidge/graph/GraphView.hpp"
#include "aidge/scheduler/SequentialScheduler.hpp"
#include "aidge/scheduler/Scheduler.hpp"
/*
#include "aidge/graph/Node.hpp"
#include "aidge/utils/Log.hpp"
#include "aidge/operator/Producer.hpp"
#include "aidge/operator/Mul.hpp"
#include "aidge/operator/ReLU.hpp"
#include "aidge/operator/Scaling.hpp"
#include "aidge/recipes/Recipes.hpp"
*/
namespace Aidge {
void devQAT(std::shared_ptr<GraphView> graphView)
{
SequentialScheduler scheduler(graphView);
scheduler.generateScheduling();
auto s = scheduler.getStaticScheduling();
for (std::shared_ptr<Node> node : s)
std::cout << " UUU : " << node->name() << std::endl;
}
}
\ No newline at end of file
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