forked from onnx/onnx
-
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.
Bulk commit for releasing Open Neural Network Exchange (ONNX)
- Loading branch information
0 parents
commit b8ab0ed
Showing
43 changed files
with
5,917 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
## General | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.cuo | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
|
||
# Compiled protocol buffers | ||
*.pb.h | ||
*.pb.cc | ||
*_pb2.py | ||
|
||
# Compiled python | ||
*.pyc | ||
|
||
# Compiled MATLAB | ||
*.mex* | ||
|
||
# IPython notebook checkpoints | ||
.ipynb_checkpoints | ||
|
||
# Editor temporaries | ||
*.swn | ||
*.swo | ||
*.swp | ||
*~ | ||
|
||
# Sublime Text settings | ||
*.sublime-workspace | ||
*.sublime-project | ||
|
||
# Eclipse Project settings | ||
*.*project | ||
.settings | ||
|
||
# QtCreator files | ||
*.user | ||
|
||
# PyCharm files | ||
.idea | ||
|
||
# Visual Studio Code files | ||
.vscode | ||
|
||
# OSX dir files | ||
.DS_Store | ||
|
||
## ONNX | ||
|
||
# build, distribute, and bins (+ python proto bindings) | ||
build | ||
build_* | ||
.build_debug/* | ||
.build_release/* | ||
|
||
# setup.py intermediates | ||
.eggs | ||
dist | ||
onnx.egg-info |
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,4 @@ | ||
[submodule "third_party/pybind11"] | ||
path = third_party/pybind11 | ||
url = https://github.com/pybind/pybind11.git | ||
branch = master |
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,19 @@ | ||
os: linux | ||
dist: trusty | ||
sudo: required | ||
language: python | ||
|
||
install: | ||
- ./.travis/install.sh | ||
|
||
script: | ||
- ./.travis/build.sh | ||
|
||
cache: | ||
- directories: | ||
- $HOME/.build_cache | ||
- $HOME/.ccache | ||
|
||
env: | ||
global: | ||
- PB_VERSION=2.6.1 |
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,17 @@ | ||
#!/bin/bash | ||
|
||
scripts_dir=$(dirname $(readlink -e "${BASH_SOURCE[0]}")) | ||
source "$scripts_dir/common"; | ||
|
||
onnx_dir="$PWD" | ||
|
||
# install onnx | ||
cd $onnx_dir | ||
ccache -z | ||
pip install . | ||
ccache -s | ||
|
||
# onnx tests | ||
cd $onnx_dir | ||
pip install pytest-cov | ||
pytest |
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,14 @@ | ||
set -ex | ||
|
||
die() { | ||
echo >&2 "$@" | ||
exit 1 | ||
} | ||
|
||
workdir="$HOME/work" | ||
mkdir -p "$workdir" | ||
build_cache_dir="$HOME/.build_cache/pb-$PB_VERSION" | ||
mkdir -p "$build_cache_dir" | ||
|
||
# setup ccache | ||
export PATH="/usr/lib/ccache:$PATH" |
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,19 @@ | ||
#!/bin/bash | ||
|
||
scripts_dir=$(dirname $(readlink -e "${BASH_SOURCE[0]}")) | ||
source "$scripts_dir/common" | ||
|
||
# install protobuf | ||
pb_dir="$build_cache_dir/pb" | ||
mkdir -p $pb_dir | ||
wget -qO- "https://github.com/google/protobuf/releases/download/v$PB_VERSION/protobuf-$PB_VERSION.tar.gz" | tar -xvz -C "$pb_dir" --strip-components 1 | ||
ccache -z | ||
cd "$pb_dir" && ./configure && make && make check && sudo make install && sudo ldconfig | ||
ccache -s | ||
|
||
if ! hash python 2>/dev/null; then | ||
sudo apt-get install python | ||
fi | ||
if ! hash pip 2>/dev/null; then | ||
sudo apt-get install python-pip | ||
fi |
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,12 @@ | ||
Open Neural Network Exchange | ||
|
||
Copyright (c) Facebook, Inc. and Microsoft Corporation. | ||
All rights reserved. | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,71 @@ | ||
Open Neural Network Exchange (ONNX) | ||
======== | ||
|
||
Open Neural Network Exchange (ONNX) is the first step toward an open ecosystem that empowers AI developers | ||
to choose the right tools as their project evolves. ONNX provides an open source format for AI models. | ||
It defines an extensible computation graph model, as well as definitions of built-in operators and standard | ||
data types. Initially we focus on the capabilities needed for inferencing (evaluation). | ||
|
||
Caffe2, PyTorch, and Cognitive Toolkit will be supporting ONNX. Enabling interoperability between different | ||
frameworks and streamlining the path from research to production will increase the speed of innovation in | ||
the AI community. We are an early stage and we invite the community to submit feedback and help us further | ||
evolve ONNX. | ||
|
||
|
||
# Folder Structure | ||
|
||
- onnx/: the main folder that all code lies under | ||
- onnx.proto: the protobuf (v2.6.1) that contains all the structures | ||
- checker.py: utility to check whether a serialized ONNX proto is legal. | ||
- defs/: subfolder that defines the ONNX operators. | ||
- test/: test files | ||
|
||
# Installation | ||
|
||
Currently ONNX can only be built from source: | ||
|
||
``` | ||
git clone --recursive https://github.com/onnx/onnx.git | ||
pip install onnx/ | ||
``` | ||
|
||
After installation, do | ||
|
||
``` | ||
python -c 'import onnx' | ||
``` | ||
|
||
to verify it works. | ||
|
||
# Testing | ||
|
||
ONNX uses [pytest](https://docs.pytest.org) as test driver. In order to run tests, first you need to install pytest: | ||
|
||
``` | ||
pip install pytest-cov | ||
``` | ||
|
||
After installing pytest, do | ||
|
||
``` | ||
pytest | ||
``` | ||
|
||
to run tests. | ||
|
||
# Development | ||
|
||
During development it's convenient to install ONNX in development mode: | ||
|
||
``` | ||
git clone --recursive https://github.com/onnx/onnx.git | ||
pip install -e onnx/ | ||
``` | ||
Then, after you have made changes to | ||
|
||
- Python files, the changes are immediatly effective in your installation, you do not need to install again. | ||
- C++ files, you need to do install again to trigger the native extension build. | ||
|
||
# License | ||
|
||
[MIT License](LICENSE) |
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,5 @@ | ||
#!/bin/bash | ||
set -e | ||
export ONNX_BINARY_BUILD=1 | ||
# Recommended by https://github.com/conda/conda-build/issues/1191 | ||
python setup.py install --single-version-externally-managed --record=record.txt |
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,33 @@ | ||
{% set version = "0.1" %} | ||
|
||
package: | ||
name: onnx | ||
version: {{ version }} | ||
|
||
source: | ||
path: .. | ||
|
||
build: | ||
number: 1 | ||
skip: True # [win] | ||
|
||
requirements: | ||
build: | ||
- protobuf | ||
- numpy | ||
- setuptools | ||
- python | ||
- pytest-runner | ||
run: | ||
- python | ||
- protobuf | ||
- numpy | ||
|
||
about: | ||
home: https://github.com/onnx/onnx/ | ||
license: BSD | ||
summary: Open Neural Network Exchange library | ||
|
||
extra: | ||
recipe-maintainers: | ||
- ezyang |
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,84 @@ | ||
Open Neural Network Exchange (ONNX) | ||
========= | ||
|
||
ONNX is an open specification that consists of the following components: | ||
|
||
1) Definition of an extensible computation graph model. | ||
|
||
2) Definition of built-in operators and standard data types. | ||
|
||
__Some notes on language in this and all related documents__: | ||
|
||
1. The use of SHOULD, MUST, MAY and so on in this document is consistent with [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt). | ||
|
||
2. The use of 'list' shall denote an ordered collection of items, 'set' shall denote an unordered collection of unique elements, and 'bag' an unordered colletion of possibly non-unique elements. | ||
|
||
Extensible computation graph model | ||
---------------------------------- | ||
|
||
ONNX specifies the portable, serialized format of the computation graph. It may not be the form a framework chooses to use and | ||
manipulate internally. For example, a framework may keep the graph in memory in another format that it finds more efficient to | ||
manipulate for optimization passes. We make use of protobuf2 (with oneof, added in protobuf 2.6.1) for the serialized format. | ||
|
||
### Graphs | ||
|
||
Each computation dataflow graph is structured as a list of nodes that form a graph, which MUST be free of cycles. | ||
Nodes have one or more inputs and one or more outputs. Each node is a call to an operator. | ||
|
||
#### Metadata | ||
|
||
The following are the metadata properties of a model graph: | ||
|
||
|Name|Type|Format|Description| | ||
|----|----|------|-----------| | ||
|name|string|Valid C identifier|A name for the model.| | ||
|domain|string|Valid DNS name|A namespace for the model, following the style of package names, that is, reverse DNS domain name.| | ||
|ir_version|int64||The version of the IR format specification| | ||
|doc_string|string|Free form|A human-readable documentation string intended to summarize the purpose of the model.| | ||
|
||
|
||
#### Names Within a Graph | ||
|
||
We organize names into separate namespaces. Names must be unique within a namespace. | ||
The namespaces are as follows: | ||
- Node: These names identify specific nodes in the graph but not necessarily any particular input or output of the node. | ||
- Graph: These names identify graphs in the protobuf. | ||
- Attribute: These names identify attribute names for extra attributes that are passed to operators. | ||
- Operator: These names identify particular operators. | ||
- Tensor: These names identify intermediate tensor values flowing through the computation of a graph. | ||
|
||
All names MUST adhere to C identifier syntax rules. | ||
|
||
#### Nodes | ||
|
||
Computation nodes are comprised of a name, a list of named inputs, a list of named outputs, and a list of attributes. | ||
|
||
Edges in the computation graph are established by outputs of one node being referenced by name in the inputs of a | ||
subsequent node. | ||
|
||
The list of nodes defining the top-level computation graph MUST be ordered topologically; that is, if node K | ||
follows node N in the graph, none of the data inputs of N may refer to outputs of K; further, no control input of N may refer to K. | ||
|
||
|
||
Built-in Operators and Standard Data Types | ||
------------------------------------------ | ||
|
||
### Operators | ||
|
||
See [the operator documentation](Operators.md) for details | ||
|
||
|
||
### Standard data types | ||
|
||
The following data types are supported by ONNX. Additional data types can be supported by frameworks. | ||
|
||
|Group|Name|Description| | ||
|-----|----|-----------| | ||
|Floating Point Types|__float16, float32, float64__|Values adhering to the IEEE 754-2008 standard representation of floating-point data.| | ||
|Signed Integer Types|__int8, int16,int32,int64__|Signed integers are supported for 8-64 bit widths.| | ||
|Unsigned Integer Types|__uint8,uint16__| Unsigned integers of 8 or 16 bits are supported.| | ||
|Complex Types|__complex64,complex128__|A complex number with either 32- or 64-bit real and imaginary parts.| | ||
|Other|__string__|Strings represent textual data. All strings are encoded using UTF-8.| | ||
|Ohter|__bool__|Boolean value represent data with only two values, typically _true_ and _false_.| | ||
|Other|__handle__|Handles are opaque types holding a 64-bit integer.| | ||
|Collections|__sparse and dense tensor__|Tensors are a generalization of vectors and matrices; whereas vectors have one dimension, and matrices two, tensors can have any number of dimenstions, including zero. A zero-dimensional tensor is equivalent to a scalar.| |
Oops, something went wrong.