[llvm] [mlir] [mlir][tosa] Add profile-based operation validation (PR #126992)
Mosè Giordano via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 21 15:31:48 PST 2025
================
@@ -0,0 +1,163 @@
+//===- TosaProfileCompliance.h - Tosa Profile-based Compliance Validation -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_DIALECT_TOSA_TRANSFORMS_TOSAPROFILECOMPILANCE_H
+#define MLIR_DIALECT_TOSA_TRANSFORMS_TOSAPROFILECOMPILANCE_H
+
+#include "mlir/Dialect/Tosa/IR/TargetEnv.h"
+#include "mlir/Dialect/Tosa/Transforms/Passes.h"
+
+#include "mlir/Support/TypeID.h"
+
+using namespace mlir;
+using namespace mlir::tosa;
+
+//===----------------------------------------------------------------------===//
+// Type Compilance Definition
+//===----------------------------------------------------------------------===//
+
+typedef struct {
+ mlir::TypeID typeID;
+ uint32_t bitWidth;
+} TypeInfo;
+
+enum CheckCondition {
+ // Valid when any of the profile (extension) requirement is meet.
+ anyOf,
+ // Valid when all of the profile (extension) requirement are meet.
+ allOf,
+ invalid
+};
+
+template <typename T>
+struct OpComplianceInfo {
+ // Certain operations require multiple modes enabled.
+ // e.g. cast bf16 to fp8e4m3 requires EXT-BF16 and EXT-FP8E4M3.
+ SmallVector<T> mode;
+ SmallVector<SmallVector<TypeInfo>> operandTypeInfoSet;
+ CheckCondition condition = CheckCondition::anyOf;
+};
+
+using OperationProfileComplianceMap =
+ std::unordered_map<std::string, SmallVector<OpComplianceInfo<Profile>>>;
----------------
giordano wrote:
[`std::unordered_map`](https://en.cppreference.com/w/cpp/container/unordered_map) requires the `unordered_map` header file
https://github.com/llvm/llvm-project/pull/126992
More information about the llvm-commits
mailing list