| 327 | } |
| 328 | |
| 329 | std::vector<int64> BatchDescriptor::full_strides( |
| 330 | const DataLayout& layout) const { |
| 331 | if (this->layout() == DataLayout::kBatchDepthYX4) { |
| 332 | LOG(FATAL) |
| 333 | << "Cannot compute full strides for batch descriptor " << ToString() |
| 334 | << ", because its layout is kBatchDepthYX4. In fact, " |
| 335 | "cudnnSetTensorNdDescriptor doesn't work for kBatchDepthYX4 at all. " |
| 336 | "Use cudnnSetTensor4DDescriptor to set cudnnTensorDescriptor_t " |
| 337 | "instead."; |
| 338 | } |
| 339 | std::vector<int64> phys_dims = full_dims(this->layout()); |
| 340 | std::vector<int64> phys_strides(phys_dims.size()); |
| 341 | phys_strides[ndims() + 1] = 1; |
| 342 | for (int i = ndims(); i >= 0; i--) { |
| 343 | phys_strides[i] = phys_strides[i + 1] * phys_dims[i + 1]; |
| 344 | } |
| 345 | return ReorderDims(phys_strides, this->layout(), layout); |
| 346 | } |
| 347 | |
| 348 | void BatchDescriptor::CloneFrom(const BatchDescriptor& other) { |
| 349 | tensor_ = other.tensor_; |
no test coverage detected