Skip to content

Commit ba543da

Browse files
committed
setup files
1 parent 339b75c commit ba543da

File tree

97 files changed

+18141
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+18141
-30
lines changed

.vscode/launch.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Debug CMake project",
9+
"type": "lldb", // https://github.com/vadimcn/vscode-lldb
10+
"request": "launch",
11+
"program": "${command:cmake.launchTargetPath}",
12+
"args": [
13+
"--model_path=./add.pte",
14+
]
15+
}
16+
]
17+
}

.vscode/settings.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"files.associations": {
3+
"cstdlib": "cpp",
4+
"__bit_reference": "cpp",
5+
"__hash_table": "cpp",
6+
"__locale": "cpp",
7+
"__node_handle": "cpp",
8+
"__split_buffer": "cpp",
9+
"__tree": "cpp",
10+
"__verbose_abort": "cpp",
11+
"array": "cpp",
12+
"bitset": "cpp",
13+
"cctype": "cpp",
14+
"charconv": "cpp",
15+
"clocale": "cpp",
16+
"cmath": "cpp",
17+
"complex": "cpp",
18+
"condition_variable": "cpp",
19+
"cstdarg": "cpp",
20+
"cstdint": "cpp",
21+
"cstdio": "cpp",
22+
"cstring": "cpp",
23+
"ctime": "cpp",
24+
"cwchar": "cpp",
25+
"cwctype": "cpp",
26+
"deque": "cpp",
27+
"execution": "cpp",
28+
"memory": "cpp",
29+
"forward_list": "cpp",
30+
"future": "cpp",
31+
"initializer_list": "cpp",
32+
"iomanip": "cpp",
33+
"ios": "cpp",
34+
"iosfwd": "cpp",
35+
"iostream": "cpp",
36+
"istream": "cpp",
37+
"limits": "cpp",
38+
"list": "cpp",
39+
"locale": "cpp",
40+
"map": "cpp",
41+
"mutex": "cpp",
42+
"new": "cpp",
43+
"optional": "cpp",
44+
"print": "cpp",
45+
"queue": "cpp",
46+
"ratio": "cpp",
47+
"regex": "cpp",
48+
"set": "cpp",
49+
"shared_mutex": "cpp",
50+
"sstream": "cpp",
51+
"stack": "cpp",
52+
"stdexcept": "cpp",
53+
"streambuf": "cpp",
54+
"string": "cpp",
55+
"string_view": "cpp",
56+
"typeindex": "cpp",
57+
"typeinfo": "cpp",
58+
"unordered_map": "cpp",
59+
"unordered_set": "cpp",
60+
"variant": "cpp",
61+
"vector": "cpp",
62+
"algorithm": "cpp",
63+
"iterator": "cpp",
64+
"tuple": "cpp",
65+
"span": "cpp"
66+
},
67+
"C_Cpp.default.compilerPath": "/library/developer/commandlinetools/usr/bin/c++",
68+
"python.analysis.typeCheckingMode": "off"
69+
}

CMakePresets.json

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,45 @@
11
{
2-
"version": 10,
3-
"cmakeMinimumRequired": {
4-
"major": 3,
5-
"minor": 31,
6-
"patch": 0
7-
},
8-
"$comment": "On-device AI across mobile, embedded and edge for PyTorch.",
9-
"configurePresets": [
10-
{
11-
"name": "common",
12-
"hidden": true,
13-
"binaryDir": "${sourceDir}/cmake-out",
14-
"generator": "Unix Makefiles"
2+
"version": 10,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 31,
6+
"patch": 0
157
},
16-
{
17-
"name": "macos-arm64",
18-
"inherits": ["common"],
19-
"generator": "Xcode",
20-
"cacheVariables": {
21-
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
22-
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/macos-arm64.cmake",
23-
"PLATFORM": "MAC_ARM64",
24-
"DEPLOYMENT_TARGET": "10.15"
25-
},
26-
"condition": {
27-
"lhs": "${hostSystemName}",
28-
"type": "equals",
29-
"rhs": "Darwin"
30-
}
31-
}
32-
]
8+
"configurePresets": [
9+
{
10+
"name": "common",
11+
"hidden": true,
12+
"binaryDir": "${sourceDir}/cmake-out",
13+
"generator": "Unix Makefiles"
14+
},
15+
{
16+
"name": "macos-arm64",
17+
"inherits": [
18+
"common"
19+
],
20+
"generator": "Xcode",
21+
"cacheVariables": {
22+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
23+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/macos-arm64.cmake",
24+
"PLATFORM": "MAC_ARM64",
25+
"DEPLOYMENT_TARGET": "10.15"
26+
},
27+
"condition": {
28+
"lhs": "${hostSystemName}",
29+
"type": "equals",
30+
"rhs": "Darwin"
31+
}
32+
},
33+
{
34+
"name": "Executorch",
35+
"displayName": "Executorch",
36+
"description": "Sets Ninja generator, build and install directory",
37+
"generator": "Ninja",
38+
"binaryDir": "${sourceDir}/out/build/${presetName}",
39+
"cacheVariables": {
40+
"CMAKE_BUILD_TYPE": "Debug",
41+
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
42+
}
43+
}
44+
]
3345
}
236 KB
Binary file not shown.

cmake_wrapper.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
source /Users/madragna/executorch/.venv/bin/activate
4+
cmake "$@"

data/bin/__init__.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This file should be written to the wheel package as
2+
# `executorch/data/bin/__init__.py`.
3+
#
4+
# Setuptools will expect to be able to say something like `from
5+
# executorch.data.bin import mybin; mybin()` for each entry listed in the
6+
# [project.scripts] section of pyproject.toml. This file makes the `mybin()`
7+
# function execute the binary at `executorch/data/bin/mybin` and exit with that
8+
# binary's exit status.
9+
10+
import subprocess
11+
import os
12+
import sys
13+
import types
14+
15+
# This file should live in the target `bin` directory.
16+
_bin_dir = os.path.join(os.path.dirname(__file__))
17+
18+
def _find_executable_files_under(dir):
19+
"""Lists all executable files in the given directory."""
20+
bin_names = []
21+
for filename in os.listdir(dir):
22+
filepath = os.path.join(dir, filename)
23+
if os.path.isfile(filepath) and os.access(filepath, os.X_OK):
24+
# Remove .exe suffix on windows.
25+
filename_without_ext = os.path.splitext(filename)[0]
26+
bin_names.append(filename_without_ext)
27+
return bin_names
28+
29+
# The list of binaries to create wrapper functions for.
30+
_bin_names = _find_executable_files_under(_bin_dir)
31+
32+
# We'll define functions named after each binary. Make them importable.
33+
__all__ = _bin_names
34+
35+
def _run(name):
36+
"""Runs the named binary, which should live under _bin_dir.
37+
38+
Exits the current process with the return code of the subprocess.
39+
"""
40+
raise SystemExit(subprocess.call([os.path.join(_bin_dir, name)] + sys.argv[1:], close_fds=False))
41+
42+
# Define a function named after each of the binaries.
43+
for bin_name in _bin_names:
44+
exec(f"def {bin_name}(): _run('{bin_name}')")

data/bin/flatc

10.9 MB
Binary file not shown.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
3+
//
4+
// See README.md before modifying this file.
5+
//
6+
7+
include "scalar_type.fbs";
8+
9+
namespace bundled_program_flatbuffer;
10+
11+
// Identifier of a valid bundled program schema.
12+
file_identifier "BP08";
13+
// Extension of written files.
14+
file_extension "bpte";
15+
16+
// Reason for basic struct: union value type can only be table/struct/string
17+
table Int {
18+
int_val:long;
19+
}
20+
21+
table Bool {
22+
bool_val:bool;
23+
}
24+
25+
table Double {
26+
double_val:double;
27+
}
28+
29+
// All information we need to bundle for a tensor EValue input.
30+
table Tensor {
31+
// The scalar type of Tensor
32+
scalar_type: executorch_flatbuffer.ScalarType;
33+
// The target sizes of the tensor.
34+
sizes: [int];
35+
// The contents of the corresponding input tensor.
36+
data: [ubyte] (force_align: 16);
37+
dim_order:[ubyte];
38+
}
39+
40+
union ValueUnion {
41+
Tensor,
42+
Int,
43+
Bool,
44+
Double,
45+
}
46+
47+
// Abstraction for BundledMethodTestCase values
48+
table Value {
49+
val: ValueUnion;
50+
}
51+
52+
// A single test for a method. The provided inputs should produce the
53+
// expected outputs.
54+
table BundledMethodTestCase {
55+
// The inputs to provide to the method. The number and types of inputs must
56+
// match the schema of the method under test.
57+
inputs: [Value];
58+
59+
// The expected outputs generated while running the model in eager mode using
60+
// the inputs provided. Its length should be equal to the length of program
61+
// outputs.
62+
expected_outputs: [Value];
63+
}
64+
65+
// Collection of test cases for a program method.
66+
table BundledMethodTestSuite {
67+
// The name of the method to test; e.g., "forward" for the forward() method
68+
// of an nn.Module. This name match a method defined by the ExecuTorch
69+
// program.
70+
method_name: string;
71+
72+
// Individual test cases for the method.
73+
test_cases: [BundledMethodTestCase];
74+
}
75+
76+
77+
// Executorch program bunlded with data for verification.
78+
table BundledProgram {
79+
// Schema version.
80+
version:uint;
81+
82+
// Test sets to run against the program.
83+
// Each BundledMethodTestSuite should be used for the method of program sharing same name.
84+
method_test_suites: [BundledMethodTestSuite];
85+
86+
// The binary data of a serialized Executorch program.
87+
// The following `force_align` may sliently override any larger force_align
88+
// used in the program. Therefore, to keep the data (including constant
89+
// tensor, delegate data, etc, see schema.fbs for more info) in the
90+
// executorch program keeps the same alignment as original no matter how
91+
// the program schema changes, we need to make the force_align here the max
92+
// one around all kinds of force_align in the current and future program
93+
// schema, so we use the 32 as the force_align here.
94+
program: [ubyte] (force_align: 32);
95+
}
96+
97+
root_type BundledProgram;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
3+
//
4+
// See README.md before modifying this file.
5+
//
6+
7+
namespace executorch_flatbuffer;
8+
9+
// The scalar data type.
10+
// Must match executorch/runtime/core/portable_type/tensor_impl.h
11+
enum ScalarType : byte {
12+
BYTE = 0,
13+
CHAR = 1,
14+
SHORT = 2,
15+
INT = 3,
16+
LONG = 4,
17+
HALF = 5,
18+
FLOAT = 6,
19+
DOUBLE = 7,
20+
BOOL = 11,
21+
QINT8 = 12,
22+
QUINT8 = 13,
23+
QINT32 = 14,
24+
QUINT4X2 = 16,
25+
QUINT2X4 = 17,
26+
BITS16 = 22,
27+
FLOAT8E5M2 = 23,
28+
FLOAT8E4M3FN = 24,
29+
FLOAT8E5M2FNUZ = 25,
30+
FLOAT8E4M3FNUZ = 26,
31+
UINT16 = 27,
32+
UINT32 = 28,
33+
UINT64 = 29,
34+
// Types currently not implemented.
35+
// COMPLEXHALF = 8,
36+
// COMPLEXFLOAT = 9,
37+
// COMPLEXDOUBLE = 10,
38+
// BFLOAT16 = 15,
39+
// BITS1x8 = 18,
40+
// BITS2x4 = 19,
41+
// BITS4x2 = 20,
42+
// BITS8 = 21,
43+
}

0 commit comments

Comments
 (0)