torch/csrc/jit/fusion_compiler.cpp
// Tries to compress sizes and strides according to cont. Emits the result t
// c_sizes, c_strides and throws an error on failure (if can't compress)
Tries to compress sizes and strides according to cont. Emits the result t
c_sizes, c_strides and throws an error on failure (if can't compress)
Tries to compress sizes and strides according to cont . Emits the result t c_sizes c_strides and throws an error on failure ( if can ' t compress )
void compressContiguous(
    at::IntList sizes,
    at::IntList strides,
    const std::vector<bool> & cont,
    uint32_t * c_sizes,
    uint32_t * c_strides) {
  size_t compressed_dims = 0;
  size_t cur = 0;
  size_t ndim = sizes.size();
  while(cur < ndim) {
    size_t total_size = sizes[cur];
    cur++;
    while(cont[cur-1] && cur < ndim) {
      JIT_ASSERT(strides[cur-1] == sizes[cur]*strides[cur]);
      total_size *= sizes[cur];
      cur++;
    }
    c_sizes[compressed_dims] = total_size;
    c_strides[compressed_dims] = strides[cur-1];
    compressed_dims++;
  }
  JIT_ASSERT(!cont.back() || strides.back() == 1);
}
void compressContiguous ( at :: IntList sizes , at :: IntList strides , const std :: vector < bool > & cont , uint32_t * c_sizes , uint32_t * c_strides ) { size_t compressed_dims = 0 ; size_t cur = 0 ; size_t ndim = sizes . size ( ) ; while ( cur < ndim ) { size_t total_size = sizes [ cur ] ; cur ++ ; while ( cont [ cur - 1 ] && cur < ndim ) { JIT_ASSERT ( strides [ cur - 1 ] == sizes [ cur ] * strides [ cur ] ) ; total_size *= sizes [ cur ] ; cur ++ ; } c_sizes [ compressed_dims ] = total_size ; c_strides [ compressed_dims ] = strides [ cur - 1 ] ; compressed_dims ++ ; } JIT_ASSERT ( ! cont . back ( ) || strides . back ( ) == 1 ) ; }
Tries to compress sizes and strides according to cont.
Tries to compress sizes and strides according to cont .
// cur starts pointing at the beginning of run to compress // cur ends one _after_ the terminating false or end of list. // total_size is the size of all dimensions [begin,end) // examples: // f = not cont. // t = cont. // x = don't care, including past end of list // s = start of cur // e = end of cur // f x x x // s e //  t f x x //  s   e //  t t f x //  s     e