MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ValidateDefaultValueShape

Function ValidateDefaultValueShape

tensorflow/core/ops/ragged_to_dense_util.cc:128–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128tensorflow::Status ValidateDefaultValueShape(
129 const TensorShapeProto& default_value_shape,
130 const TensorShapeProto& value_shape) {
131 if (default_value_shape.unknown_rank() || value_shape.unknown_rank()) {
132 return tensorflow::Status::OK();
133 }
134
135 if (default_value_shape.dim_size() > value_shape.dim_size()) {
136 // TODO(martinz): This constraint is unnecessary. The
137 // default value could have as many dimensions as shape. If there is a
138 // discrepancy, it will be picked up when we broadcast the default value.
139 // For now, I'll relax the constraint only slightly.
140 return InvalidArgument(
141 "default_value_shape must have no more dimensions than the value. "
142 "default_value_shape: ",
143 default_value_shape.DebugString(),
144 " default_value_shape.dim_size(): ", default_value_shape.dim_size(),
145 " value_shape: ", value_shape.DebugString(),
146 " value_shape.dim_size(): ", value_shape.dim_size());
147 }
148 for (int i = 0;
149 i < std::min(default_value_shape.dim_size(), value_shape.dim_size() - 1);
150 ++i) {
151 if (default_value_shape.dim(i).size() >= 0 &&
152 value_shape.dim(i + 1).size() >= 0 &&
153 default_value_shape.dim(i).size() != 1 &&
154 default_value_shape.dim(i).size() != value_shape.dim(i + 1).size()) {
155 return InvalidArgument(
156 "default_value_shape and value_shape do not match on dimension ", i);
157 }
158 }
159 return tensorflow::Status::OK();
160}
161
162} // namespace tensorflow

Callers 3

TESTFunction · 0.85
CalculateOutputSizeMethod · 0.85

Calls 7

InvalidArgumentFunction · 0.85
unknown_rankMethod · 0.80
minFunction · 0.50
dim_sizeMethod · 0.45
DebugStringMethod · 0.45
sizeMethod · 0.45
dimMethod · 0.45

Tested by 1

TESTFunction · 0.68