1 //===- MLModelRunner.h ---- ML model runner interface -----------*- C++ -*-===// 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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 10 #ifndef LLVM_ANALYSIS_MLMODELRUNNER_H 11 #define LLVM_ANALYSIS_MLMODELRUNNER_H 12 13 #include "llvm/Analysis/InlineModelFeatureMaps.h" 14 #include "llvm/IR/LLVMContext.h" 15 #include "llvm/IR/PassManager.h" 16 17 namespace llvm { 18 19 /// MLModelRunner interface: abstraction of a mechanism for evaluating a 20 /// tensorflow "saved model". 21 class MLModelRunner { 22 public: 23 // Disallows copy and assign. 24 MLModelRunner(const MLModelRunner &) = delete; 25 MLModelRunner &operator=(const MLModelRunner &) = delete; 26 virtual ~MLModelRunner() = default; 27 28 virtual bool run() = 0; 29 virtual void setFeature(FeatureIndex Index, int64_t Value) = 0; 30 virtual int64_t getFeature(int Index) const = 0; 31 32 protected: MLModelRunner(LLVMContext & Ctx)33 MLModelRunner(LLVMContext &Ctx) : Ctx(Ctx) {} 34 35 LLVMContext &Ctx; 36 }; 37 } // namespace llvm 38 39 #endif // LLVM_ANALYSIS_MLMODELRUNNER_H 40