| 97 | } |
| 98 | |
| 99 | string SliceDebugString(const TensorShape& shape, const int64 flat) { |
| 100 | // Special case rank 0 and 1 |
| 101 | const int dims = shape.dims(); |
| 102 | if (dims == 0) return ""; |
| 103 | if (dims == 1) return strings::StrCat("[", flat, "]"); |
| 104 | |
| 105 | // Compute strides |
| 106 | gtl::InlinedVector<int64, 32> strides(dims); |
| 107 | strides.back() = 1; |
| 108 | for (int i = dims - 2; i >= 0; i--) { |
| 109 | strides[i] = strides[i + 1] * shape.dim_size(i + 1); |
| 110 | } |
| 111 | |
| 112 | // Unflatten index |
| 113 | int64 left = flat; |
| 114 | string result; |
| 115 | for (int i = 0; i < dims; i++) { |
| 116 | strings::StrAppend(&result, i ? "," : "[", left / strides[i]); |
| 117 | left %= strides[i]; |
| 118 | } |
| 119 | strings::StrAppend(&result, "]"); |
| 120 | return result; |
| 121 | } |
| 122 | |
| 123 | #ifdef INTEL_MKL |
| 124 | bool DisableMKL() { |
no test coverage detected