diff options
author | 2018-07-25 08:23:57 -0700 | |
---|---|---|
committer | 2018-07-25 08:27:36 -0700 | |
commit | b3771feab49e2122164737a860341727d08c2d8c (patch) | |
tree | 5fb440041db26ef96eb14e7491cb67fe06e7c3d4 /tensorflow/core/graph | |
parent | be3d22844025e42e177a21479f3ae73bc5351c1f (diff) |
This change started with an intention of adding an attribute to cast ops to decide
whether bfloat16 casts should use truncation or rounding.
This is a preparatory change before we switch the default float ==> bfloat16 cast
to use rounding instead of truncation. The attribute added can then be specified
on casts that rely on the truncation, e.g., the TensorFlow send/receive operations.
It later emerged that the choice of doing truncation is useful more generally.
Therefore, this change allows the new attribute to be used by all relevant casts
to use truncation instead of rounding.
PiperOrigin-RevId: 205996367
Diffstat (limited to 'tensorflow/core/graph')
-rw-r--r-- | tensorflow/core/graph/graph_partition.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tensorflow/core/graph/graph_partition.cc b/tensorflow/core/graph/graph_partition.cc index 1b1941f9c1..ea0a814ab8 100644 --- a/tensorflow/core/graph/graph_partition.cc +++ b/tensorflow/core/graph/graph_partition.cc @@ -214,6 +214,14 @@ NodeDef* AddSend(const PartitionOptions& opts, const GraphInfo& g_info, cast_builder.Attr("_start_time", start_time); } cast_builder.Attr("DstT", cast_dtype); + + if (cast_dtype == DT_BFLOAT16) { + // the below attribute specifies that the cast to bfloat16 should use + // truncation. This is needed to retain legacy behavior when we change + // the default bfloat16 casts to use rounding instead of truncation + cast_builder.Attr("Truncate", true); + } + NodeDef* cast = gdef->add_node(); *status = cast_builder.Finalize(cast); if (!status->ok()) return nullptr; |