[LPT] Introduce new quantization mode attribute (#11380)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2022 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <ngraph/variant.hpp>
|
||||
#include <low_precision/lpt_visibility.hpp>
|
||||
|
||||
namespace ngraph {
|
||||
|
||||
class LP_TRANSFORMATIONS_API QuantizationModeAttribute : public ov::RuntimeAttribute {
|
||||
public:
|
||||
OPENVINO_RTTI("LowPrecision::QuantizationModeAttribute", "", ov::RuntimeAttribute, 0);
|
||||
|
||||
enum class Mode {
|
||||
Asymmetric,
|
||||
Symmetric
|
||||
};
|
||||
|
||||
QuantizationModeAttribute() : mode(Mode::Asymmetric) {}
|
||||
QuantizationModeAttribute(const Mode mode) : mode(mode) {}
|
||||
|
||||
bool operator==(const QuantizationModeAttribute& attribute) const {
|
||||
return this->mode == attribute.mode;
|
||||
}
|
||||
|
||||
std::string to_string() const override;
|
||||
|
||||
Mode mode;
|
||||
};
|
||||
} // namespace ngraph
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2022 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "low_precision/rt_info/quantization_mode_attribute.hpp"
|
||||
#include <assert.h>
|
||||
|
||||
using namespace ngraph;
|
||||
using namespace ov;
|
||||
|
||||
std::string QuantizationModeAttribute::to_string() const {
|
||||
assert((mode == Mode::Asymmetric) || (mode == Mode::Symmetric));
|
||||
|
||||
std::stringstream ss;
|
||||
switch (mode) {
|
||||
case Mode::Asymmetric: {
|
||||
ss << "Asymmetric";
|
||||
break;
|
||||
}
|
||||
case Mode::Symmetric: {
|
||||
ss << "Symmetric";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ss << "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
Reference in New Issue
Block a user