Skip to content

Commit

Permalink
Cleanup assertion logic (#14510)
Browse files Browse the repository at this point in the history
Explicitly separate assertion check vs. messages
  • Loading branch information
hcindyl authored Jul 29, 2023
1 parent 268b6de commit cc3e5f3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 2 additions & 4 deletions compiler/src/iree/compiler/Codegen/LLVMCPU/KernelDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,8 @@ static SmallVector<int64_t> getDefaultDistributedLevelTileSizes(
int64_t numLoops = lbs.size();
assert(numLoops == minTileSizes.size() && maxTileSizes.size() == numLoops &&
"expected as many min/max tile sizes as number of loops");
assert(
vectorSizeHints.empty() ||
vectorSizeHints.size() == numLoops &&
"vector size hints should be empty or equal to the number of loops");
assert((vectorSizeHints.empty() || vectorSizeHints.size() == numLoops) &&
"vector size hints should be empty or equal to the number of loops");

// Only set values when the loop is partitionable.
SmallVector<int64_t> adjustedMinTileSizes(numLoops, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int64_t mlir::iree_compiler::gpu::scaleUpByBitWidth(int64_t value,
int64_t mlir::iree_compiler::gpu::adjustNumberOfWarpsForBlockShuffle(
int64_t numWarpsToUse, int64_t bitWidth) {
// Try to scale down the number of warps to use 32b elements in warp shuffles.
assert((bitWidth & bitWidth - 1) == 0 && "bitWidth must be a power of 2");
assert(((bitWidth & (bitWidth - 1)) == 0) && "bitWidth must be a power of 2");
int64_t factor;
for (factor = scaleUpByBitWidth(1, bitWidth); factor > 1; factor >>= 1)
if (numWarpsToUse % factor == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ LogicalResult HALConversionTarget::applyDefaultBufferRewrite(
// Check that any type that should have been mapped to buffer view was.
// This is just to catch conflicts in type conversions that may sneak in
// during development.
assert(!HALTypeConverter::shouldConvertToBufferView(srcOperand.getType()) ||
dstOperand.getType().isa<IREE::HAL::BufferViewType>() &&
"expect that tensors have been mapped to buffer views");
assert(
(!HALTypeConverter::shouldConvertToBufferView(srcOperand.getType()) ||
dstOperand.getType().isa<IREE::HAL::BufferViewType>()) &&
"expect that tensors have been mapped to buffer views");
state.addOperands({dstOperand});
}
for (auto resultType : srcOp->getResultTypes()) {
Expand Down

0 comments on commit cc3e5f3

Please sign in to comment.