// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #include #include "core/framework/op_kernel.h" namespace onnxruntime { namespace contrib { template class QLinearLookupBase : public OpKernel { public: QLinearLookupBase(const OpKernelInfo& info) : OpKernel(info), fixed_lookup_table_() { } // protected: template Status ComputeBase(OpKernelContext* context, Transformer fn) const; // Should be called in derived class's constructor template void BuildLookupTableIfFixed(const OpKernelInfo& info, Transformer fn); // when input quantizaton parameters are const, pre-compute table value. // After construction, non-zero size means pre-computed. Save space when not pre-computed. std::vector fixed_lookup_table_; }; template class QLinearLeakyRelu final : public QLinearLookupBase { public: QLinearLeakyRelu(const OpKernelInfo& info); Status Compute(OpKernelContext* context) const override; private: const float alpha_; }; template class QLinearSigmoid final : public QLinearLookupBase { public: QLinearSigmoid(const OpKernelInfo& info); Status Compute(OpKernelContext* context) const override; }; } // namespace contrib } // namespace onnxruntime