|
46 | 46 | #include <ATen/ops/empty_like.h> |
47 | 47 | #include <ATen/ops/empty_like_native.h> |
48 | 48 | #include <ATen/ops/empty_native.h> |
49 | | -#include <ATen/ops/empty_permuted_native.h> |
50 | 49 | #include <ATen/ops/empty_strided.h> |
51 | 50 | #include <ATen/ops/empty_strided_native.h> |
52 | 51 | #include <ATen/ops/eye.h> |
@@ -279,45 +278,6 @@ Tensor empty_names( |
279 | 278 | return result; |
280 | 279 | } |
281 | 280 |
|
282 | | -Tensor empty_permuted_symint(SymIntArrayRef size, IntArrayRef physical_layout, c10::optional<ScalarType> dtype_opt, |
283 | | - c10::optional<Layout> layout_opt, c10::optional<Device> device_opt, c10::optional<bool> pin_memory_opt |
284 | | -) { |
285 | | - // size is logical; aka, the output size you'll get from the operation overall |
286 | | - // |
287 | | - // physical_layout follows NCHW/NHWC convention: |
288 | | - // contiguous is [0,1,2,3], channels last is [0,2,3,1] |
289 | | - // |
290 | | - // this means if i is physical index, physical_layout[i] is logical index; |
291 | | - // e.g., to find what is innermost physical dim (3), query NHWC[3] == 1 |
292 | | - // (aka it is channels) |
293 | | - int64_t dim = static_cast<int64_t>(size.size()); |
294 | | - SymDimVector phys_size(dim); |
295 | | - TORCH_CHECK(physical_layout.size() == dim, |
296 | | - "Number of dimensions in size does not match the " |
297 | | - "length of the physical_layout; i.e. len(size) = ", dim, |
298 | | - " is not equal to len(physical_layout) = ", physical_layout.size()); |
299 | | - std::vector<bool> seen_dims(dim); |
300 | | - for (const auto i : c10::irange(dim)) { |
301 | | - TORCH_CHECK(physical_layout[i] >= 0 && physical_layout[i] < dim, |
302 | | - "Dimension out of range (expected to be between 0 and ", dim - 1, ", but got ", |
303 | | - physical_layout[i], " at index ", i, "). NB: negative dims " |
304 | | - "not currently supported; file an issue if you want it."); |
305 | | - TORCH_CHECK(!seen_dims[physical_layout[i]], "Duplicate dim not allowed"); |
306 | | - phys_size[i] = size[physical_layout[i]]; |
307 | | - seen_dims[physical_layout[i]] = true; |
308 | | - } |
309 | | - // do a contiguous allocation |
310 | | - Tensor phys_tensor = at::empty_symint(phys_size, dtype_opt, layout_opt, device_opt, pin_memory_opt, c10::nullopt); |
311 | | - SymIntArrayRef phys_strides = phys_tensor.sym_strides(); |
312 | | - // permute the strides (inverse permutation! This is why this is |
313 | | - // empty_permute*d*, not empty_permute; it's not an empty + permute) |
314 | | - SymDimVector strides(dim); |
315 | | - for (const auto i : c10::irange(dim)) { |
316 | | - strides[physical_layout[i]] = phys_strides[i]; |
317 | | - } |
318 | | - return phys_tensor.as_strided_symint(size, strides); |
319 | | -} |
320 | | - |
321 | 281 | Tensor empty_strided_cpu(IntArrayRef size, IntArrayRef stride, c10::optional<ScalarType> dtype_opt, |
322 | 282 | c10::optional<Layout> layout_opt, c10::optional<Device> device_opt, c10::optional<bool> pin_memory_opt) { |
323 | 283 | return at::detail::empty_strided_cpu(size, stride, dtype_opt, layout_opt, device_opt, pin_memory_opt); |
|
0 commit comments