diff options
author | 2017-02-07 16:45:06 -0800 | |
---|---|---|
committer | 2017-02-07 17:09:35 -0800 | |
commit | 780bc6b4d98665125c43685b20eeba6ad2804c0c (patch) | |
tree | 4acac8d596888cae078e520e65d836ff1a2c28d3 /tensorflow/core/kernels/example_parsing_ops.cc | |
parent | e6bfaf47374b44bb688023904eac98576baf4cd4 (diff) |
Add support for variable major dimension in dense features in example parser c++ op.
Full python support (including more comprehensive documentation) coming soon.
Change: 146852707
Diffstat (limited to 'tensorflow/core/kernels/example_parsing_ops.cc')
-rw-r--r-- | tensorflow/core/kernels/example_parsing_ops.cc | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/tensorflow/core/kernels/example_parsing_ops.cc b/tensorflow/core/kernels/example_parsing_ops.cc index d03f8fa33a..f4c4460fa4 100644 --- a/tensorflow/core/kernels/example_parsing_ops.cc +++ b/tensorflow/core/kernels/example_parsing_ops.cc @@ -92,7 +92,18 @@ class ExampleParserOp : public OpKernel { for (int d = 0; d < static_cast<int>(attrs_.num_dense); ++d) { const Tensor& def_value = dense_defaults[d]; - if (def_value.NumElements() > 0) { + if (attrs_.variable_length[d]) { + OP_REQUIRES(ctx, def_value.NumElements() == 1, + errors::InvalidArgument( + "dense_shape[", d, "] is a variable length shape: ", + attrs_.dense_shapes[d].DebugString(), + ", therefore " + "def_value[", + d, + "] must contain a single element (" + "the padding element). But its shape is: ", + def_value.shape().DebugString())); + } else if (def_value.NumElements() > 0) { OP_REQUIRES(ctx, attrs_.dense_shapes[d].IsCompatibleWith(def_value.shape()), errors::InvalidArgument( @@ -100,12 +111,12 @@ class ExampleParserOp : public OpKernel { "].shape() == ", def_value.shape().DebugString(), " is not compatible with dense_shapes_[", d, "] == ", attrs_.dense_shapes[d].DebugString())); - OP_REQUIRES(ctx, def_value.dtype() == attrs_.dense_types[d], - errors::InvalidArgument( - "dense_defaults[", d, "].dtype() == ", - DataTypeString(def_value.dtype()), " != dense_types_[", - d, "] == ", DataTypeString(attrs_.dense_types[d]))); } + OP_REQUIRES(ctx, def_value.dtype() == attrs_.dense_types[d], + errors::InvalidArgument( + "dense_defaults[", d, "].dtype() == ", + DataTypeString(def_value.dtype()), " != dense_types_[", d, + "] == ", DataTypeString(attrs_.dense_types[d]))); } example::Result result; @@ -114,6 +125,7 @@ class ExampleParserOp : public OpKernel { for (int d = 0; d < attrs_.num_dense; ++d) { config.dense.push_back({dense_keys_t[d], attrs_.dense_types[d], attrs_.dense_shapes[d], dense_defaults[d], + attrs_.variable_length[d], attrs_.elements_per_stride[d]}); } for (int d = 0; d < attrs_.num_sparse; ++d) { |