1111#include < executorch/runtime/core/memory_allocator.h>
1212#include < executorch/runtime/executor/method.h>
1313
14- namespace torch {
15- namespace executor {
14+ namespace executorch {
1615namespace bundled_program {
1716
1817/* *
1918 * An opaque pointer to a serialized bundled program.
2019 */
21- using serialized_bundled_program = const void ;
20+ using SerializedBundledProgram = const void ;
2221
2322/* *
2423 * Load testset_idx-th bundled input of method_idx-th Method test in
@@ -31,9 +30,9 @@ using serialized_bundled_program = const void;
3130 * @returns Return Error::Ok if load successfully, or the error happens during
3231 * execution.
3332 */
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,
3736 size_t testset_idx);
3837
3938/* *
@@ -49,9 +48,9 @@ ET_NODISCARD Error LoadBundledInput(
4948 * @returns Return Error::Ok if two outputs match, or the error happens during
5049 * execution.
5150 */
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,
5554 size_t testset_idx,
5655 double rtol = 1e-5 ,
5756 double atol = 1e-8 );
@@ -73,7 +72,7 @@ ET_NODISCARD Error VerifyResultWithBundledExpectedOutput(
7372 * in it, and out_program_data/out_program_data_len point to the data. Other
7473 * values on failure.
7574 */
76- ET_NODISCARD Error GetProgramData (
75+ ET_NODISCARD ::executorch::runtime:: Error get_program_data (
7776 void * file_data,
7877 size_t file_data_len,
7978 const void ** out_program_data,
@@ -83,11 +82,61 @@ ET_NODISCARD Error GetProgramData(
8382 * Checks whether the given file is a bundled program.
8483 *
8584 * @param[in] file_data The contents of the given file.
85+ * @param[in] file_data_len The length of file_data, in bytes.
8686 *
8787 * @returns true if the given file is a bundled program, false otherwise
8888 */
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+ }
90135
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+ }
91140} // namespace bundled_program
92141} // namespace executor
93142} // namespace torch
0 commit comments