@@ -140,13 +140,15 @@ LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::TransposeOp op) {
140140template <>
141141LogicalResult ProfileInfoDepot::populateProfileInfo (tosa::GatherOp op) {
142142 addValue (op.getValues ());
143+ addValue (op.getIndices ());
143144 addValue (op.getOutput ());
144145 return success ();
145146}
146147
147148template <>
148149LogicalResult ProfileInfoDepot::populateProfileInfo (tosa::ScatterOp op) {
149150 addValue (op.getValuesIn ());
151+ addValue (op.getIndices ());
150152 addValue (op.getInput ());
151153 addValue (op.getValuesOut ());
152154 return success ();
@@ -347,6 +349,19 @@ LogicalResult ProfileInfoDepot::populatationDispatch(Operation *op) {
347349// Tosa Profile And Extension Compliance Checker
348350// ===----------------------------------------------------------------------===//
349351
352+ template <typename T>
353+ FailureOr<SmallVector<T>>
354+ TosaProfileCompliance::getOperatorDefinition (Operation *op,
355+ CheckCondition &condition) {
356+ const std::string opName = op->getName ().getStringRef ().str ();
357+ const auto complianceMap = getProfileComplianceMap<T>();
358+ const auto it = complianceMap.find (opName);
359+ if (it == complianceMap.end ())
360+ return {};
361+
362+ return findMatchedProfile<T>(op, it->second , condition);
363+ }
364+
350365template <typename T>
351366LogicalResult TosaProfileCompliance::checkProfileOrExtension (
352367 Operation *op, const tosa::TargetEnv &targetEnv,
@@ -356,11 +371,9 @@ LogicalResult TosaProfileCompliance::checkProfileOrExtension(
356371 if (specRequiredModeSet.size () == 0 )
357372 return success ();
358373
359- auto opName = op->getName ().getStringRef ().str ();
360- auto compMap = getProfileComplianceMap<T>();
361- auto it = compMap.find (opName);
362-
363- if (it == compMap.end ()) {
374+ CheckCondition condition = CheckCondition::invalid;
375+ const auto maybeOpRequiredMode = getOperatorDefinition<T>(op, condition);
376+ if (failed (maybeOpRequiredMode)) {
364377 // Operators such as control-flow and shape ops do not have an operand type
365378 // restriction. When the profile compliance information of operation is not
366379 // found, confirm if the target have enabled the profile required from the
@@ -381,12 +394,9 @@ LogicalResult TosaProfileCompliance::checkProfileOrExtension(
381394 return failure ();
382395 }
383396
384- CheckCondition condition = CheckCondition::invalid;
385- // Find the profiles or extensions requirement according to the signature of
386- // type of the operand list.
387- SmallVector<T> opRequiredMode =
388- findMatchedProfile<T>(op, it->second , condition);
389-
397+ // Find the required profiles or extensions according to the operand type
398+ // combination.
399+ const auto opRequiredMode = maybeOpRequiredMode.value ();
390400 if (opRequiredMode.size () == 0 ) {
391401 // No matched restriction found.
392402 return success ();
@@ -466,6 +476,17 @@ TosaProfileCompliance::checkExtension(Operation *op,
466476 return success ();
467477}
468478
479+ LogicalResult TosaProfileCompliance::checkInvalid (Operation *op) {
480+ CheckCondition condition = CheckCondition::invalid;
481+ const auto maybeProfDef = getOperatorDefinition<Profile>(op, condition);
482+ const auto maybeExtDef = getOperatorDefinition<Extension>(op, condition);
483+ if (!failed (maybeProfDef) && !failed (maybeExtDef) &&
484+ !maybeProfDef.value ().size () && !maybeExtDef.value ().size ())
485+ return failure ();
486+
487+ return success ();
488+ }
489+
469490// Find the profiles or extensions requirement according to the signature of
470491// type of the operand list.
471492template <typename T>
@@ -483,7 +504,6 @@ SmallVector<T> TosaProfileCompliance::findMatchedProfile(
483504
484505 for (size_t i = 0 ; i < compInfo.size (); i++) {
485506 SmallVector<SmallVector<TypeInfo>> sets = compInfo[i].operandTypeInfoSet ;
486-
487507 for (SmallVector<TypeInfo> expected : sets) {
488508 assert (present.size () == expected.size () &&
489509 " the entries for profile-based compliance do not match between "
0 commit comments