Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion codegen/tools/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def define_common_targets(is_fbcode = False):
srcs = ["test/test_gen_oplist_real_model.py"],
base_module = "",
resources = {
"//executorch/test/models:exported_programs[ModuleLinear.pte]": "test/ModuleLinear.pte",
"//executorch/test/models:exported_programs[ModuleAddMul.pte]": "test/ModuleAddMul.pte",
},
visibility = [
"//executorch/...",
Expand Down
2 changes: 1 addition & 1 deletion codegen/tools/test/test_gen_oplist_real_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from libfb.py import parutil # type: ignore[import-not-found]

MODEL_PATH: Final[str] = parutil.get_file_path("ModuleLinear.pte", pkg=__package__)
MODEL_PATH: Final[str] = parutil.get_file_path("ModuleAddMul.pte", pkg=__package__)


class TestGenOplistRealModel(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion extension/flat_tensor/flat_tensor_data_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ ET_NODISCARD Result<const char*> FlatTensorDataMap::get_key(
index,
num_keys);

if (flat_tensor_->named_data() != nullptr && index < flat_tensor_->named_data()->size()) {
if (flat_tensor_->named_data() != nullptr &&
index < flat_tensor_->named_data()->size()) {
return flat_tensor_->named_data()->Get(index)->key()->c_str();
} else {
if (flat_tensor_->named_data() != nullptr) {
Expand Down
14 changes: 7 additions & 7 deletions extension/flat_tensor/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
include(${EXECUTORCH_ROOT}/tools/cmake/Test.cmake)

add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ModuleLinearProgram.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleLinearProgram.ptd"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.ptd"
COMMAND
python -m test.models.export_program --modules "ModuleLinear"
python -m test.models.export_program --modules "ModuleAddMul"
--external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
WORKING_DIRECTORY ${EXECUTORCH_ROOT}
)

add_custom_target(
extension_flat_tensor_test_resources
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/ModuleLinearProgram.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleLinearProgram.ptd"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.ptd"
)

set(test_env
"ET_MODULE_LINEAR_PROGRAM_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleLinearProgram.pte"
"ET_MODULE_LINEAR_DATA_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleLinearProgram.ptd"
"ET_MODULE_ADD_MUL_PROGRAM_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.pte"
"ET_MODULE_ADD_MUL_DATA_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.ptd"
)

set(_test_srcs flat_tensor_data_map_test.cpp flat_tensor_header_test.cpp)
Expand Down
2 changes: 1 addition & 1 deletion extension/flat_tensor/test/flat_tensor_data_map_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FlatTensorDataMapTest : public ::testing::Test {

// Load data map. The eager linear model is defined at:
// //executorch/test/models/linear_model.py
const char* path = std::getenv("ET_MODULE_LINEAR_DATA_PATH");
const char* path = std::getenv("ET_MODULE_ADD_MUL_DATA_PATH");
Result<FileDataLoader> loader = FileDataLoader::from(path);
ASSERT_EQ(loader.error(), Error::Ok);

Expand Down
4 changes: 2 additions & 2 deletions extension/flat_tensor/test/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def define_common_targets(is_fbcode=False):
# The tests use this var to find the program file to load. This uses
# an fbcode target path because the authoring/export tools
# intentionally don't work in xplat (since they're host-only tools).
"ET_MODULE_LINEAR_PROGRAM_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleLinear.pte])",
"ET_MODULE_LINEAR_DATA_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleLinear.ptd])",
"ET_MODULE_ADD_MUL_PROGRAM_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleAddMul.pte])",
"ET_MODULE_ADD_MUL_DATA_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleAddMul.ptd])",
}

runtime.cxx_test(
Expand Down
2 changes: 1 addition & 1 deletion extension/training/module/test/state_dict_util_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class LoadStateDictTest : public ::testing::Test {
// Load data map.
// The eager linear model is defined at:
// //executorch/test/models/linear_model.py
const char* path = std::getenv("ET_MODULE_LINEAR_DATA_PATH");
const char* path = std::getenv("ET_MODULE_ADD_MUL_DATA_PATH");
Result<FileDataLoader> loader = FileDataLoader::from(path);
ASSERT_EQ(loader.error(), Error::Ok);

Expand Down
4 changes: 2 additions & 2 deletions extension/training/module/test/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def define_common_targets(is_fbcode = False):
# an fbcode target path because the authoring/export tools
# intentionally don't work in xplat (since they're host-only tools).
"ET_MODULE_ADD_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleAdd.pte])",
"ET_MODULE_LINEAR_DATA_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleLinear.ptd])",
"ET_MODULE_LINEAR_PROGRAM_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleLinear.pte])",
"ET_MODULE_ADD_MUL_DATA_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleAddMul.ptd])",
"ET_MODULE_ADD_MUL_PROGRAM_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleAddMul.pte])",
"ET_MODULE_TRAIN_DATA_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleSimpleTrain.ptd])",
"ET_MODULE_TRAIN_PROGRAM_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleSimpleTrainProgram.pte])",
"ET_MODULE_SIMPLE_TRAIN_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleSimpleTrain.pte])",
Expand Down
32 changes: 16 additions & 16 deletions runtime/executor/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
include(${EXECUTORCH_ROOT}/tools/cmake/Test.cmake)

add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ModuleAddHalf.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAdd.pte"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ModuleAdd.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddHalf.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMul.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.ptd"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleDynamicCatUnallocatedIO.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleIndex.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleLinear.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleLinearProgram.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleLinearProgram.ptd"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleMultipleEntry.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleSimpleTrain.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleStateful.pte"
COMMAND
python3 -m test.models.export_program --modules
"ModuleAdd,ModuleAddHalf,ModuleDynamicCatUnallocatedIO,ModuleIndex,ModuleLinear,ModuleMultipleEntry,ModuleSimpleTrain,ModuleStateful"
"ModuleAdd,ModuleAddHalf,ModuleAddMul,ModuleDynamicCatUnallocatedIO,ModuleIndex,ModuleMultipleEntry,ModuleSimpleTrain,ModuleStateful"
--outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
COMMAND
python3 -m test.models.export_program --modules "ModuleLinear"
python3 -m test.models.export_program --modules "ModuleAddMul"
--external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
COMMAND
python3 -m test.models.export_delegated_program --modules "ModuleAddMul"
Expand All @@ -43,27 +43,27 @@ add_custom_command(

add_custom_target(
generated_pte_files
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/ModuleAddHalf.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAdd.pte"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/ModuleAdd.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddHalf.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMul.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.ptd"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleDynamicCatUnallocatedIO.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleIndex.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleLinear.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleLinearProgram.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleLinearProgram.ptd"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleMultipleEntry.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleSimpleTrain.pte"
"${CMAKE_CURRENT_BINARY_DIR}/ModuleStateful.pte"
)

set(test_env
"DEPRECATED_ET_MODULE_LINEAR_CONSTANT_BUFFER_PATH=${EXECUTORCH_ROOT}/test/models/deprecated/ModuleLinear-no-constant-segment.pte"
"ET_MODULE_ADD_HALF_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleAddHalf.pte"
"ET_MODULE_ADD_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleAdd.pte"
"ET_MODULE_ADD_HALF_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleAddHalf.pte"
"ET_MODULE_ADD_MUL_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMul.pte"
"ET_MODULE_ADD_MUL_PROGRAM_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.pte"
"ET_MODULE_ADD_MUL_DATA_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.ptd"
"ET_MODULE_DYNAMIC_CAT_UNALLOCATED_IO_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleDynamicCatUnallocatedIO.pte"
"ET_MODULE_INDEX_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleIndex.pte"
"ET_MODULE_LINEAR_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleLinear.pte"
"ET_MODULE_LINEAR_PROGRAM_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleLinearProgram.pte"
"ET_MODULE_LINEAR_DATA_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleLinearProgram.ptd"
"ET_MODULE_MULTI_ENTRY_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleMultipleEntry.pte"
"ET_MODULE_SIMPLE_TRAIN_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleSimpleTrain.pte"
"ET_MODULE_STATEFUL_PATH=${CMAKE_CURRENT_BINARY_DIR}/ModuleStateful.pte"
Expand Down
6 changes: 3 additions & 3 deletions runtime/executor/test/program_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ TEST_F(ProgramTest, LoadConstantSegmentWithNoConstantSegment) {
}

TEST_F(ProgramTest, LoadConstantSegment) {
// Load the serialized ModuleLinear data, with constants in the segment.
const char* linear_path = std::getenv("ET_MODULE_LINEAR_PATH");
// Load the serialized ModuleAddMul data, with constants in the segment.
const char* linear_path = std::getenv("ET_MODULE_ADD_MUL_PATH");
Result<FileDataLoader> linear_loader = FileDataLoader::from(linear_path);
ASSERT_EQ(linear_loader.error(), Error::Ok);

Expand Down Expand Up @@ -458,7 +458,7 @@ TEST_F(ProgramTest, LoadConstantSegment) {
}

TEST_F(ProgramTest, LoadConstantSegmentWhenConstantBufferExists) {
// Load the serialized ModuleLinear data, with constants in the flatbuffer and
// Load the serialized ModuleAddMul data, with constants in the flatbuffer and
// no constants in the segment.
const char* linear_path =
std::getenv("DEPRECATED_ET_MODULE_LINEAR_CONSTANT_BUFFER_PATH");
Expand Down
6 changes: 3 additions & 3 deletions runtime/executor/test/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ def define_common_targets(is_fbcode = False):
"ET_MODULE_ADD_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleAdd.pte])",
"ET_MODULE_DYNAMIC_CAT_UNALLOCATED_IO_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleDynamicCatUnallocatedIO.pte])",
"ET_MODULE_INDEX_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleIndex.pte])",
"ET_MODULE_LINEAR_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleLinear.pte])",
"ET_MODULE_ADD_MUL_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleLinear.pte])",
"ET_MODULE_MULTI_ENTRY_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleMultipleEntry.pte])",
"ET_MODULE_SIMPLE_TRAIN_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleSimpleTrain.pte])",
"ET_MODULE_STATEFUL_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleStateful.pte])",
"ET_MODULE_LINEAR_PROGRAM_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleLinear.pte])",
"ET_MODULE_LINEAR_DATA_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleLinear.ptd])",
"ET_MODULE_ADD_MUL_PROGRAM_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleLinear.pte])",
"ET_MODULE_ADD_MUL_DATA_PATH": "$(location fbcode//executorch/test/models:exported_program_and_data[ModuleLinear.ptd])",
}

runtime.cxx_test(
Expand Down
2 changes: 1 addition & 1 deletion test/models/export_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def get_export_kwargs():
return {"capture_config": CaptureConfig(pt2_mode=True, enable_aot=True)}


class ModuleLinear(torch.nn.Module):
class ModuleAddMul(torch.nn.Module):
def __init__(self):
super().__init__()
self.a = 3 * torch.ones(2, 2, dtype=torch.float)
Expand Down
8 changes: 4 additions & 4 deletions test/models/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def define_common_targets():
MODULES_TO_EXPORT = [
"ModuleAdd",
"ModuleAddHalf",
"ModuleAddMul",
"ModuleBasic",
"ModuleLinear",
"ModuleMultipleEntry",
"ModuleIndex",
"ModuleDynamicCatUnallocatedIO",
Expand Down Expand Up @@ -94,16 +94,16 @@ def define_common_targets():

# Class names of nn.Modules for :exported_programs to export.
MODULES_AND_DATA_TO_EXPORT = [
"ModuleLinear",
"ModuleAddMul",
"ModuleSimpleTrain",
]

runtime.genrule(
name = "exported_program_and_data",
cmd = "$(exe :export_program) --modules " + ",".join(MODULES_AND_DATA_TO_EXPORT) + " --external-constants --outdir $OUT",
outs = {
"ModuleLinear.pte": ["ModuleLinearProgram.pte"],
"ModuleLinear.ptd": ["ModuleLinearProgram.ptd"],
"ModuleAddMul.pte": ["ModuleAddMulProgram.pte"],
"ModuleAddMul.ptd": ["ModuleAddMulProgram.ptd"],
"ModuleSimpleTrainProgram.pte": ["ModuleSimpleTrainProgram.pte"],
"ModuleSimpleTrain.ptd": ["ModuleSimpleTrainProgram.ptd"],
},
Expand Down
Loading