-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support default configs for BATCH_MATMUL_* in MaterializeEncoding pass (
- Loading branch information
Jerry Wu
authored
Aug 24, 2023
1 parent
b0c77fa
commit 8314b5c
Showing
12 changed files
with
227 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...rnal-projects/iree-dialects/include/iree-dialects/Dialect/LinalgExt/Utils/EncodingUtils.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2023 The IREE Authors | ||
// | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#ifndef IREE_DIALECTS_DIALECT_LINALGEXT_UTILS_ENCODING_UTILS_H_ | ||
#define IREE_DIALECTS_DIALECT_LINALGEXT_UTILS_ENCODING_UTILS_H_ | ||
|
||
#include "iree-dialects/Dialect/LinalgExt/IR/LinalgExtOps.h" | ||
#include "iree-dialects/Dialect/LinalgExt/Utils/Utils.h" | ||
|
||
namespace mlir { | ||
namespace iree_compiler { | ||
namespace IREE { | ||
namespace LinalgExt { | ||
|
||
struct MatmulTileParams { | ||
int64_t M = 1; | ||
int64_t K = 1; | ||
int64_t N = 1; | ||
}; | ||
|
||
MaterializeEncodingInfo | ||
chooseEncodingInfoForMatmul(EncodingUser user, EncodingRole role, | ||
MatmulTileParams tileParams); | ||
|
||
} // namespace LinalgExt | ||
} // namespace IREE | ||
} // namespace iree_compiler | ||
} // namespace mlir | ||
|
||
#endif // IREE_DIALECTS_DIALECT_LINALGEXT_UTILS_ENCODING_UTILS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
llvm-external-projects/iree-dialects/lib/Dialect/LinalgExt/Utils/EncodingUtils.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2023 The IREE Authors | ||
// | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include "iree-dialects/Dialect/LinalgExt/Utils/EncodingUtils.h" | ||
|
||
namespace mlir { | ||
namespace iree_compiler { | ||
namespace IREE { | ||
namespace LinalgExt { | ||
|
||
MaterializeEncodingInfo | ||
chooseEncodingInfoForMatmul(EncodingUser user, EncodingRole role, | ||
MatmulTileParams tileParams) { | ||
// Start dim of the MxK (LHS), KxN (RHS), or MxN (RESULT) 2D matrix. | ||
int64_t matmulDimBase = 0; | ||
switch (user) { | ||
case EncodingUser::BATCH_MATMUL_F32F32F32: | ||
case EncodingUser::BATCH_MATMUL_F16F16F32: | ||
case EncodingUser::BATCH_MATMUL_F16F16F16: | ||
case EncodingUser::BATCH_MATMUL_BF16BF16F32: | ||
case EncodingUser::BATCH_MATMUL_BF16BF16BF16: | ||
case EncodingUser::BATCH_MATMUL_I8I8I32: | ||
matmulDimBase = 1; | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
MaterializeEncodingInfo encodingInfo; | ||
encodingInfo.innerDimsPos = {matmulDimBase, matmulDimBase + 1}; | ||
switch (role) { | ||
case (EncodingRole::LHS): { | ||
encodingInfo.innerTileSizes = {tileParams.M, tileParams.K}; | ||
break; | ||
} | ||
case (EncodingRole::RHS): { | ||
encodingInfo.innerTileSizes = {tileParams.N, tileParams.K}; | ||
encodingInfo.innerDimsPos = {matmulDimBase + 1, matmulDimBase}; | ||
encodingInfo.outerDimsPerm = | ||
llvm::to_vector(llvm::seq<int64_t>(0, matmulDimBase)); | ||
encodingInfo.outerDimsPerm.push_back(matmulDimBase + 1); | ||
encodingInfo.outerDimsPerm.push_back(matmulDimBase); | ||
break; | ||
} | ||
case (EncodingRole::RESULT): { | ||
encodingInfo.innerTileSizes = {tileParams.M, tileParams.N}; | ||
break; | ||
} | ||
default: { | ||
assert(false); | ||
return {}; | ||
} | ||
} | ||
return encodingInfo; | ||
} | ||
|
||
} // namespace LinalgExt | ||
} // namespace IREE | ||
} // namespace iree_compiler | ||
} // namespace mlir |
Oops, something went wrong.