| 10 | #include "spatial_cuda_layers.h" |
| 11 | |
| 12 | ChannelsLastProblem dimension_problem(at::Tensor& input) |
| 13 | { |
| 14 | ChannelsLastProblem dims; |
| 15 | |
| 16 | if (input.dim() == 4) { |
| 17 | // In some sense this is unsafe (and a reflection of the assumptions made inside |
| 18 | // the C10 options checker). Basically, there's no great way to be sure that |
| 19 | // a tensor is in channels last because a 1x1 image will appear to be in channels |
| 20 | // last even when it isn't. |
| 21 | assert(input.is_contiguous(at::MemoryFormat::ChannelsLast)); |
| 22 | dims.batch_size = input.size(0); |
| 23 | dims.seq_len = input.size(2) * input.size(3); |
| 24 | dims.channels = input.size(1); |
| 25 | } else { |
| 26 | assert(input.is_contiguous()); |
| 27 | dims.batch_size = input.size(0); |
| 28 | dims.seq_len = input.size(1); |
| 29 | dims.channels = input.size(2); |
| 30 | } |
| 31 | |
| 32 | return dims; |
| 33 | } |
| 34 | |
| 35 | at::Tensor seq_unroll_bias_add(at::Tensor& input, at::Tensor& bias) |
| 36 | { |
no test coverage detected