brintos

brintos / llvm-project-archived public Read only

0
0
Text · 21.9 KiB · ddd9c70 Raw
634 lines · cpp
1//===--- TosaProfileCompliance.cpp - Tosa Profile Compliance Validation ---===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "mlir/Dialect/Tosa/IR/TosaProfileCompliance.h"10#include "llvm/ADT/StringExtras.h"11 12using namespace mlir;13using namespace mlir::tosa;14 15TosaProfileCompliance::TosaProfileCompliance() {16  const TypeInfo boolT = {mlir::IntegerType::getTypeID(), 1};17  const TypeInfo i4T = {mlir::IntegerType::getTypeID(), 4};18  const TypeInfo i8T = {mlir::IntegerType::getTypeID(), 8};19  const TypeInfo i16T = {mlir::IntegerType::getTypeID(), 16};20  const TypeInfo i32T = {mlir::IntegerType::getTypeID(), 32};21  const TypeInfo i48T = {mlir::IntegerType::getTypeID(), 48};22  const TypeInfo i64T = {mlir::IntegerType::getTypeID(), 64};23  const TypeInfo bf16T = {mlir::BFloat16Type::getTypeID(), 16};24  const TypeInfo fp16T = {mlir::Float16Type::getTypeID(), 16};25  const TypeInfo fp32T = {mlir::Float32Type::getTypeID(), 32};26  const TypeInfo fp8e4m3T = {mlir::Float8E4M3FNType::getTypeID(), 8};27  const TypeInfo fp8e5m2T = {mlir::Float8E5M2Type::getTypeID(), 8};28 29  // micro-scaling formats30  const TypeInfo fp6e2m3T = {mlir::Float6E2M3FNType::getTypeID(), 6};31  const TypeInfo fp6e3m2T = {mlir::Float6E3M2FNType::getTypeID(), 6};32  const TypeInfo fp4e2m1T = {mlir::Float4E2M1FNType::getTypeID(), 4};33  const TypeInfo fp8ue8m0T = {mlir::Float8E8M0FNUType::getTypeID(), 8};34  const TypeInfo mxint8T = {mlir::tosa::mxint8Type::getTypeID(), 8};35 36// The profile-based compliance content below is auto-generated by a script37// in https://git.mlplatform.org/tosa/specification.git38#include "mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc"39  // End of auto-generated metadata40}41 42template <>43OperationProfileComplianceMap TosaProfileCompliance::getProfileComplianceMap() {44  return profileComplianceMap;45}46 47template <>48OperationExtensionComplianceMap49TosaProfileCompliance::getProfileComplianceMap() {50  return extensionComplianceMap;51}52 53// Base populating function54LogicalResult ProfileInfoDepot::populateProfileInfo(ValueRange operands,55                                                    ValueRange results) {56  for (const auto &operand : operands)57    addValue(operand);58  for (const auto &result : results)59    addValue(result);60  return success();61}62 63template <>64LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::ConcatOp op) {65  addValue(op.getInput1().front());66  addValue(op.getOutput());67  return success();68}69 70template <>71LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::AvgPool2dOp op) {72  addValue(op.getInput());73  addValue(op.getInputZp());74  addValue(op.getOutputZp());75  addType(op.getAccType());76  addValue(op.getOutput());77  return success();78}79 80template <typename T>81LogicalResult ProfileInfoDepot::populateProfileInfoConv(T op) {82  addValue(op.getInput());83  addValue(op.getWeight());84  addValue(op.getBias());85  addValue(op.getInputZp());86  addValue(op.getWeightZp());87  addType(op.getAccType());88  addValue(op.getOutput());89  return success();90}91 92template <>93LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::Conv2DOp op) {94  return populateProfileInfoConv(op);95}96 97template <>98LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::Conv3DOp op) {99  return populateProfileInfoConv(op);100}101 102template <>103LogicalResult104ProfileInfoDepot::populateProfileInfo(tosa::TransposeConv2DOp op) {105  return populateProfileInfoConv(op);106}107 108template <>109LogicalResult110ProfileInfoDepot::populateProfileInfo(tosa::DepthwiseConv2DOp op) {111  return populateProfileInfoConv(op);112}113 114template <>115LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::PadOp op) {116  addValue(op.getInput1());117  addValue(op.getPadConst());118  addValue(op.getOutput());119  return success();120}121 122template <typename T>123LogicalResult ProfileInfoDepot::populateProfileInfoDataLayout(T op) {124  addValue(op.getInput1());125  addValue(op.getOutput());126  return success();127}128 129template <>130LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::ReshapeOp op) {131  return populateProfileInfoDataLayout(op);132}133 134template <>135LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::SliceOp op) {136  return populateProfileInfoDataLayout(op);137}138 139template <>140LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::TileOp op) {141  return populateProfileInfoDataLayout(op);142}143 144template <>145LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::TransposeOp op) {146  return populateProfileInfoDataLayout(op);147}148 149template <>150LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::GatherOp op) {151  addValue(op.getValues());152  addValue(op.getIndices());153  addValue(op.getOutput());154  return success();155}156 157template <>158LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::ScatterOp op) {159  addValue(op.getValuesIn());160  addValue(op.getIndices());161  addValue(op.getInput());162  addValue(op.getValuesOut());163  return success();164}165 166template <>167LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::MulOp op) {168  addValue(op.getInput1());169  addValue(op.getInput2());170  addValue(op.getOutput());171  return success();172}173 174template <>175LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::ResizeOp op) {176  addValue(op.getInput());177  addValue(op.getOutput());178  return success();179}180 181template <>182LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::SelectOp op) {183  addValue(op.getOnTrue());184  addValue(op.getOnFalse());185  addValue(op.getOutput());186  return success();187}188 189template <>190LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::RescaleOp op) {191  addValue(op.getInput());192  addValue(op.getInputZp());193  addValue(op.getOutputZp());194  addValue(op.getOutput());195  return success();196}197 198template <>199LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::MatMulOp op) {200  addValue(op.getA());201  addValue(op.getB());202  addValue(op.getAZp());203  addValue(op.getBZp());204  addValue(op.getOutput());205  return success();206}207 208template <>209LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::VariableOp op) {210  addType(op.getType());211  return success();212}213 214template <>215LogicalResult ProfileInfoDepot::populateProfileInfo(tosa::VariableWriteOp op) {216  addValue(op.getInput1());217  return success();218}219 220LogicalResult ProfileInfoDepot::populatationDispatch(Operation *op) {221// This helper function only populates the info for the customised operands.222#define POPULATE_PROFILE_INFO_CUSTOM(tosaOp)                                   \223  if (isa<tosa::tosaOp##Op>(op)) {                                             \224    return populateProfileInfo(cast<tosa::tosaOp##Op>(op));                    \225  }226 227#define POPULATE_PROFILE_INFO_SKIP(tosaOp)                                     \228  if (isa<tosa::tosaOp##Op>(op))                                               \229    return success();230 231// This helper function populates the info for all operands.232#define POPULATE_PROFILE_INFO_COMMON(tosaOp)                                   \233  if (isa<tosa::tosaOp##Op>(op)) {                                             \234    return populateProfileInfo(op->getOperands(), op->getResults());           \235  }236 237  // Skip irrelevant operands when they are independent and not tied to any238  // specific profile/extension.239  POPULATE_PROFILE_INFO_CUSTOM(AvgPool2d)240  POPULATE_PROFILE_INFO_CUSTOM(TransposeConv2D)241  POPULATE_PROFILE_INFO_CUSTOM(Conv2D)242  POPULATE_PROFILE_INFO_CUSTOM(Conv3D)243  POPULATE_PROFILE_INFO_CUSTOM(DepthwiseConv2D)244  POPULATE_PROFILE_INFO_CUSTOM(Mul)245  POPULATE_PROFILE_INFO_CUSTOM(Concat)246  POPULATE_PROFILE_INFO_CUSTOM(Pad)247  POPULATE_PROFILE_INFO_CUSTOM(Reshape)248  POPULATE_PROFILE_INFO_CUSTOM(Slice)249  POPULATE_PROFILE_INFO_CUSTOM(Tile)250  POPULATE_PROFILE_INFO_CUSTOM(Transpose)251  POPULATE_PROFILE_INFO_CUSTOM(Gather)252  POPULATE_PROFILE_INFO_CUSTOM(Scatter)253  POPULATE_PROFILE_INFO_CUSTOM(Resize)254  POPULATE_PROFILE_INFO_CUSTOM(Select)255  POPULATE_PROFILE_INFO_CUSTOM(Rescale)256  POPULATE_PROFILE_INFO_CUSTOM(MatMul)257  POPULATE_PROFILE_INFO_CUSTOM(Variable)258  POPULATE_PROFILE_INFO_CUSTOM(VariableWrite)259 260  // For the most of tosa operators, all operands are profile/extension related261  // and hence are all considered in this profile-based compilance check.262  POPULATE_PROFILE_INFO_COMMON(MatmulTBlockScaled)263  POPULATE_PROFILE_INFO_COMMON(FFT2d)264  POPULATE_PROFILE_INFO_COMMON(RFFT2d)265  POPULATE_PROFILE_INFO_COMMON(Cast)266  POPULATE_PROFILE_INFO_COMMON(CastFromBlockScaled)267  POPULATE_PROFILE_INFO_COMMON(CastToBlockScaled)268  POPULATE_PROFILE_INFO_COMMON(Const)269  POPULATE_PROFILE_INFO_COMMON(ArgMax)270  POPULATE_PROFILE_INFO_COMMON(Sub)271  POPULATE_PROFILE_INFO_COMMON(Maximum)272  POPULATE_PROFILE_INFO_COMMON(Minimum)273  POPULATE_PROFILE_INFO_COMMON(MaxPool2d)274  POPULATE_PROFILE_INFO_COMMON(Clamp)275  POPULATE_PROFILE_INFO_COMMON(Erf)276  POPULATE_PROFILE_INFO_COMMON(Sigmoid)277  POPULATE_PROFILE_INFO_COMMON(Tanh)278  POPULATE_PROFILE_INFO_COMMON(Add)279  POPULATE_PROFILE_INFO_COMMON(ArithmeticRightShift)280  POPULATE_PROFILE_INFO_COMMON(BitwiseAnd)281  POPULATE_PROFILE_INFO_COMMON(BitwiseNot)282  POPULATE_PROFILE_INFO_COMMON(BitwiseOr)283  POPULATE_PROFILE_INFO_COMMON(BitwiseXor)284  POPULATE_PROFILE_INFO_COMMON(LogicalLeftShift)285  POPULATE_PROFILE_INFO_COMMON(LogicalRightShift)286  POPULATE_PROFILE_INFO_COMMON(LogicalAnd)287  POPULATE_PROFILE_INFO_COMMON(LogicalNot)288  POPULATE_PROFILE_INFO_COMMON(LogicalOr)289  POPULATE_PROFILE_INFO_COMMON(LogicalXor)290  POPULATE_PROFILE_INFO_COMMON(IntDiv)291  POPULATE_PROFILE_INFO_COMMON(Pow)292  POPULATE_PROFILE_INFO_COMMON(Table)293  POPULATE_PROFILE_INFO_COMMON(Abs)294  POPULATE_PROFILE_INFO_COMMON(Ceil)295  POPULATE_PROFILE_INFO_COMMON(Clz)296  POPULATE_PROFILE_INFO_COMMON(Sin)297  POPULATE_PROFILE_INFO_COMMON(Cos)298  POPULATE_PROFILE_INFO_COMMON(Exp)299  POPULATE_PROFILE_INFO_COMMON(Floor)300  POPULATE_PROFILE_INFO_COMMON(Log)301  POPULATE_PROFILE_INFO_COMMON(Negate)302  POPULATE_PROFILE_INFO_COMMON(Reciprocal)303  POPULATE_PROFILE_INFO_COMMON(Rsqrt)304  POPULATE_PROFILE_INFO_COMMON(ReduceAll)305  POPULATE_PROFILE_INFO_COMMON(ReduceAny)306  POPULATE_PROFILE_INFO_COMMON(ReduceMax)307  POPULATE_PROFILE_INFO_COMMON(ReduceMin)308  POPULATE_PROFILE_INFO_COMMON(ReduceProduct)309  POPULATE_PROFILE_INFO_COMMON(ReduceSum)310  POPULATE_PROFILE_INFO_COMMON(Equal)311  POPULATE_PROFILE_INFO_COMMON(GreaterEqual)312  POPULATE_PROFILE_INFO_COMMON(Greater)313  POPULATE_PROFILE_INFO_COMMON(Reverse)314  POPULATE_PROFILE_INFO_COMMON(Identity)315  POPULATE_PROFILE_INFO_COMMON(VariableRead)316 317  // Type Invariant Extension, a capability extension that is independent318  // of the data type, meaning any compatible type can be used. No type319  // constraint for those operations.320  POPULATE_PROFILE_INFO_SKIP(ConstShape)321  POPULATE_PROFILE_INFO_SKIP(Yield)322  POPULATE_PROFILE_INFO_SKIP(If)323  POPULATE_PROFILE_INFO_SKIP(While)324 325  return failure();326}327 328//===----------------------------------------------------------------------===//329// Tosa Profile And Extension Compliance Checker330//===----------------------------------------------------------------------===//331 332template <typename T>333FailureOr<OpComplianceInfo<T>>334TosaProfileCompliance::getOperatorDefinition(Operation *op) {335  const std::string opName = op->getName().getStringRef().str();336  const auto complianceMap = getProfileComplianceMap<T>();337  const auto it = complianceMap.find(opName);338  if (it == complianceMap.end())339    return {};340 341  return findMatchedEntry<T>(op, it->second);342}343 344template <typename T>345LogicalResult TosaProfileCompliance::checkProfileOrExtension(346    Operation *op, const tosa::TargetEnv &targetEnv,347    const SmallVector<ArrayRef<T>> &specRequiredModeSet) {348 349  // None of profile requirement is set in the specification.350  if (specRequiredModeSet.size() == 0)351    return success();352 353  const auto maybeOpDefinition = getOperatorDefinition<T>(op);354  if (failed(maybeOpDefinition)) {355    // Operators such as control-flow and shape ops do not have an operand type356    // restriction. When the profile compliance information of operation is not357    // found, confirm if the target have enabled the profile required from the358    // specification.359    int modeCount = 0;360    for (const auto &cands : specRequiredModeSet) {361      if (targetEnv.allowsAnyOf(cands))362        return success();363      modeCount += cands.size();364    }365 366    op->emitOpError() << "illegal: requires"367                      << (modeCount > 1 ? " any of " : " ") << "["368                      << llvm::join(stringifyProfile<T>(specRequiredModeSet),369                                    ", ")370                      << "] but not enabled in target\n";371 372    return failure();373  }374 375  // Find the required profiles or extensions according to the operand type376  // combination.377  const auto opDefinition = maybeOpDefinition.value();378  const SmallVector<T> opRequiredMode = opDefinition.mode;379  const CheckCondition condition = opDefinition.condition;380 381  if (opRequiredMode.size() == 0) {382    // No matched restriction found.383    return success();384  }385 386  if (condition == CheckCondition::allOf &&387      !targetEnv.allowsAllOf(opRequiredMode)) {388    op->emitOpError() << "illegal: requires"389                      << (opRequiredMode.size() > 1 ? " all of " : " ") << "["390                      << llvm::join(stringifyProfile<T>(opRequiredMode), ", ")391                      << "] but not enabled in target\n";392    return failure();393  }394 395  if (condition == CheckCondition::anyOf &&396      !targetEnv.allowsAnyOf(opRequiredMode)) {397    op->emitOpError() << "illegal: requires"398                      << (opRequiredMode.size() > 1 ? " any of " : " ") << "["399                      << llvm::join(stringifyProfile<T>(opRequiredMode), ", ")400                      << "] but not enabled in target\n";401    return failure();402  }403 404  // Each extension can contain a list of profiles that it works with, usually405  // have the same data type.406  if constexpr (std::is_same_v<T, Extension>) {407    for (const auto &mode : opRequiredMode) {408      SmallVector<Profile> coProfs = getCooperativeProfiles(mode);409      if (!targetEnv.allowsAnyOf(coProfs)) {410        op->emitOpError() << "illegal: requires ["411                          << llvm::join(stringifyProfile<Profile>(coProfs),412                                        ", ")413                          << "] to work with but not enabled in target\n";414        return failure();415      }416    }417  }418 419  // Ensure the profile inference match the profile knowledge of the420  // specification.421  for (const auto &cands : specRequiredModeSet) {422    for (const auto &mode : opRequiredMode) {423      if (!llvm::is_contained(cands, mode)) {424        op->emitOpError() << "illegal: requires ["425                          << llvm::join(stringifyProfile<T>(opRequiredMode),426                                        ", ")427                          << "] but not included in the profile compliance ["428                          << llvm::join(429                                 stringifyProfile<T>(specRequiredModeSet), ", ")430                          << "]\n";431        return failure();432      }433    }434  }435 436  // Ensure the matched op compliance version does not exceed the target437  // specification version.438  const VersionedTypeInfo versionedTypeInfo =439      opDefinition.operandTypeInfoSet[0];440  const TosaSpecificationVersion complianceVersion{versionedTypeInfo.second};441  const TosaSpecificationVersion targetVersion{targetEnv.getSpecVersion()};442  if (!targetVersion.isBackwardsCompatibleWith(complianceVersion)) {443    op->emitOpError() << "illegal: the target specification version ("444                      << stringifyVersion(targetVersion)445                      << ") is not backwards compatible with the op compliance "446                         "specification version ("447                      << stringifyVersion(complianceVersion) << ")\n";448    return failure();449  }450 451  return success();452}453 454LogicalResult455TosaProfileCompliance::checkProfile(Operation *op,456                                    const tosa::TargetEnv &targetEnv) {457  if (auto interface = dyn_cast<tosa::QueryProfileInterface>(op))458    return checkProfileOrExtension<Profile>(op, targetEnv,459                                            interface.getProfiles());460 461  return success();462}463 464LogicalResult465TosaProfileCompliance::checkExtension(Operation *op,466                                      const tosa::TargetEnv &targetEnv) {467  if (auto interface = dyn_cast<tosa::QueryExtensionInterface>(op))468    return checkProfileOrExtension<Extension>(op, targetEnv,469                                              interface.getExtensions());470 471  return success();472}473 474LogicalResult TosaProfileCompliance::checkInvalid(Operation *op) {475  const auto maybeProfDef = getOperatorDefinition<Profile>(op);476  const auto maybeExtDef = getOperatorDefinition<Extension>(op);477  if (failed(maybeProfDef) && failed(maybeExtDef))478    return success();479 480  const bool hasEntry =481      (succeeded(maybeProfDef) && !maybeProfDef->mode.empty()) ||482      (succeeded(maybeExtDef) && !maybeExtDef->mode.empty());483  if (!hasEntry) {484    std::string message;485    llvm::raw_string_ostream os(message);486    os << "illegal: operation operand/result data types did not align with any "487          "profile or extension, got (";488 489    ProfileInfoDepot depot(op);490    SmallVector<TypeInfo> current = depot.getInfo();491    for (const auto &typeInfo : llvm::drop_end(current))492      os << stringifyTypeInfo(typeInfo) << ",";493    os << stringifyTypeInfo(current.back()) << ")";494 495    // avoid polluting the error message output by outputting only496    // the best match497    const std::string opName = op->getName().getStringRef().str();498    int maxMatches = -1;499    SmallVector<TypeInfo> bestTypeInfo;500    const auto searchBestMatch = [&](auto map) {501      for (const auto &complianceInfos : map[opName]) {502        for (const auto &versionedTypeInfos :503             complianceInfos.operandTypeInfoSet) {504          const SmallVector<TypeInfo> typeInfos = versionedTypeInfos.first;505          const int matches = llvm::count_if(506              llvm::zip_equal(current, typeInfos), [&](const auto zipType) {507                return isSameTypeInfo(std::get<0>(zipType),508                                      std::get<1>(zipType));509              });510          if (matches > maxMatches) {511            maxMatches = matches;512            bestTypeInfo = typeInfos;513          }514        }515      }516    };517    searchBestMatch(getProfileComplianceMap<Profile>());518    searchBestMatch(getProfileComplianceMap<Extension>());519 520    os << ", did you mean (";521    for (const auto &typeInfo : llvm::drop_end(bestTypeInfo))522      os << stringifyTypeInfo(typeInfo) << ",";523    os << stringifyTypeInfo(bestTypeInfo.back()) << ")? ";524    os << "Otherwise, please refer to the 'supported data types' for '"525       << opName << "' in the specification.";526    op->emitOpError(message);527    return failure();528  }529 530  return success();531}532 533// Find the profiles or extensions requirement according to the signature of534// type of the operand list.535template <typename T>536OpComplianceInfo<T> TosaProfileCompliance::findMatchedEntry(537    Operation *op, SmallVector<OpComplianceInfo<T>> compInfo) {538  assert(compInfo.size() != 0 &&539         "profile-based compliance information is empty");540 541  // Populate the type of profile/extension relevant operands.542  ProfileInfoDepot depot(op);543  SmallVector<TypeInfo> present = depot.getInfo();544  if (present.size() == 0)545    return {};546 547  for (size_t i = 0; i < compInfo.size(); i++) {548    SmallVector<VersionedTypeInfo> sets = compInfo[i].operandTypeInfoSet;549    for (const auto &set : sets) {550      SmallVector<TypeInfo> expected = set.first;551      assert(present.size() == expected.size() &&552             "the entries for profile-based compliance do not match between "553             "the generated metadata and the type definition retrieved from "554             " the operation");555 556      bool isFound = true;557      // Compare the type signature between the given operation and the558      // compliance metadata.559      for (size_t j = 0; j < expected.size(); j++) {560        if (!isSameTypeInfo(present[j], expected[j])) {561          // Verify the next mode set from the list.562          isFound = false;563          break;564        }565      }566 567      if (isFound == true) {568        SmallVector<VersionedTypeInfo> typeInfoSet{set};569        OpComplianceInfo<T> info{compInfo[i].mode, typeInfoSet,570                                 compInfo[i].condition};571        return info;572      }573    }574  }575 576  return {};577}578 579// Debug utilites.580template <typename T>581SmallVector<StringRef>582TosaProfileCompliance::stringifyProfile(ArrayRef<T> profiles) {583  SmallVector<StringRef> debugStrings;584  for (const auto &profile : profiles) {585    if constexpr (std::is_same_v<T, Profile>)586      debugStrings.push_back(tosa::stringifyProfile(profile));587    else588      debugStrings.push_back(tosa::stringifyExtension(profile));589  }590  return debugStrings;591}592 593template <typename T>594SmallVector<StringRef> TosaProfileCompliance::stringifyProfile(595    const SmallVector<ArrayRef<T>> &profileSet) {596  SmallVector<StringRef> debugStrings;597 598  for (const auto &profiles : profileSet) {599    auto tempStrings = stringifyProfile<T>(profiles);600    llvm::append_range(debugStrings, tempStrings);601  }602 603  return debugStrings;604}605 606llvm::SmallString<7>607TosaProfileCompliance::stringifyTypeInfo(const TypeInfo &typeInfo) {608  if (typeInfo.typeID == mlir::IntegerType::getTypeID()) {609    return {"i" + llvm::utostr(typeInfo.bitWidth)};610  }611  if (typeInfo.typeID == mlir::Float16Type::getTypeID()) {612    return {"f16"};613  } else if (typeInfo.typeID == mlir::Float32Type::getTypeID()) {614    return {"f32"};615  } else if (typeInfo.typeID == mlir::BFloat16Type::getTypeID()) {616    return {"bf16"};617  } else if (typeInfo.typeID == mlir::Float8E4M3FNType::getTypeID()) {618    return {"fp8e4m3"};619  } else if (typeInfo.typeID == mlir::Float8E5M2Type::getTypeID()) {620    return {"fp8e5m2"};621  } else if (typeInfo.typeID == mlir::Float6E2M3FNType::getTypeID()) {622    return {"fp6e2m3"};623  } else if (typeInfo.typeID == mlir::Float6E3M2FNType::getTypeID()) {624    return {"fp6e3m2"};625  } else if (typeInfo.typeID == mlir::Float4E2M1FNType::getTypeID()) {626    return {"fp4e2m1"};627  } else if (typeInfo.typeID == mlir::Float8E8M0FNUType::getTypeID()) {628    return {"fp8e8m0"};629  } else if (typeInfo.typeID == tosa::mxint8Type::getTypeID()) {630    return {"mxint8"};631  }632  llvm_unreachable("unknown type");633}634