"git@developer.sourcefind.cn:hehl2/torchaudio.git" did not exist on "2acafdafd91d4ad3df7079d63fc51f3f3c00813a"
Unverified Commit 79b6c2f3 authored by pyoung2778's avatar pyoung2778 Committed by GitHub
Browse files

Check in seq_flow_lite (#10502)

parent 3d0e12fd
......@@ -19,6 +19,7 @@ build:manylinux2010 --crosstool_top=//third_party/toolchains/preconfig/ubuntu16.
build -c opt
build --cxxopt="-std=c++14"
build --host_cxxopt="-std=c++14"
build --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
build --auto_output_filter=subpackages
build --copt="-Wall" --copt="-Wno-sign-compare"
......@@ -60,11 +61,6 @@ build --define=grpc_no_ares=true
# archives in -whole_archive -no_whole_archive.
build --noincompatible_remove_legacy_whole_archive
# These are bazel 2.0's incompatible flags. Tensorflow needs to use bazel 2.0.0
# to use cc_shared_library, as part of the Tensorflow Build Improvements RFC:
# https://github.com/tensorflow/community/pull/179
build --noincompatible_prohibit_aapt1
# Build TF with C++ 17 features.
build:c++17 --cxxopt=-std=c++1z
build:c++17 --cxxopt=-stdlib=libc++
......
......@@ -28,6 +28,40 @@ def _dump_graph_in_text_format(filename, graph_def):
f.close()
def get_mean_stddev_values(min_value_of_features, max_value_of_features):
"""Gets Mean and Stddev values for given min/max float values."""
quant_min = 0
quant_max = 255
min_global = min_value_of_features
max_global = max_value_of_features
quant_min_float = float(quant_min)
quant_max_float = float(quant_max)
nudged_scale = (max_global - min_global) / (quant_max_float - quant_min_float)
zero_point_from_min = quant_min_float - min_global / nudged_scale
if zero_point_from_min < quant_min_float:
nudged_zero_point = int(quant_min)
elif zero_point_from_min > quant_max_float:
nudged_zero_point = int(quant_max)
else:
nudged_zero_point = int(round(zero_point_from_min))
nudged_min = (quant_min_float - nudged_zero_point) * (nudged_scale)
nudged_max = (quant_max_float - nudged_zero_point) * (nudged_scale)
zero_point = (quant_min - min_global) / (max_global - min_global) * quant_max
scale = (nudged_max - nudged_min) / 255.0
mean_value = zero_point
stddev_value = 1 / scale
return mean_value, stddev_value
class InterpreterWithCustomOps(tf.lite.Interpreter):
"""Extended tf.lite.Interpreter."""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment