| 29 | |
| 30 | template <DataType DT> |
| 31 | Status HandleSliceToElement(const Tensor& parent, Tensor* element, |
| 32 | int64 index) { |
| 33 | typedef typename EnumToDataType<DT>::Type T; |
| 34 | DCHECK_NE(parent.dim_size(0), 0); |
| 35 | DCHECK_GE(index, 0); |
| 36 | if (element->NumElements() != (parent.NumElements() / parent.dim_size(0))) { |
| 37 | TensorShape chip_shape = parent.shape(); |
| 38 | chip_shape.RemoveDim(0); |
| 39 | return errors::Internal( |
| 40 | "HandleSliceToElement Cannot copy slice: number of elements does not " |
| 41 | "match. Shapes are: [element]: ", |
| 42 | element->shape().DebugString(), |
| 43 | ", [parent slice]: ", chip_shape.DebugString()); |
| 44 | } |
| 45 | auto parent_as_matrix = parent.flat_outer_dims<T>(); |
| 46 | element->flat<T>() = parent_as_matrix.chip(index, 0); |
| 47 | return Status::OK(); |
| 48 | } |
| 49 | |
| 50 | } // namespace |
| 51 |
nothing calls this directly
no test coverage detected