11
11
#include < executorch/runtime/core/memory_allocator.h>
12
12
#include < executorch/runtime/executor/method.h>
13
13
14
- namespace torch {
15
- namespace executor {
14
+ namespace executorch {
16
15
namespace bundled_program {
17
16
18
17
/* *
19
18
* An opaque pointer to a serialized bundled program.
20
19
*/
21
- using serialized_bundled_program = const void ;
20
+ using SerializedBundledProgram = const void ;
22
21
23
22
/* *
24
23
* Load testset_idx-th bundled input of method_idx-th Method test in
@@ -31,9 +30,9 @@ using serialized_bundled_program = const void;
31
30
* @returns Return Error::Ok if load successfully, or the error happens during
32
31
* execution.
33
32
*/
34
- ET_NODISCARD Error LoadBundledInput (
35
- Method& method,
36
- serialized_bundled_program * bundled_program_ptr,
33
+ ET_NODISCARD ::executorch::runtime:: Error load_bundled_input (
34
+ ::executorch::runtime:: Method& method,
35
+ SerializedBundledProgram * bundled_program_ptr,
37
36
size_t testset_idx);
38
37
39
38
/* *
@@ -49,9 +48,9 @@ ET_NODISCARD Error LoadBundledInput(
49
48
* @returns Return Error::Ok if two outputs match, or the error happens during
50
49
* execution.
51
50
*/
52
- ET_NODISCARD Error VerifyResultWithBundledExpectedOutput (
53
- Method& method,
54
- serialized_bundled_program * bundled_program_ptr,
51
+ ET_NODISCARD ::executorch::runtime:: Error verify_method_outputs (
52
+ ::executorch::runtime:: Method& method,
53
+ SerializedBundledProgram * bundled_program_ptr,
55
54
size_t testset_idx,
56
55
double rtol = 1e-5 ,
57
56
double atol = 1e-8 );
@@ -73,7 +72,7 @@ ET_NODISCARD Error VerifyResultWithBundledExpectedOutput(
73
72
* in it, and out_program_data/out_program_data_len point to the data. Other
74
73
* values on failure.
75
74
*/
76
- ET_NODISCARD Error GetProgramData (
75
+ ET_NODISCARD ::executorch::runtime:: Error get_program_data (
77
76
void * file_data,
78
77
size_t file_data_len,
79
78
const void ** out_program_data,
@@ -83,11 +82,61 @@ ET_NODISCARD Error GetProgramData(
83
82
* Checks whether the given file is a bundled program.
84
83
*
85
84
* @param[in] file_data The contents of the given file.
85
+ * @param[in] file_data_len The length of file_data, in bytes.
86
86
*
87
87
* @returns true if the given file is a bundled program, false otherwise
88
88
*/
89
- bool IsBundledProgram (void * file_data);
89
+ bool is_bundled_program (void * file_data, size_t file_data_len);
90
+
91
+ // / DEPRECATED: Use the version with the file_data_len parameter.
92
+ ET_DEPRECATED inline bool is_bundled_program (void * file_data) {
93
+ // 128 is enough data to contain the identifier in the flatbuffer header.
94
+ return is_bundled_program (file_data, 128 );
95
+ }
96
+
97
+ } // namespace bundled_program
98
+ } // namespace executorch
99
+
100
+ namespace torch {
101
+ namespace executor {
102
+ namespace bundled_program {
103
+ // TODO(T197294990): Remove these deprecated aliases once all users have moved
104
+ // to the new `::executorch` namespaces.
105
+ using serialized_bundled_program =
106
+ ::executorch::bundled_program::SerializedBundledProgram;
107
+
108
+ ET_NODISCARD inline ::executorch::runtime::Error LoadBundledInput (
109
+ ::executorch::runtime::Method& method,
110
+ serialized_bundled_program* bundled_program_ptr,
111
+ size_t testset_idx) {
112
+ return ::executorch::bundled_program::load_bundled_input (
113
+ method, bundled_program_ptr, testset_idx);
114
+ }
115
+
116
+ ET_NODISCARD inline ::executorch::runtime::Error
117
+ VerifyResultWithBundledExpectedOutput (
118
+ ::executorch::runtime::Method& method,
119
+ serialized_bundled_program* bundled_program_ptr,
120
+ size_t testset_idx,
121
+ double rtol = 1e-5 ,
122
+ double atol = 1e-8 ) {
123
+ return ::executorch::bundled_program::verify_method_outputs (
124
+ method, bundled_program_ptr, testset_idx, rtol, atol);
125
+ }
126
+
127
+ ET_NODISCARD inline ::executorch::runtime::Error GetProgramData (
128
+ void * file_data,
129
+ size_t file_data_len,
130
+ const void ** out_program_data,
131
+ size_t * out_program_data_len) {
132
+ return ::executorch::bundled_program::get_program_data (
133
+ file_data, file_data_len, out_program_data, out_program_data_len);
134
+ }
90
135
136
+ inline bool IsBundledProgram (void * file_data) {
137
+ // 128 is enough data to contain the identifier in the flatbuffer header.
138
+ return ::executorch::bundled_program::is_bundled_program (file_data, 128 );
139
+ }
91
140
} // namespace bundled_program
92
141
} // namespace executor
93
142
} // namespace torch
0 commit comments