diff options
author | 2016-01-06 12:52:30 -0800 | |
---|---|---|
committer | 2016-01-06 12:52:30 -0800 | |
commit | 0ce489f4e0c3b12d4dce1b2d642f48f45797774a (patch) | |
tree | f438f4c42c98a9e26ace12bb84b3f3be7e3f6745 /tensorflow/core/kernels/summary_op.cc | |
parent | d0dfcdbd7bf605f5878f1b3aa2aacd5fcf001e32 (diff) |
New GraphDef version 4: TensorFlow is now scalar strict
The kAllowLegacyScalars flag is now gone. Instead, scalar strictness now
depends on the GraphDef version: we are lenient below 4 and strict with 4
and above. All new graphs should use version >= 4.
The internal Google version of tensorflow is now as scalar strict as the
open source release. Note that outside of PLATFORM_GOOGLE, this change has no
effect, since the code was already scalar strict.
Change: 111467133
Diffstat (limited to 'tensorflow/core/kernels/summary_op.cc')
-rw-r--r-- | tensorflow/core/kernels/summary_op.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/tensorflow/core/kernels/summary_op.cc b/tensorflow/core/kernels/summary_op.cc index 4031e90857..7451ea5673 100644 --- a/tensorflow/core/kernels/summary_op.cc +++ b/tensorflow/core/kernels/summary_op.cc @@ -40,12 +40,12 @@ class SummaryScalarOp : public OpKernel { const Tensor& tags = c->input(0); const Tensor& values = c->input(1); - OP_REQUIRES(c, tags.IsSameSize(values) || - (TensorShapeUtils::IsLegacyScalar(tags.shape()) && - TensorShapeUtils::IsLegacyScalar(values.shape())), + OP_REQUIRES(c, tags.IsSameSize(values) || (IsLegacyScalar(tags.shape()) && + IsLegacyScalar(values.shape())), errors::InvalidArgument("tags and values not the same shape: ", tags.shape().ShortDebugString(), " != ", - values.shape().ShortDebugString())); + values.shape().ShortDebugString(), + SingleTag(tags))); auto Ttags = tags.flat<string>(); auto Tvalues = values.flat<T>(); Summary s; @@ -59,6 +59,15 @@ class SummaryScalarOp : public OpKernel { OP_REQUIRES_OK(c, c->allocate_output(0, TensorShape({}), &summary_tensor)); CHECK(s.SerializeToString(&summary_tensor->scalar<string>()())); } + + // If there's only one tag, include it in the error message + static string SingleTag(const Tensor& tags) { + if (tags.NumElements() == 1) { + return strings::StrCat(" (tag '", tags.flat<string>()(0), "')"); + } else { + return ""; + } + } }; template <typename T> @@ -72,7 +81,7 @@ class SummaryHistoOp : public OpKernel { const Tensor& tags = c->input(0); const Tensor& values = c->input(1); const auto flat = values.flat<T>(); - OP_REQUIRES(c, TensorShapeUtils::IsLegacyScalar(tags.shape()), + OP_REQUIRES(c, IsLegacyScalar(tags.shape()), errors::InvalidArgument("tags must be scalar")); // Build histogram of values in "values" tensor histogram::Histogram histo; |