releaase 2.11 (#703)

This commit is contained in:
Aditya Atluri
2022-11-19 06:02:15 -08:00
committed by GitHub
parent 3c90f6aea6
commit c975e2ccbb
329 changed files with 47332 additions and 10607 deletions

View File

@@ -42,6 +42,7 @@
namespace cutlass {
// uncompress sparse tensor core A matrix
template <typename ElementA, typename LayoutA, typename ElementE,
typename LayoutE>
void uncompress(TensorRef<ElementA, LayoutA> uncompressed_tensor_a,
@@ -119,5 +120,38 @@ void uncompress(TensorRef<ElementA, LayoutA> uncompressed_tensor_a,
}
}
}
// uncompress ELL block sparse matrix
template <typename ElementA, typename LayoutA,
typename ElementE, typename LayoutE>
void uncompress_ell_block_sparse(
TensorRef<ElementA, LayoutA> uncompressed_tensor_a,
TensorRef<ElementA, LayoutA> tensor_a,
TensorRef<ElementE, LayoutE> ell_idx,
int rows, int cols,
int ell_num_cols, int ell_blocksize) {
for (int r = 0; r < rows / ell_blocksize; ++r) {
for (int c = 0; c < ell_num_cols / ell_blocksize; ++c) {
ElementE idx = ell_idx.at(MatrixCoord(r, c));
if (idx != -1) {
int row_begin = r * ell_blocksize;
int col_begin_real = idx * ell_blocksize;
int col_begin = c * ell_blocksize;
for (int i = 0; i < ell_blocksize; ++i) {
for (int j = 0; j < ell_blocksize; ++j) {
uncompressed_tensor_a.at(MatrixCoord(row_begin + i, col_begin_real + j)) =
tensor_a.at(
MatrixCoord(row_begin + i, col_begin +j));
}
}
}
}
}
}
} // namespace cutlass

View File

@@ -68,8 +68,8 @@ struct TensorFuncBinaryOp {
/// View of left-hand-side tensor
TensorView<ElementD, LayoutD> view_d;
TensorRef<ElementA, LayoutA> ref_a;
TensorRef<ElementB, LayoutB> ref_b;
TensorRef<ElementA, LayoutA> view_a;
TensorRef<ElementB, LayoutB> view_b;
BinaryFunc func;
//
@@ -82,8 +82,8 @@ struct TensorFuncBinaryOp {
/// Constructor
TensorFuncBinaryOp(
TensorView<ElementD, LayoutD> const & view_d_,
TensorRef<ElementA, LayoutA> const & ref_a_,
TensorRef<ElementB, LayoutB> const & ref_b_,
TensorRef<ElementA, LayoutA> const & view_a_,
TensorRef<ElementB, LayoutB> const & view_b_,
BinaryFunc func = BinaryFunc()
):
view_d(view_d_), view_a(view_a_), view_b(view_b_), func(func) { }
@@ -284,7 +284,7 @@ void TensorDiv(
TensorView<ElementD, LayoutD> d, ///< destination tensor view
TensorRef<ElementA, LayoutA> a ///< A tensor reference
) {
TensorMul(d, d, a);
TensorDiv(d, d, a);
}
@@ -312,7 +312,7 @@ void TensorModulus(
LayoutA,
ElementB,
LayoutB,
cutlass::modulus<ElementD>
cutlass::divides<ElementD>
> func(d, a, b);
TensorForEach(
@@ -331,7 +331,7 @@ void TensorModulus(
TensorView<ElementD, LayoutD> d, ///< destination tensor view
TensorRef<ElementA, LayoutA> a ///< A tensor reference
) {
TensorMul(d, d, a);
TensorDiv(d, d, a);
}
///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -1272,7 +1272,7 @@ template <typename Element>
struct RandomSparseMetaFunc {
uint64_t seed;
double range;
int range;
int MetaSizeInBits;
//
@@ -1302,9 +1302,8 @@ struct RandomSparseMetaFunc {
Element result = 0x0;
for (int i = 0; i < cutlass::sizeof_bits<Element>::value / 4; ++i) {
double rnd = double(std::rand()) / double(RAND_MAX);
rnd = range * rnd;
Element meta = MetaArray[(int)rnd];
int rnd = std::rand() % range;
Element meta = MetaArray[rnd];
result = (Element)(result | ((Element)(meta << (i * 4))));
}
@@ -1393,6 +1392,37 @@ void BlockFillRandomSparseMeta(
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
/// Fills a ell block index matrix with random values with a uniform random distribution.
template <
typename Element, ///< Element type
typename Layout> ///< Layout function
void TensorFillRandomEllIdx(
TensorView<Element, Layout> dst, ///< destination tensor
uint64_t seed, ///< seed for RNG
int rows, int ell_cols, int cols) { ///< dimension of the matrix
std::srand((unsigned)seed);
for (int i = 0; i < rows; ++i) {
int col_idx = std::rand() % cols;
for (int j = 0; j < ell_cols; ++j) {
dst.at({i, j}) = col_idx;
if (col_idx != -1) {
if (col_idx == (cols - 1)) {
col_idx = -1;
} else {
col_idx = std::rand() % (cols - col_idx - 1) + col_idx + 1;
}
}
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/// Copies a diagonal in from host memory without modifying off-diagonal elements.