forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Adding tuned apple M1 Config for spirv kernels Co-authored-by: nodlabs <nodlabs@mini0.local>
- Loading branch information
1 parent
7b1e7c1
commit bb456f5
Showing
5 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2021 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 | ||
|
||
//===- AppleConfig.h - Apple CodeGen Configurations ---------------------===// | ||
// | ||
// This file contains CodeGen configurations for Apple M1 GPUs. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <array> | ||
|
||
#include "iree/compiler/Codegen/SPIRV/KernelConfig.h" | ||
#include "llvm/ADT/TypeSwitch.h" | ||
#include "mlir/Dialect/Linalg/IR/Linalg.h" | ||
#include "mlir/IR/BuiltinOps.h" | ||
|
||
namespace mlir { | ||
namespace iree_compiler { | ||
namespace detail { | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Entry Point | ||
//===----------------------------------------------------------------------===// | ||
|
||
LogicalResult setAppleCodeGenConfig(const spirv::TargetEnv &targetEnv, | ||
Operation *rootOp) { | ||
int64_t subgroupSize = targetEnv.getResourceLimits().subgroup_size().getInt(); | ||
return TypeSwitch<Operation *, LogicalResult>(rootOp) | ||
.Case<linalg::BatchMatmulOp, linalg::MatmulOp>([subgroupSize](auto op) { | ||
std::array<int64_t, 2> workgroupXY = {256, 1}; | ||
std::array<int64_t, 3> threadMNK = {4, 4, 4}; | ||
return setMatmulOpConfig(op, subgroupSize, workgroupXY, threadMNK); | ||
}) | ||
.Case<linalg::Conv2DNhwcHwcfOp>([subgroupSize](auto op) { | ||
return setConvOpConfig(op, subgroupSize, | ||
/*bestTilingFactor=*/16); | ||
}) | ||
.Case<linalg::DepthwiseConv2DNhwcHwcOp>([subgroupSize](auto op) { | ||
return setConvOpConfig(op, subgroupSize, | ||
/*bestTilingFactor=*/16); | ||
}) | ||
.Default([](Operation *) { return success(); }); | ||
} | ||
|
||
} // namespace detail | ||
} // namespace iree_compiler | ||
} // namespace mlir |
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