cleanup unused channel operations and related logic
Validate Operations / validate-operations (push) Has been cancelled
Validate Operations / validate-operations (push) Has been cancelled
This commit is contained in:
@@ -150,13 +150,7 @@ static bool isSupportedCoreInstructionOp(Operation* op) {
|
||||
pim::PimMemCopyDevToHostOp,
|
||||
pim::PimMemCopyOp,
|
||||
pim::PimReceiveOp,
|
||||
pim::PimReceiveBatchOp,
|
||||
pim::PimReceiveTensorOp,
|
||||
pim::PimReceiveTensorBatchOp,
|
||||
pim::PimSendOp,
|
||||
pim::PimSendBatchOp,
|
||||
pim::PimSendTensorOp,
|
||||
pim::PimSendTensorBatchOp,
|
||||
pim::PimConcatOp,
|
||||
pim::PimVMMOp,
|
||||
pim::PimTransposeOp,
|
||||
@@ -173,18 +167,6 @@ static bool isSupportedCoreInstructionOp(Operation* op) {
|
||||
memref::GetGlobalOp>(op);
|
||||
}
|
||||
|
||||
static FailureOr<ShapedType> getStaticByteSizedShapedType(Type type) {
|
||||
auto shapedType = dyn_cast<ShapedType>(type);
|
||||
if (!shapedType || !shapedType.hasStaticShape())
|
||||
return failure();
|
||||
|
||||
int64_t elementBits = shapedType.getElementTypeBitWidth();
|
||||
if (elementBits <= 0 || elementBits % 8 != 0)
|
||||
return failure();
|
||||
|
||||
return shapedType;
|
||||
}
|
||||
|
||||
static LogicalResult verifyBatchOpSemantics(Operation& op,
|
||||
const StaticValueKnowledge& knowledge,
|
||||
pim::CappedDiagnosticReporter& diagnostics) {
|
||||
@@ -203,73 +185,6 @@ static LogicalResult verifyBatchOpSemantics(Operation& op,
|
||||
return success(!hasFailure);
|
||||
}
|
||||
|
||||
if (auto sendBatchOp = dyn_cast<pim::PimSendBatchOp>(op)) {
|
||||
if (sendBatchOp.getTargetCoreIds().size() != static_cast<size_t>(sendBatchOp->getParentOfType<pim::PimCoreBatchOp>()
|
||||
.getLaneCount())) {
|
||||
reportFailure([](Operation* illegalOp) {
|
||||
illegalOp->emitOpError("targetCoreIds size must match parent laneCount");
|
||||
});
|
||||
}
|
||||
return success(!hasFailure);
|
||||
}
|
||||
|
||||
if (auto receiveBatchOp = dyn_cast<pim::PimReceiveBatchOp>(op)) {
|
||||
if (receiveBatchOp.getSourceCoreIds().size()
|
||||
!= static_cast<size_t>(receiveBatchOp->getParentOfType<pim::PimCoreBatchOp>().getLaneCount())) {
|
||||
reportFailure([](Operation* illegalOp) {
|
||||
illegalOp->emitOpError("sourceCoreIds size must match parent laneCount");
|
||||
});
|
||||
}
|
||||
return success(!hasFailure);
|
||||
}
|
||||
|
||||
auto verifyTensorBatchCommunication = [&](Value tensorValue, ArrayRef<int32_t> coreIds, StringRef kind) {
|
||||
if (coreIds.empty()) {
|
||||
reportFailure([&](Operation* illegalOp) { illegalOp->emitOpError() << kind << " must carry at least one chunk"; });
|
||||
return;
|
||||
}
|
||||
|
||||
auto parentBatchOp = op.getParentOfType<pim::PimCoreBatchOp>();
|
||||
int32_t laneCount = parentBatchOp.getLaneCount();
|
||||
if (laneCount <= 0) {
|
||||
reportFailure([&](Operation* illegalOp) {
|
||||
illegalOp->emitOpError() << kind << " requires a positive parent laneCount";
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (coreIds.size() % static_cast<size_t>(laneCount) != 0) {
|
||||
reportFailure([&](Operation* illegalOp) {
|
||||
illegalOp->emitOpError() << kind << " core id count must be divisible by the parent laneCount";
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
auto shapedType = getStaticByteSizedShapedType(tensorValue.getType());
|
||||
if (failed(shapedType)) {
|
||||
reportFailure([&](Operation* illegalOp) {
|
||||
illegalOp->emitOpError() << kind << " requires a static shaped tensor or memref with byte-sized elements";
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t chunkCount = static_cast<int64_t>(coreIds.size()) / laneCount;
|
||||
int64_t totalBytes = (*shapedType).getNumElements() * (*shapedType).getElementTypeBitWidth() / 8;
|
||||
if (totalBytes % chunkCount != 0) {
|
||||
reportFailure([&](Operation* illegalOp) {
|
||||
illegalOp->emitOpError() << kind << " tensor byte size must be divisible by the chunk count per lane";
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (auto sendTensorBatchOp = dyn_cast<pim::PimSendTensorBatchOp>(op))
|
||||
verifyTensorBatchCommunication(sendTensorBatchOp.getInput(),
|
||||
sendTensorBatchOp.getTargetCoreIds(),
|
||||
"send_tensor_batch");
|
||||
else if (auto receiveTensorBatchOp = dyn_cast<pim::PimReceiveTensorBatchOp>(op))
|
||||
verifyTensorBatchCommunication(receiveTensorBatchOp.getOutput(),
|
||||
receiveTensorBatchOp.getSourceCoreIds(),
|
||||
"receive_tensor_batch");
|
||||
|
||||
return success(!hasFailure);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user