// Copyright (c Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #ifndef ONNXRUNTIME_QLINEAR_UTIL_H #define ONNXRUNTIME_QLINEAR_UTIL_H #include #include "core/framework/tensor.h" namespace onnxruntime { namespace contrib { constexpr int LOOKUP_TABLE_IS_FIXED = 1; constexpr int LOOKUP_TABLE_IS_COPY = 2; static inline bool has_same_scale(const Tensor* tensor_x_scale, const Tensor* tensor_y_scale) { return *(tensor_x_scale->Data()) == *(tensor_y_scale->Data()); } static inline bool has_same_zero_point(bool is_signed, const Tensor* tensor_x_zero_point, const Tensor* tensor_y_zero_point) { if (is_signed) { const int8_t X_zero_point = (tensor_x_zero_point == nullptr) ? static_cast(0) : *(tensor_x_zero_point->Data()); const int8_t Y_zero_point = (tensor_y_zero_point == nullptr) ? static_cast(0) : *(tensor_y_zero_point->Data()); return X_zero_point == Y_zero_point; } const uint8_t X_zero_point = (tensor_x_zero_point == nullptr) ? static_cast(0) : *(tensor_x_zero_point->Data()); const uint8_t Y_zero_point = (tensor_y_zero_point == nullptr) ? static_cast(0) : *(tensor_y_zero_point->Data()); return X_zero_point == Y_zero_point; } } // namespace contrib } // namespace onnxruntime #endif // ONNXRUNTIME_QLINEAR_UTIL_H