NoInferenceModelRunner.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233
  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. #include "llvm/Analysis/NoInferenceModelRunner.h"
  16. #include "llvm/Analysis/Utils/TFUtils.h"
  17. using namespace llvm;
  18. NoInferenceModelRunner::NoInferenceModelRunner(
  19. LLVMContext &Ctx, const std::vector<TensorSpec> &Inputs)
  20. : MLModelRunner(Ctx, MLModelRunner::Kind::NoOp) {
  21. ValuesBuffer.reserve(Inputs.size());
  22. for (const auto &TS : Inputs)
  23. ValuesBuffer.push_back(std::make_unique<char[]>(TS.getElementCount() *
  24. TS.getElementByteSize()));
  25. }
  26. void *NoInferenceModelRunner::getTensorUntyped(size_t Index) {
  27. return ValuesBuffer[Index].get();
  28. }
  29. #endif // defined(LLVM_HAVE_TF_API)