Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion extension/module/bundled_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <executorch/extension/data_loader/buffer_data_loader.h>
#include <executorch/extension/data_loader/file_data_loader.h>


namespace executorch {
namespace extension {

Expand All @@ -27,6 +28,9 @@ std::unique_ptr<BufferDataLoader> program_data_loader(
}
} // namespace


namespace ET_BUNDLED_MODULE_NAMESPACE {

BundledModule::BundledModule(
const void* bundled_program_ptr,
std::unique_ptr<runtime::MemoryAllocator> memory_allocator,
Expand Down Expand Up @@ -107,6 +111,6 @@ runtime::Error BundledModule::verify_method_outputs(
return executorch::BUNDLED_PROGRAM_NAMESPACE::verify_method_outputs(
*method, bundled_program_ptr_, testset_idx, rtol, atol);
}

} // namespace ET_BUNDLED_MODULE_NAMESPACE
} // namespace extension
} // namespace executorch
12 changes: 12 additions & 0 deletions extension/module/bundled_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@

#include <executorch/extension/module/module.h>


#ifdef USE_ATEN_LIB
#define ET_BUNDLED_MODULE_NAMESPACE bundled_module::aten
#else // !USE_ATEN_LIB
#define ET_BUNDLED_MODULE_NAMESPACE bundled_module
#endif // USE_ATEN_LIB

namespace executorch {
namespace extension {

using ET_MODULE_NAMESPACE::Module;

namespace ET_BUNDLED_MODULE_NAMESPACE {

/**
* A facade class for loading bundled programs and executing methods within
* them.
Expand Down Expand Up @@ -119,5 +130,6 @@ class BundledModule : public Module {
bool is_loaded_from_file_ = false;
};

} // namespace ET_BUNDLED_MODULE_NAMESPACE
} // namespace extension
} // namespace executorch
3 changes: 3 additions & 0 deletions extension/module/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

namespace executorch {
namespace extension {
namespace ET_MODULE_NAMESPACE {


using ET_RUNTIME_NAMESPACE::MethodMeta;
using ET_RUNTIME_NAMESPACE::Program;
Expand Down Expand Up @@ -308,5 +310,6 @@ runtime::Error Module::set_output(
output_tensor.mutable_data_ptr(), output_tensor.nbytes(), output_index);
}

} // namespace ET_MODULE_NAMESPACE
} // namespace extension
} // namespace executorch
24 changes: 21 additions & 3 deletions extension/module/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

#include <executorch/runtime/executor/program.h>


#ifdef USE_ATEN_LIB
#define ET_MODULE_NAMESPACE module::aten
#else // !USE_ATEN_LIB
#define ET_MODULE_NAMESPACE module
#endif // USE_ATEN_LIB

namespace executorch {
namespace extension {

Expand All @@ -24,6 +31,9 @@ using ET_RUNTIME_NAMESPACE::MethodMeta;
using ET_RUNTIME_NAMESPACE::NamedDataMap;
using ET_RUNTIME_NAMESPACE::Program;

class ExecuTorchJni;

namespace ET_MODULE_NAMESPACE {
/**
* A facade class for loading programs and executing methods within them.
*/
Expand Down Expand Up @@ -493,16 +503,24 @@ class Module {
protected:
std::unordered_map<std::string, MethodHolder> methods_;

friend class ExecuTorchJni;
friend class executorch::extension::ExecuTorchJni;
};

} // namespace ET_MODULE_NAMESPACE
} // namespace extension
} // namespace executorch

namespace torch {
namespace executor {
// TODO(T197294990): Remove these deprecated aliases once all users have moved
// to the new `::executorch` namespaces.
using ::executorch::extension::Module;
} // namespace executor
using ::executorch::extension::ET_MODULE_NAMESPACE::Module;
} // namespace executorch
} // namespace torch

namespace executorch {
namespace extension {
// backward compatible namespace alias
using ::executorch::extension::ET_MODULE_NAMESPACE::Module;
} // namespace extension
} // namespace executorch
2 changes: 1 addition & 1 deletion extension/module/test/bundled_module_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <executorch/extension/module/bundled_module.h>
#include <gtest/gtest.h>

using namespace ::executorch::extension;
using namespace ::executorch::extension::ET_BUNDLED_MODULE_NAMESPACE;
using namespace ::executorch::runtime;

class BundledModuleTest : public ::testing::Test {
Expand Down
1 change: 1 addition & 0 deletions extension/pybindings/pybindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ using ::executorch::ET_RUNTIME_NAMESPACE::get_registered_kernels;
using ::executorch::ET_RUNTIME_NAMESPACE::Kernel;
using ::executorch::ET_RUNTIME_NAMESPACE::Method;
using ::executorch::ET_RUNTIME_NAMESPACE::Program;
using ::executorch::extension::ET_BUNDLED_MODULE_NAMESPACE::BundledModule;
using ::executorch::extension::BufferDataLoader;
using ::executorch::extension::MallocMemoryAllocator;
using ::executorch::extension::MmapDataLoader;
Expand Down
Loading