-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quantizer class to perform quantization
This pull request introduces a quantizer class allowing quantization and dequantization with different schemes. The goal is to offer users more choices when dealing with various types of quantization. Initial support targets include affine quantization (per tensor and per channel) and binary-code-based quantization. This pull request presents the basic structure of these classes, and further implementation details will be added in future updates. **Self-evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Donghyeon Jeong <[email protected]>
- Loading branch information
Showing
5 changed files
with
383 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.