[llvm] [MLGO] Model selection for models lowered through EmitC (PR #212650)
ioana ghiban via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 29 01:20:19 PDT 2026
================
@@ -0,0 +1,66 @@
+//===- EmitCModelRunner.h - Fast, precompiled model runner ---------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements a model runner wrapping an EmitC compiled ML model.
+// Only inference is supported.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_ANALYSIS_EMITCMODELRUNNER_H
+#define LLVM_ANALYSIS_EMITCMODELRUNNER_H
+
+#include "llvm/Analysis/MLModelRunner.h"
+#include "llvm/Analysis/TensorSpec.h"
+
+#include <type_traits>
+
+namespace llvm {
+
+template <class TGen> class EmitCModelRunner final : public MLModelRunner {
+public:
+ template <class FType>
+ EmitCModelRunner(LLVMContext &Ctx, const FType &InputSpec)
+ : MLModelRunner(Ctx, MLModelRunner::Kind::Release, InputSpec.size()) {
+ for (size_t I = 0; I < InputSpec.size(); ++I)
----------------
ioghiban wrote:
```suggestion
for (auto [I, Spec] : llvm::enumerate(InputSpec))
```
LLVM Coding Standards recommend using range-based `for` loops wherever possible. Since this loop needs both the index and the element, `llvm::enumerate` is the idiomatic LLVM approach and avoids manual index-based iteration.
https://llvm.org/docs/CodingStandards.html#use-range-based-for-loops-wherever-possible
https://github.com/llvm/llvm-project/pull/212650
More information about the llvm-commits
mailing list