Commit 1eddd748 authored by A. Unique TensorFlower's avatar A. Unique TensorFlower
Browse files

Internal change

PiperOrigin-RevId: 366496850
parent c9768389
...@@ -112,8 +112,8 @@ class Parser(parser.Parser): ...@@ -112,8 +112,8 @@ class Parser(parser.Parser):
self._use_autoaugment = use_autoaugment self._use_autoaugment = use_autoaugment
self._autoaugment_policy_name = autoaugment_policy_name self._autoaugment_policy_name = autoaugment_policy_name
# Device. # Data type.
self._use_bfloat16 = True if dtype == 'bfloat16' else False self._dtype = dtype
def _parse_train_data(self, data): def _parse_train_data(self, data):
"""Parses data for training and evaluation.""" """Parses data for training and evaluation."""
...@@ -180,9 +180,8 @@ class Parser(parser.Parser): ...@@ -180,9 +180,8 @@ class Parser(parser.Parser):
box_weights) = anchor_labeler.label_anchors( box_weights) = anchor_labeler.label_anchors(
anchor_boxes, boxes, tf.expand_dims(classes, axis=1)) anchor_boxes, boxes, tf.expand_dims(classes, axis=1))
# If bfloat16 is used, casts input image to tf.bfloat16. # Casts input image to desired data type.
if self._use_bfloat16: image = tf.cast(image, dtype=self._dtype)
image = tf.cast(image, dtype=tf.bfloat16)
# Packs labels for model_fn outputs. # Packs labels for model_fn outputs.
labels = { labels = {
...@@ -245,9 +244,8 @@ class Parser(parser.Parser): ...@@ -245,9 +244,8 @@ class Parser(parser.Parser):
box_weights) = anchor_labeler.label_anchors( box_weights) = anchor_labeler.label_anchors(
anchor_boxes, boxes, tf.expand_dims(classes, axis=1)) anchor_boxes, boxes, tf.expand_dims(classes, axis=1))
# If bfloat16 is used, casts input image to tf.bfloat16. # Casts input image to desired data type.
if self._use_bfloat16: image = tf.cast(image, dtype=self._dtype)
image = tf.cast(image, dtype=tf.bfloat16)
# Sets up groundtruth data for evaluation. # Sets up groundtruth data for evaluation.
groundtruths = { groundtruths = {
......
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