diff --git a/training/training_scripts/NN_Filtering_HOP/quantize/quantize.py b/training/training_scripts/NN_Filtering_HOP/quantize/quantize.py new file mode 100644 index 0000000000000000000000000000000000000000..42df4440a099911f183a13273c5483894542e719 --- /dev/null +++ b/training/training_scripts/NN_Filtering_HOP/quantize/quantize.py @@ -0,0 +1,109 @@ +""" +/* The copyright in this software is being made available under the BSD +* License, included below. This software may be subject to other third party +* and contributor rights, including patent rights, and no such rights are +* granted under this license. +* +* Copyright (c) 2010-2023, ITU/ISO/IEC +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* * Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* * Neither the name of the ITU/ISO/IEC nor the names of its contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +* THE POSSIBILITY OF SUCH DAMAGE. +""" + +# inputs: REC, PRED, BS, QPb, QPs, IBP +Q = 11 +print(f"0 {Q} 1 {Q} 2 {Q} 3 {Q} 4 {Q} 5 {Q} ", end="") + +# conv2D + biais on inputs +Q = 11 +print( + f"6 {Q} 8 {Q} 12 {Q} 14 {Q} 18 {Q} 20 {Q} 24 {Q} 26 {Q} 30 {Q} 32 {Q} 36 {Q} 38 {Q} ", + end="", +) + +# conv2D internal quantization offset +L = [7, 13, 19, 25, 31, 37, 45, 51] +for i in L: + print(f" {i} 0 ", end="") + +# leaky relu +Q = 11 +L = [10, 16, 22, 28, 34, 40, 48, 54] +for i in L: + print(f" {i} {Q} ", end="") + + +# concatenate result NO QUANTIZATION on attribute +print(" 42 0 ", end="") + +# conv2D+bias channel reduction +Q = 11 +print(f" 44 {Q} 46 {Q} ", end="") + +# conv2d+bias +Q = 11 +print(f" 50 {Q} 52 {Q} ", end="") + + +# building blocks +Q = 11 +for i in range(24): + # conv internal quantization offset + print(f"{57+i*31} 0 ", end="") + print(f"{63+i*31} 0 ", end="") + print(f"{67+i*31} 0 ", end="") + print(f"{75+i*31} 0 ", end="") + print(f"{79+i*31} 0 ", end="") + print(f"{83+i*31} 0 ", end="") + + print(f"{72+i*31} 0 ", end="") + + # conv+bias + print(f"{56+i*31} {Q} ", end="") + print(f"{58+i*31} {Q} ", end="") + print(f"{62+i*31} {Q} ", end="") + print(f"{64+i*31} {Q} ", end="") + print(f"{66+i*31} {Q} ", end="") + print(f"{68+i*31} {Q} ", end="") + print(f"{74+i*31} {Q} ", end="") + print(f"{76+i*31} {Q} ", end="") + print(f"{78+i*31} {Q} ", end="") + print(f"{80+i*31} {Q} ", end="") + print(f"{82+i*31} {Q} ", end="") + print(f"{84+i*31} {Q} ", end="") + + # leaky relu + print(f"{70+i*31} {Q} ", end="") + print(f"{60+i*31} {Q} ", end="") + +# final conv+bias +Q = 11 +print(f" 800 {Q} 802 {Q} 806 {Q} 808 {Q}", end="") + +# leaky relu +print(f" 804 {Q} ", end="") + +# conv internal quantization offset +print(" 801 0 807 0 ")