| 31 | |
| 32 | template <typename Index> |
| 33 | Status CheckInvalidLabelIndex(const Tensor& labels, int64 max_index) { |
| 34 | if (labels.NumElements() == 0) return Status::OK(); |
| 35 | const auto label_values = labels.vec<Index>(); |
| 36 | int64 bad_index; |
| 37 | auto min_max_dim_value = std::minmax_element( |
| 38 | label_values.data(), label_values.data() + label_values.size()); |
| 39 | if (*min_max_dim_value.first < 0 || *min_max_dim_value.second >= max_index) { |
| 40 | bad_index = (*min_max_dim_value.first < 0) ? *min_max_dim_value.first |
| 41 | : *min_max_dim_value.second; |
| 42 | return errors::InvalidArgument( |
| 43 | "Received a label value of ", bad_index, |
| 44 | " which is outside the valid range of [0, ", max_index, |
| 45 | "). Label values: ", labels.SummarizeValue(labels.NumElements())); |
| 46 | } |
| 47 | return Status::OK(); |
| 48 | } |
| 49 | |
| 50 | template <typename Device, typename T, typename Index> |
| 51 | class SparseSoftmaxXentWithLogitsOp : public OpKernel { |
nothing calls this directly
no test coverage detected