| 1 | // Tencent is pleased to support the open source community by making ncnn available. |
| 2 | // |
| 3 | // Copyright (C) 2019 BUG1989. All rights reserved. |
| 4 | // Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. |
| 5 | // |
| 6 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except |
| 7 | // in compliance with the License. You may obtain a copy of the License at |
| 8 | // |
| 9 | // https://opensource.org/licenses/BSD-3-Clause |
| 10 | // |
| 11 | // Unless required by applicable law or agreed to in writing, software distributed |
| 12 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 13 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 14 | // specific language governing permissions and limitations under the License. |
| 15 | |
| 16 | #ifndef LAYER_REQUANTIZE_H |
| 17 | #define LAYER_REQUANTIZE_H |
| 18 | |
| 19 | #include "layer.h" |
| 20 | |
| 21 | namespace ncnn { |
| 22 | |
| 23 | class Requantize : public Layer |
| 24 | { |
| 25 | public: |
| 26 | Requantize(); |
| 27 | |
| 28 | virtual int load_param(const ParamDict& pd); |
| 29 | |
| 30 | virtual int load_model(const ModelBin& mb); |
| 31 | |
| 32 | virtual int forward(const Mat& bottom_blob, Mat& top_blob, const Option& opt) const; |
| 33 | |
| 34 | public: |
| 35 | int scale_in_data_size; |
| 36 | int scale_out_data_size; |
| 37 | int bias_data_size; |
| 38 | |
| 39 | // 0=none 1=relu 2=leakyrelu 3=clip 4=sigmoid |
| 40 | int activation_type; |
| 41 | Mat activation_params; |
| 42 | |
| 43 | Mat scale_in_data; |
| 44 | Mat scale_out_data; |
| 45 | Mat bias_data; |
| 46 | |
| 47 | // float scale_in; // bottom_blob_scale * weight_scale |
| 48 | // float scale_out; // top_blob_scale / (bottom_blob_scale * weight_scale) |
| 49 | // int bias_term; |
| 50 | // int bias_data_size; |
| 51 | // |
| 52 | // Mat bias_data; |
| 53 | }; |
| 54 | |
| 55 | } // namespace ncnn |
| 56 | |
| 57 | #endif // LAYER_REQUANTIZE_H |