Record and validate the label to dimension mapping. Must be a named (non-broadcasting) label as broadcasting labels don't have a fixed dimension.
| 189 | // Record and validate the label to dimension mapping. Must be a named |
| 190 | // (non-broadcasting) label as broadcasting labels don't have a fixed dimension. |
| 191 | Status RecordLabelToDimension(const int label, const int axis, |
| 192 | const Tensor& input, |
| 193 | LabelToDimSizes* label_to_dim_sizes) { |
| 194 | const int64 input_dim = input.dim_size(axis); |
| 195 | // We know that label_to_dim_sizes has the size to accommodate named labels. |
| 196 | if (label_to_dim_sizes->at(label) != 0 && |
| 197 | label_to_dim_sizes->at(label) != input_dim) { |
| 198 | return errors::InvalidArgument( |
| 199 | "Expected dimension ", label_to_dim_sizes->at(label), " at axis ", axis, |
| 200 | " of the input shaped ", input.shape().DebugString(), |
| 201 | " but got dimension ", input_dim); |
| 202 | } |
| 203 | (*label_to_dim_sizes)[label] = input_dim; |
| 204 | return Status::OK(); |
| 205 | } |
| 206 | |
| 207 | // Validate input dimensions and populate unnamed labels and their label counts. |
| 208 | Status ProcessDimensions(const OpInputList& inputs, |
no test coverage detected