Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic model builder and inference engine #3415

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
657ed9b
Added the generic model builder.
Jun 2, 2019
6ec9862
Added the generic inference engine.
Jun 2, 2019
5205ba8
Merge pull request #1 in TECH/xperi_glow from feature/xperi-generic-i…
Jun 3, 2019
2bef650
Merge pull request #4 in TECH/xperi_glow from feature/xperi-generic-m…
Jun 3, 2019
3830fff
Created a build system for the inference engine.
Jun 4, 2019
ceec0b2
Merge branch 'feature/xperi-generic-inference-engine' into integratio…
Jun 4, 2019
c9f0b88
Bugfix.
Jun 4, 2019
28c5644
bug fixes
Jun 4, 2019
69a7289
Bugfix.
Jun 5, 2019
e1bfb2a
Removed redundant debug message.
Jun 5, 2019
acba063
bugfixes
Jun 5, 2019
75c8349
Bugfix.
Jun 5, 2019
5fc3610
Implemented performance monitoring.
Jun 19, 2019
99d8c3b
Finished performance monitoring code.
Jun 20, 2019
fb6af78
Bug fix.
Jun 20, 2019
9023ebc
Merge pull request #6 in TECH/xperi_glow from feature/inference-perfo…
Jun 20, 2019
826a352
Bug fix.
Jun 25, 2019
00c8071
Condition performance monitoring/output on the -p flag.
Jun 25, 2019
a957f81
Merge pull request #7 in TECH/xperi_glow from feature/inference-perfo…
Jun 25, 2019
18c7280
Merge remote-tracking branch 'upstream/master' into local/integration…
Jun 25, 2019
b41f6af
Reset cmake for backends to virgin state (for native builds).
Jun 25, 2019
f08345f
Bug fix.
Jun 25, 2019
255b998
TODO comments about extending to multi-dim output.
Jun 26, 2019
04a57b7
WIP: Support multiple output tensors of variable length.
Jun 28, 2019
4fd4bc1
WIP
Jul 11, 2019
3249e96
Merge branch 'upstream/integration/master' into local/integration/ups…
Jul 11, 2019
c5a1577
Merged latest from glow upstream.
Jul 17, 2019
f511124
Fixed cmake.
Jul 18, 2019
76f4149
Bug fix.
Jul 18, 2019
c525119
Bug fixes.
Jul 18, 2019
933256c
Merge branch 'upstream/integration/master' into local/integration/ups…
Jul 18, 2019
c5ffb13
Merge branch 'upstream/integration/master' into local/integration/ups…
Jul 18, 2019
dbe2bd9
Merge branch 'upstream/integration/master' into local/integration/ups…
Jul 18, 2019
299838d
Merge branch 'upstream/integration/local-to-upstream-merge-07182019' …
Jul 18, 2019
5de9e62
Merge pull request #1 from wyessen/upstream/integration/local-to-upst…
Jul 18, 2019
3907506
Merge remote-tracking branch 'glow/master' into local/integration/ups…
Aug 2, 2019
b5c7d67
Added the correct copyright notices.
Aug 2, 2019
f42bb70
Merge branch 'local/integration/upstream-PR-preparation-08022019' int…
Aug 3, 2019
dc78170
Merge branch 'master' of github.com:wyessen/glow into upstream/integr…
Aug 3, 2019
f522987
Merge branch 'glow/integration/master' into upstream/integration/master
Aug 13, 2019
2d28995
Added some comments.
Aug 13, 2019
eabe8f8
Added initial documentation for the XModelRunner.
Aug 13, 2019
f9d7567
Bug fixes and documentation for the x-inference-engine.
Aug 14, 2019
b9dcbc3
Merge branch 'glow/integration/master' into upstream/integration/master
Aug 14, 2019
82f2fcb
Merge branch 'glow/integration/master' into upstream/integration/master
Sep 26, 2019
c5d0b9c
Code review.
Sep 26, 2019
e5e73cf
Glow wants to be clang-formatted
Sep 26, 2019
2c8a364
Merge branch 'glow/integration/master' into upstream/integration/master
Oct 14, 2019
332d1b2
WIP: formatting
Oct 14, 2019
089fe5e
WIP: added inference_engines to format.sh
Oct 14, 2019
9023cd5
Bugfix
Oct 14, 2019
6ef6844
Clang-format
Oct 14, 2019
9095361
clang-format
Oct 14, 2019
10e5700
Merge branch 'glow/integration/master' into upstream/integration/master
Oct 14, 2019
2c1c437
Bug fix.
Oct 15, 2019
d8c538d
formatting
Oct 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
521 changes: 521 additions & 0 deletions docs/InferenceEngines.md

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions docs/XModelRunner.md
@@ -0,0 +1,44 @@
## XModelRunner

Glow supplies a number of out-of-the-box model builders/runners, which include
the `ImageClassifier` and the `ModelLoader`. The former is tailored towards specific
networks built for image classification, while the latter is a generic model loader (see
the corresponding documentation).

`XModelRunner` is a generic model builder/runner that is able to consume any model --
either in the ONNX format, or as a Caffe2 protobuf -- and
either compile it (producing a bundle if requested, along with profiling when requested),
or run inference on it. `XModelRunner`
is built along with the other models using the standard build instructions (see the
building documentation). Below is a description of the command line options for `XModelRunner`.

### Command Line Options

In addition to all of the "standard" command line options (i.e. those that are common to
all model builders/runners, and can be obtained with the `-help` option), a few
options are supported by `XModelRunner`, some of which are mandatory and some are optional.

#### Required Options

| Option | Expected Values | Description | Required |
| :------ | :------ | :------ | :------ |
|`input-tensor-dims` | Comma-separated list of ints | Input tensor dimensions | Yes |
|`output-tensor-names` | Comma-separated list of strings (no spaces) | Output tensor names (can be more than one) | Yes |
|`write-output` | Boolean flag | Whether to write output to output files (only applicable when not building a bundle) | No (default is `False`) |

#### Expected Input

`XModelRunner` expects either a list of file names containing input (one input tensor per file), which are positional arguments, or a file name containing the list of file names that contain input (one file name per line), specified with the `input-file-list` option. Input specification is required when either profiling the network, or running inference (i.e. not building a bundle). Otherwise, input can be omitted.

#### Produced Output

When input files are specified, output is produced (saved into binary files) only when the `write-output` option is specified. In this case, the input file name acts as a base name for the output file name. The output file name is composed as `[input file name].out.dat`. When input is not specified and bundles are requested, the runner produces bundles in the specified output directory. Also, `write-output` may be omitted when profiling the network.

### Technical Notes

1. The runner currently supports only one (named) input tensor, but can work with multiple (named) output tensors.
2. The runner does not currently support streaming input, but this feature is planned.

### A Note on the Initial Contribution

The initial contribution of this runner (as well as the corresponding documentation) was made as part of the open source contribution initiative by the XPERI Corporation (xperi.com).
66 changes: 66 additions & 0 deletions inference_engines/x-inference-engines/CMakeLists.txt
@@ -0,0 +1,66 @@
cmake_minimum_required(VERSION 3.0)
project(x-infer)

option(LIB_ONLY "Only build the library" OFF)
option(BUILD_FOR_DYNAMIC_LINKAGE "Whether to build for dynamic or static bundle linkage" ON)
option(LINK_LIBS_STATICALLY "Whether to link in all the required libraries statically" ON)
option(ENABLE_PERF_MONITORING "Whether to enable performance monitoring" OFF)

set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)

if(LINK_LIBS_STATICALLY)
message(WARNING "Static linking may cause issues with dlopen on target")
message("Will statically link executable")
set(TARGET_COMPILE_FLAGS "-static"
)
set(TARGET_LINKER_FLAGS "-static"
)
else()
set(TARGET_COMPILE_FLAGS )
endif()

if (DEFINED TARGET_OPTIONS)
set(TARGET_COMPILE_FLAGS "${TARGET_COMPILE_FLAGS} ${TARGET_OPTIONS}")
endif()

include_directories(${PROJECT_SOURCE_DIR})

set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ${TARGET_COMPILE_FLAGS})
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${TARGET_COMPILE_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${TARGET_LINKER_FLAGS})

if(ENABLE_PERF_MONITORING)
message("Will enable performance monitoring")
message(WARNING "Performance monitoring is support only on Linux")
message(WARNING "If you're running in a VM, performance monitoring will be broken, "
"and will likely break inference.")
add_definitions(-DENABLE_PERF_MONITORING)
endif()

add_library(xinfer STATIC x_inference_lib.c x_perf_monitor.c)

if(LIB_ONLY)
message("Will only build the library")
else()
message("Will build the library and the executable")
if (BUILD_FOR_DYNAMIC_LINKAGE)
message("Will build the executable for dynamic bundle linkage")
set(OBJS )
add_definitions(-DX_USE_DYNAMIC)
else()
if(NOT DEFINED LINKED_BUNDLE)
message(FATAL_ERROR "When building with static bundle linkage, bundle must be specified with -DLINKED_BUNDLE=")
endif()
if (NOT DEFINED LINKED_MODEL_NAME)
message(FATAL_ERROR "When building with static bundle linkage, model name must be specified with -DLINKED_MODEL_NAME=")
endif()

add_definitions(-DX_MODEL_NAME=${LINKED_MODEL_NAME})
set(OBJS ${LINKED_BUNDLE})
set_source_files_properties(${OBJS} PROPERTIES EXTERNAL_OBJECT TRUE GENERATED TRUE)
endif()
link_directories(${LIBRARY_OUTPUT_PATH})
add_executable(x-infer main.c ${OBJS})
target_link_libraries(x-infer xinfer dl m)
endif()