| 229 | } |
| 230 | |
| 231 | TensorLayout TensorLayout::dimshuffle(const std::vector<size_t>& dims) const { |
| 232 | TensorLayout res{dtype, format}; |
| 233 | res.ndim = this->ndim; |
| 234 | megdnn_assert_eq_size_t(dims.size(), this->ndim); |
| 235 | auto ndim = this->ndim; |
| 236 | rep(i, ndim) { |
| 237 | auto dest = dims[i]; |
| 238 | megdnn_assert(dest < ndim); |
| 239 | res.shape[i] = this->shape[dest]; |
| 240 | res.stride[i] = this->stride[dest]; |
| 241 | } |
| 242 | return res; |
| 243 | } |
| 244 | |
| 245 | TensorLayout TensorLayout::remove_axis(size_t idx) const { |
| 246 | TensorLayout res{*this}; |