Skip to content

Commit

Permalink
Actually make MobileBERT run in the test. (#5264)
Browse files Browse the repository at this point in the history
Previously added MobileBERT test was only compiling the model, but not
running it due to `iree.symbol.export` not being set on the
function.

Fixing that leads to the issue of too many descriptors being used
(Issue #5152). For now
- drop `noinline` from some constants in the test file
- add a flag to increase the size at which constants are inlined into
  the dispatch region
  • Loading branch information
MaheshRavishankar authored Mar 31, 2021
1 parent 2e05313 commit 1bdc3a4
Show file tree
Hide file tree
Showing 4 changed files with 763 additions and 751 deletions.
10 changes: 9 additions & 1 deletion iree/compiler/Dialect/Flow/IR/FlowOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "iree/compiler/Dialect/Shape/IR/Builders.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CommandLine.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BlockAndValueMapping.h"
Expand All @@ -33,6 +34,12 @@
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/RegionUtils.h"

static llvm::cl::opt<int> clInlineConstantByteLength(
"iree-flow-inline-constants-max-byte-length",
llvm::cl::desc("Maximum byte-length of constant that can be inlined into a "
"dispatch region"),
llvm::cl::init(256));

namespace mlir {
namespace iree_compiler {
namespace IREE {
Expand Down Expand Up @@ -831,7 +838,8 @@ static bool canDispatchRegionContainOp(Operation *op) {
uint64_t estimatedByteLength =
(shapedType.getNumElements() * shapedType.getElementTypeBitWidth()) /
8;
return denseAttr.isSplat() || estimatedByteLength <= 256; // or whatever
return denseAttr.isSplat() ||
estimatedByteLength <= clInlineConstantByteLength;
} else if (constantType.isIntOrIndexOrFloat()) {
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions iree/test/e2e/models/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ iree_check_single_backend_test_suite(
srcs = CHECK_FRAMEWORK_TESTS,
compiler_flags = [
"-iree-flow-dispatch-linalg-on-tensors",
"-iree-flow-inline-constants-max-byte-length=2048",
"-iree-codegen-spirv-experimental-linalg-on-tensors",
"-iree-spirv-enable-vectorization",
],
Expand All @@ -80,6 +81,7 @@ iree_check_single_backend_test_suite(
srcs = CHECK_FRAMEWORK_TESTS,
compiler_flags = [
"-iree-flow-dispatch-linalg-on-tensors",
"-iree-flow-inline-constants-max-byte-length=2048",
"-iree-codegen-llvm-experimental-linalg-on-tensors",
],
driver = "dylib",
Expand Down
2 changes: 2 additions & 0 deletions iree/test/e2e/models/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ iree_check_single_backend_test_suite(
"vulkan"
COMPILER_FLAGS
"-iree-flow-dispatch-linalg-on-tensors"
"-iree-flow-inline-constants-max-byte-length=2048"
"-iree-codegen-spirv-experimental-linalg-on-tensors"
"-iree-spirv-enable-vectorization"
)
Expand All @@ -69,6 +70,7 @@ iree_check_single_backend_test_suite(
"dylib"
COMPILER_FLAGS
"-iree-flow-dispatch-linalg-on-tensors"
"-iree-flow-inline-constants-max-byte-length=2048"
"-iree-codegen-llvm-experimental-linalg-on-tensors"
)

Expand Down
Loading

0 comments on commit 1bdc3a4

Please sign in to comment.