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
01dbd5bf
Commit
01dbd5bf
authored
Feb 26, 2020
by
A. Unique TensorFlower
Browse files
Internal change
PiperOrigin-RevId: 297317839
parent
9a4b0371
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
official/benchmark/tfhub_memory_usage_benchmark.py
official/benchmark/tfhub_memory_usage_benchmark.py
+51
-0
No files found.
official/benchmark/tfhub_memory_usage_benchmark.py
0 → 100644
View file @
01dbd5bf
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Runs a memory usage benchmark for a Tensorflow Hub model.
Loads a SavedModel and records memory usage.
"""
import
time
from
absl
import
flags
import
tensorflow.compat.v2
as
tf
import
tensorflow_hub
as
hub
from
official.utils.testing.perfzero_benchmark
import
PerfZeroBenchmark
FLAGS
=
flags
.
FLAGS
class
TfHubMemoryUsageBenchmark
(
PerfZeroBenchmark
):
"""A benchmark measuring memory usage for a given TF Hub SavedModel."""
def
__init__
(
self
,
output_dir
=
None
,
default_flags
=
None
,
root_data_dir
=
None
):
super
(
TfHubMemoryUsageBenchmark
,
self
).
__init__
(
output_dir
=
output_dir
,
default_flags
=
default_flags
)
def
benchmark_memory_usage
(
self
):
start_time_sec
=
time
.
time
()
self
.
load_model
()
wall_time_sec
=
time
.
time
()
-
start_time_sec
metrics
=
[]
self
.
report_benchmark
(
iters
=-
1
,
wall_time
=
wall_time_sec
,
metrics
=
metrics
)
def
load_model
(
self
):
"""Loads a TF Hub module."""
hub
.
load
(
'https://tfhub.dev/google/nnlm-en-dim128/1'
)
if
__name__
==
'__main__'
:
tf
.
test
.
main
()
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