9#ifndef LLVM_ANALYSIS_UTILS_TFUTILS_H
10#define LLVM_ANALYSIS_UTILS_TFUTILS_H
12#include "llvm/Config/llvm-config.h"
14#ifdef LLVM_HAVE_TFLITE
39class TFModelEvaluatorImpl;
40class EvaluationResultImpl;
42class TFModelEvaluator final {
47 class EvaluationResult {
49 EvaluationResult(
const EvaluationResult &) =
delete;
50 EvaluationResult &operator=(
const EvaluationResult &
Other) =
delete;
52 EvaluationResult(EvaluationResult &&
Other);
53 EvaluationResult &operator=(EvaluationResult &&
Other);
58 template <
typename T>
T *getTensorValue(
size_t Index) {
59 return static_cast<T *
>(getUntypedTensorValue(
Index));
62 template <
typename T>
const T *getTensorValue(
size_t Index)
const {
63 return static_cast<T *
>(getUntypedTensorValue(
Index));
67 void *getUntypedTensorValue(
size_t Index);
68 const void *getUntypedTensorValue(
size_t Index)
const;
71 friend class TFModelEvaluator;
72 EvaluationResult(std::unique_ptr<EvaluationResultImpl> Impl);
73 std::unique_ptr<EvaluationResultImpl> Impl;
76 TFModelEvaluator(StringRef SavedModelPath,
77 const std::vector<TensorSpec> &InputSpecs,
78 const std::vector<TensorSpec> &OutputSpecs,
79 const char *Tags =
"serve");
82 TFModelEvaluator(
const TFModelEvaluator &) =
delete;
83 TFModelEvaluator(TFModelEvaluator &&) =
delete;
89 std::optional<EvaluationResult> evaluate();
92 template <
typename T>
T *getInput(
size_t Index) {
93 return static_cast<T *
>(getUntypedInput(
Index));
98 bool isValid()
const {
return !!Impl; }
101 void *getUntypedInput(
size_t Index);
104 std::unique_ptr<TFModelEvaluatorImpl> Impl;
This file defines the StringMap class.
std::optional< std::vector< StOtherPiece > > Other
This file supports working with JSON data.
static bool isValid(const char C)
Returns true if C is a valid mangled character: <0-9a-zA-Z_>.
This is an optimization pass for GlobalISel generic memory operations.