1 //===- NoInferenceModelRunner.cpp - noop ML model runner ----------------===// 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 // A pseudo model runner. We use it to store feature values when collecting 10 // logs for the default policy, in 'development' mode, but never ask it to 11 // 'run'. 12 //===----------------------------------------------------------------------===// 13 #include "llvm/Config/config.h" 14 #if defined(LLVM_HAVE_TF_API) 15 16 #include "llvm/Analysis/NoInferenceModelRunner.h" 17 #include "llvm/Analysis/Utils/TFUtils.h" 18 19 using namespace llvm; 20 21 NoInferenceModelRunner::NoInferenceModelRunner( 22 LLVMContext &Ctx, const std::vector<TensorSpec> &Inputs) 23 : MLModelRunner(Ctx, MLModelRunner::Kind::NoOp) { 24 ValuesBuffer.reserve(Inputs.size()); 25 for (const auto &TS : Inputs) 26 ValuesBuffer.push_back(std::make_unique<char[]>(TS.getElementCount() * 27 TS.getElementByteSize())); 28 } 29 30 void *NoInferenceModelRunner::getTensorUntyped(size_t Index) { 31 return ValuesBuffer[Index].get(); 32 } 33 #endif // defined(LLVM_HAVE_TF_API) 34