tensorflow/lite/experimental/ruy/pack_sse42.cc
// TODO(b/147376783): SSE 4.2 and AVX-VNNI support is incomplete / placeholder.
// Optimization is not finished. In particular the dimensions of the kernel
// blocks can be changed as desired.
//
// When removing this comment, update profiling label below.


When removing this comment, update profiling label below.
When removing this comment update profiling label below .
void Pack8bitSse42(const std::int8_t* src_ptr, std::int8_t input_xor,
                   const std::int8_t* zerobuf, int src_stride,
                   int remaining_src_cols, int src_rows,
                   std::int8_t* packed_ptr, std::int32_t* sums_ptr) {
  profiler::ScopeLabel label("Pack kSse42 8bit (UNFINISHED)");
  using Layout = PackImpl8bitSse42::Layout;
  RUY_DCHECK_EQ(Layout::kCols, 8);
  RUY_DCHECK_EQ(Layout::kRows, 4);
  static constexpr int kNumRowChunks = 8;  
  constexpr int kTrailingBufSize =
      kNumRowChunks * Layout::kCols * Layout::kRows;
  std::int8_t trailing_buf[kTrailingBufSize];
  memset(trailing_buf, 0, kTrailingBufSize * sizeof(std::int8_t));
  Pack8bitSse42Packer(src_ptr, input_xor, zerobuf, src_stride,
                      remaining_src_cols, src_rows, packed_ptr, sums_ptr,
                      trailing_buf);
  constexpr int kChunkedRowMask = kNumRowChunks * Layout::kRows - 1;
  const bool trailing_data = (src_rows & kChunkedRowMask) > 0;
  if (trailing_data > 0) {
    const int non_trailing_rows = src_rows & ~kChunkedRowMask;
    const int dst_rows = (src_rows + 3) & ~3;
    const int trailing_rows = dst_rows - non_trailing_rows;
    memcpy(packed_ptr + Layout::kCols * non_trailing_rows, trailing_buf,
           Layout::kCols * trailing_rows * sizeof(std::int8_t));
  }
}
void Pack8bitSse42 ( const std :: int8_t * src_ptr , std :: int8_t input_xor , const std :: int8_t * zerobuf , int src_stride , int remaining_src_cols , int src_rows , std :: int8_t * packed_ptr , std :: int32_t * sums_ptr ) { profiler :: ScopeLabel label ( " " ) ; using Layout = PackImpl8bitSse42 :: Layout ; RUY_DCHECK_EQ ( Layout :: kCols , 8 ) ; RUY_DCHECK_EQ ( Layout :: kRows , 4 ) ; static constexpr int kNumRowChunks = 8 ; constexpr int kTrailingBufSize = kNumRowChunks * Layout :: kCols * Layout :: kRows ; std :: int8_t trailing_buf [ kTrailingBufSize ] ; memset ( trailing_buf , 0 , kTrailingBufSize * sizeof ( std :: int8_t ) ) ; Pack8bitSse42Packer ( src_ptr , input_xor , zerobuf , src_stride , remaining_src_cols , src_rows , packed_ptr , sums_ptr , trailing_buf ) ; constexpr int kChunkedRowMask = kNumRowChunks * Layout :: kRows - 1 ; const bool trailing_data = ( src_rows & kChunkedRowMask ) > 0 ; if ( trailing_data > 0 ) { const int non_trailing_rows = src_rows & ~ kChunkedRowMask ; const int dst_rows = ( src_rows + 3 ) & ~ 3 ; const int trailing_rows = dst_rows - non_trailing_rows ; memcpy ( packed_ptr + Layout :: kCols * non_trailing_rows , trailing_buf , Layout :: kCols * trailing_rows * sizeof ( std :: int8_t ) ) ; } }
TODO(b/147376783): SSE 4.2 and AVX-VNNI support is incomplete / placeholder.
TODO ( b / 147376783 ) : SSE 4 . 2 and AVX - VNNI support is incomplete / placeholder .
// Each Layout::Rows is 4 contiguous input, contiguous packed elements. // We process 8 of these chunks at a time, padding short input chunks. // Short input is padded. // Each packed block is 4*8, and there are normally 8. The trailing block is // only slightly shorter. // If the number of source rows is not a multiple of kChunkedRowMask, there // will be data in the trailing buffer, // Destination "rows" are padded to next highest multiple of Layout::kRows.