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
b81fe53a
Commit
b81fe53a
authored
Aug 17, 2022
by
Jinoo Baek
Committed by
A. Unique TensorFlower
Aug 17, 2022
Browse files
Internal change
PiperOrigin-RevId: 468296610
parent
ceacd37c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
12 deletions
+21
-12
official/nlp/serving/export_savedmodel.py
official/nlp/serving/export_savedmodel.py
+21
-12
No files found.
official/nlp/serving/export_savedmodel.py
View file @
b81fe53a
...
...
@@ -136,21 +136,30 @@ def main(_):
if
FLAGS
.
convert_tpu
:
# pylint: disable=g-import-not-at-top
from
cloud_tpu.inference_converter
import
converter_cli
from
cloud_tpu.inference_converter
import
converter_options_pb2
from
cloud_tpu.inference_converter_v2
import
converter_options_v2_pb2
from
cloud_tpu.inference_converter_v2.python
import
converter
tpu_dir
=
os
.
path
.
join
(
export_dir
,
"tpu"
)
options
=
converter_options_pb2
.
ConverterO
ptions
()
batch_o
ptions
=
[]
if
FLAGS
.
allowed_batch_size
is
not
None
:
allowed_batch_sizes
=
sorted
(
FLAGS
.
allowed_batch_size
)
options
.
batch_options
.
num_batch_threads
=
FLAGS
.
num_batch_threads
options
.
batch_options
.
max_batch_size
=
allowed_batch_sizes
[
-
1
]
options
.
batch_options
.
batch_timeout_micros
=
FLAGS
.
batch_timeout_micros
options
.
batch_options
.
allowed_batch_sizes
[:]
=
allowed_batch_sizes
options
.
batch_options
.
max_enqueued_batches
=
FLAGS
.
max_enqueued_batches
converter_cli
.
ConvertSavedModel
(
export_dir
,
tpu_dir
,
function_alias
=
"tpu_candidate"
,
options
=
options
,
graph_rewrite_only
=
True
)
batch_option
=
converter_options_v2_pb2
.
BatchOptionsV2
(
num_batch_threads
=
FLAGS
.
num_batch_threads
,
max_batch_size
=
allowed_batch_sizes
[
-
1
],
batch_timeout_micros
=
FLAGS
.
batch_timeout_micros
,
allowed_batch_sizes
=
allowed_batch_sizes
,
max_enqueued_batches
=
FLAGS
.
max_enqueued_batches
)
batch_options
.
append
(
batch_option
)
converter_options
=
converter_options_v2_pb2
.
ConverterOptionsV2
(
tpu_functions
=
[
converter_options_v2_pb2
.
TpuFunction
(
function_alias
=
"tpu_candidate"
)
],
batch_options
=
batch_options
,
)
converter
.
ConvertSavedModel
(
export_dir
,
tpu_dir
,
converter_options
)
if
__name__
==
"__main__"
:
define_flags
()
...
...
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