Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
79b6c2f3
"git@developer.sourcefind.cn:hehl2/torchaudio.git" did not exist on "2acafdafd91d4ad3df7079d63fc51f3f3c00813a"
Unverified
Commit
79b6c2f3
authored
Feb 15, 2022
by
pyoung2778
Committed by
GitHub
Feb 15, 2022
Browse files
Check in seq_flow_lite (#10502)
parent
3d0e12fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
5 deletions
+35
-5
research/seq_flow_lite/.bazelrc
research/seq_flow_lite/.bazelrc
+1
-5
research/seq_flow_lite/utils/tflite_utils.py
research/seq_flow_lite/utils/tflite_utils.py
+34
-0
No files found.
research/seq_flow_lite/.bazelrc
View file @
79b6c2f3
...
...
@@ -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++
...
...
research/seq_flow_lite/utils/tflite_utils.py
View file @
79b6c2f3
...
...
@@ -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."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment