Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quantizer class to perform quantization #2824

Merged
merged 1 commit into from
Dec 19, 2024
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
1 change: 1 addition & 0 deletions debian/nntrainer-dev.install
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/usr/include/nntrainer/blas_interface.h
/usr/include/nntrainer/var_grad.h
/usr/include/nntrainer/weight.h
/usr/include/nntrainer/quantizer.h
/usr/include/nntrainer/blas_avx.h
# todo: update dataset headers
/usr/include/nntrainer/databuffer.h
Expand Down
2 changes: 2 additions & 0 deletions nntrainer/tensor/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tensor_sources = [
'tensor_dim.cpp',
'var_grad.cpp',
'weight.cpp',
'quantizer.cpp',
'basic_planner.cpp',
'memory_pool.cpp',
'swap_device.cpp',
Expand All @@ -31,6 +32,7 @@ tensor_headers = [
'uint_tensor.h',
'weight.h',
'var_grad.h',
'quantizer.h',
'tensor_wrap_specs.h',
'blas_interface.h',
'manager.h',
Expand Down
84 changes: 84 additions & 0 deletions nntrainer/tensor/quantizer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// SPDX-License-Identifier: Apache-2.0
/**
* @file quantizer.cpp
* @date 10 December 2024
* @brief This defines quantizers for different types of quantization schemes
* @see https://github.com/nnstreamer/nntrainer
* @author Donghyeon Jeong <[email protected]>
* @bug No known bugs except for NYI items
*/

#include <quantizer.h>

namespace nntrainer {

/**
* @brief PerTensorAffineQuantizer class
*/
std::unique_ptr<Quantizer> PerTensorAffineQuantizer::create() {
return std::make_unique<PerTensorAffineQuantizer>();
}

Tensor PerTensorAffineQuantizer::quantize(const Tensor &input,
Tdatatype qtype) {
/// @todo NYI
return input;
}

Tensor PerTensorAffineQuantizer::dequantize(const Tensor &input,
Tdatatype dtype) {
/// @todo NYI
return input;
}

QScheme PerTensorAffineQuantizer::qscheme() const {
return QScheme::PER_TENSOR_AFFINE;
}

/**
* @brief PerChannelAffineQuantizer class
*/
std::unique_ptr<Quantizer> PerChannelAffineQuantizer::create() {
return std::make_unique<PerChannelAffineQuantizer>();
}

Tensor PerChannelAffineQuantizer::quantize(const Tensor &input,
Tdatatype qtype) {
/// @todo NYI
return input;
}

Tensor PerChannelAffineQuantizer::dequantize(const Tensor &input,
Tdatatype dtype) {
/// @todo NYI
return input;
}

QScheme PerChannelAffineQuantizer::qscheme() const {
return QScheme::PER_CHANNEL_AFFINE;
}

/**
* @brief BinaryCodeBasedQuantizer class
*/
std::unique_ptr<Quantizer> BinaryCodeBasedQuantizer::create() {
return std::make_unique<BinaryCodeBasedQuantizer>();
}

Tensor BinaryCodeBasedQuantizer::quantize(const Tensor &input,
Tdatatype qtype) {
/// @todo NYI
return input;
}

Tensor BinaryCodeBasedQuantizer::dequantize(const Tensor &input,
Tdatatype dtype) {
/// @todo NYI
return input;
}

QScheme BinaryCodeBasedQuantizer::qscheme() const {
return QScheme::BINARY_CODE_BASED;
}

} // namespace nntrainer
Loading
Loading