forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Allows the XOR model training demo to be runnable in OSS. Will follow up with a documentation PR about training and how to run this demo. Im sure my cmakelist.txt changes have issues so if anyone sees ways to improve them please let me know. Only hack I had to do was the optimizer was calling an ET op directly. I don't think we have enabled this in OSS yet so I will follow up with larryliu0820 when hes back and in the meantime open up an issue. Repro of demo: Pull Request resolved: pytorch#5445 Test Plan: python3 extension/training/examples/XOR/export_model.py --outdir /tmp/xor rm -rf cmake-out mkdir cmake-out cmake \ -DCMAKE_INSTALL_PREFIX=cmake-out \ -DCMAKE_BUILD_TYPE=Release \ -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \ -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \ -DEXECUTORCH_BUILD_EXTENSION_TRAINING=ON \ -DEXECUTORCH_ENABLE_LOGGING=ON \ -DPYTHON_EXECUTABLE=python \ -Bcmake-out . cmake --build cmake-out -j9 --target install --config Release ./cmake-out/extension/training/train_xor --model_path=/tmp/xor/xor.pte Reviewed By: dvorjackz Differential Revision: D62905840 Pulled By: JacobSzwejbka fbshipit-source-id: 622e68637ee7a0bb1b323e777d60e9516be115cd
- Loading branch information
1 parent
53c1a5f
commit 26c736e
Showing
12 changed files
with
198 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# Please this file formatted by running: | ||
# ~~~ | ||
# cmake-format -i CMakeLists.txt | ||
# ~~~ | ||
|
||
cmake_minimum_required(VERSION 3.19) | ||
|
||
# Source root directory for executorch. | ||
if(NOT EXECUTORCH_ROOT) | ||
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) | ||
endif() | ||
|
||
list(TRANSFORM _extension_training__srcs PREPEND "${EXECUTORCH_ROOT}/") | ||
|
||
add_library(extension_training ${_extension_training__srcs}) | ||
target_include_directories( | ||
extension_training PUBLIC ${_common_include_directories} | ||
) | ||
|
||
target_include_directories(extension_training PUBLIC ${EXECUTORCH_ROOT}/..) | ||
target_compile_options(extension_training PUBLIC ${_common_compile_options}) | ||
target_link_libraries(extension_training executorch_no_prim_ops | ||
extension_data_loader extension_module extension_tensor) | ||
|
||
|
||
list(TRANSFORM _train_xor__srcs PREPEND "${EXECUTORCH_ROOT}/") | ||
add_executable(train_xor ${_train_xor__srcs}) | ||
target_include_directories( | ||
train_xor PUBLIC ${_common_include_directories} | ||
) | ||
target_link_libraries( | ||
train_xor gflags executorch_no_prim_ops portable_ops_lib extension_tensor | ||
extension_training program_schema | ||
) | ||
target_compile_options(train_xor PUBLIC ${_common_compile_options}) | ||
|
||
# Install libraries | ||
install( | ||
TARGETS extension_training | ||
DESTINATION lib | ||
INCLUDES | ||
DESTINATION ${_common_include_directories} | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,8 @@ | ||
# Any targets that should be shared between fbcode and xplat must be defined in | ||
# targets.bzl. This file can contain fbcode-only targets. | ||
|
||
load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") | ||
load("@fbcode_macros//build_defs:python_library.bzl", "python_library") | ||
load(":targets.bzl", "define_common_targets") | ||
|
||
oncall("executorch") | ||
|
||
define_common_targets() | ||
|
||
python_library( | ||
name = "model", | ||
srcs = ["model.py"], | ||
visibility = [], # Private | ||
deps = [ | ||
"//caffe2:torch", | ||
], | ||
) | ||
|
||
python_library( | ||
name = "export_model_lib", | ||
srcs = ["export_model_lib.py"], | ||
visibility = [], | ||
deps = [ | ||
":model", | ||
"//caffe2:torch", | ||
"//executorch/exir:lib", | ||
], | ||
) | ||
|
||
python_binary( | ||
name = "export_model", | ||
main_function = ".export_model.main", | ||
main_src = "export_model.py", | ||
deps = [ | ||
":export_model_lib", | ||
"//caffe2:torch", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.