LLVM: include/llvm/Analysis/Utils/TFUtils.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_ANALYSIS_UTILS_TFUTILS_H
10#define LLVM_ANALYSIS_UTILS_TFUTILS_H
11
12#include "llvm/Config/llvm-config.h"
13
14#ifdef LLVM_HAVE_TFLITE
19
20#include
21#include
22
23namespace llvm {
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39class TFModelEvaluatorImpl;
40class EvaluationResultImpl;
41
42class TFModelEvaluator final {
43public:
44
45
46
47 class EvaluationResult {
48 public:
49 EvaluationResult(const EvaluationResult &) = delete;
50 EvaluationResult &operator=(const EvaluationResult &Other) = delete;
51
52 EvaluationResult(EvaluationResult &&Other);
53 EvaluationResult &operator=(EvaluationResult &&Other);
54
55 ~EvaluationResult();
56
57
58 template T *getTensorValue(size_t Index) {
59 return static_cast<T *>(getUntypedTensorValue(Index));
60 }
61
62 template const T *getTensorValue(size_t Index) const {
63 return static_cast<T *>(getUntypedTensorValue(Index));
64 }
65
66
67 void *getUntypedTensorValue(size_t Index);
68 const void *getUntypedTensorValue(size_t Index) const;
69
70 private:
71 friend class TFModelEvaluator;
72 EvaluationResult(std::unique_ptr Impl);
73 std::unique_ptr Impl;
74 };
75
76 TFModelEvaluator(StringRef SavedModelPath,
77 const std::vector &InputSpecs,
78 const std::vector &OutputSpecs,
79 const char *Tags = "serve");
80
81 ~TFModelEvaluator();
82 TFModelEvaluator(const TFModelEvaluator &) = delete;
83 TFModelEvaluator(TFModelEvaluator &&) = delete;
84
85
86
87
88
89 std::optional evaluate();
90
91
92 template T *getInput(size_t Index) {
93 return static_cast<T *>(getUntypedInput(Index));
94 }
95
96
97
98 bool isValid() const { return !!Impl; }
99
100
101 void *getUntypedInput(size_t Index);
102
103private:
104 std::unique_ptr Impl;
105};
106
107}
108
109#endif
110#endif
static bool evaluate(const MCSpecifierExpr &Expr, MCValue &Res, const MCAssembler *Asm)
This file defines the StringMap class.
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.