Skip to content

Commit

Permalink
Merge branch 'main' into exclude-test-data
Browse files Browse the repository at this point in the history
  • Loading branch information
cbourjau committed Mar 4, 2024
2 parents 903b9f4 + b590c5f commit 674376a
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 35 deletions.
10 changes: 3 additions & 7 deletions .azure-pipelines/Windows-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ jobs:
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
displayName: Add conda to PATH

# cmake 3.28.3 failed to find protobuf installed from conda-forge
# https://gitlab.kitware.com/cmake/cmake/-/issues/25704
- script: |
choco install cmake --version 3.27.9 -y
cmake --version
displayName: Install specific version of CMake and check version
- script: |
conda create --yes --quiet --name py$(python.version) python=$(python.version)
if '$(protobuf_type)' == 'External' (
Expand All @@ -72,6 +65,9 @@ jobs:
)
displayName: Create Anaconda environment
- powershell: echo "##vso[task.setvariable variable=CMAKE_PREFIX_PATH]$env:CONDA/envs/py$(python.version)/Library"
displayName: Set CMAKE_PREFIX_PATH

- script: |
call activate py$(python.version)
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_urls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
subfolder: docs
file_types: .md,.py,.rst,.ipynb,.cc,.h,.cpp
print_all: false
timeout: 2
timeout: 10
retry_count# : 2
exclude_urls: https://github.com/onnx/onnx/blob/main/docs/Operators,https://github.com/onnx/onnx/pull/436
force_pass: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reuse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: REUSE Compliance Check
uses: fsfe/reuse-action@4f2804894b54004c8ed4b8a62b7c649e54a3aa4b # v2.0.0
uses: fsfe/reuse-action@a46482ca367aef4454a87620aa37c2be4b2f8106 # v3.0.0
2 changes: 1 addition & 1 deletion VERSION_NUMBER
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.16.0
1.17.0
2 changes: 1 addition & 1 deletion docs/Hub.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ All other fields in the `metadata` field are optional for the client but provide
The simplest way to add a model to the official `onnx/models` version model hub is to follow
[these guidelines](https://github.com/onnx/models/blob/main/contribute.md) to contribute your model. Once contributed,
ensure that your model has a markdown table in its `README.md`
([Example](https://github.com/onnx/models/tree/main/vision/classification/mobilenet)). The model hub
([Example](https://github.com/onnx/models/tree/main/validated/vision/classification/mobilenet)). The model hub
manifest generator will pull information from these markdown tables. To run the generator:

```shell script
Expand Down
4 changes: 2 additions & 2 deletions docs/docsgen/source/intro/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ to build the graph among the {ref}`l-onnx-make-function`:
(an operator type), its inputs and outputs
- `make_graph`: a function to create an ONNX graph with
the objects created by the two previous functions
- `make_model`: a last function with merges the graph and
- `make_model`: a last function which merges the graph and
additional metadata

All along the creation, we need to give a name to every input,
Expand Down Expand Up @@ -1500,7 +1500,7 @@ object of type `ModelProto`. But it is not. According to
[Protobuf 4, changes](https://developers.google.com/protocol-buffers/docs/news/2022-05-06),
this is no longer possible after version 4 and it is safer to assume the
only way to get a hold on the content is to serialize the model
into bytes, give it the C function, then deserialize it.
into bytes, give it to the C function, then deserialize it.
Functions like `check_model` or
`shape_inference` are calling `SerializeToString` then
`ParseFromString` before checking the model with a C code.
Expand Down
4 changes: 2 additions & 2 deletions onnx/common/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ struct Graph final {

void addInitializer(Tensor& initializer) {
if (initializer.name().empty()) {
initializer.setName(ONNX_NAMESPACE::to_string(getNextUnique()));
initializer.setName(toVarName(getNextUnique()));
}
initializers_.push_back(initializer);
initializer_names_.push_back(initializer.name());
Expand Down Expand Up @@ -1166,7 +1166,7 @@ struct Graph final {
}

Value* addInitializerAndInput(const Tensor& initializer) {
return addInitializerAndInput(initializer, ONNX_NAMESPACE::to_string(getNextUnique()));
return addInitializerAndInput(initializer, toVarName(getNextUnique()));
}

// Erases from graph initializer list, initializer names list, and as a graph input
Expand Down
24 changes: 24 additions & 0 deletions onnx/defs/schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,30 @@ OpSchemaRegistry* OpSchemaRegistry::Instance() {

void OpSchema::CheckInputOutputType(struct InferenceContext& ctx) const {
std::unordered_map<std::string, std::string> type_constraints;
if (inputs_.empty() && ctx.getNumInputs() > 0) {
fail_check(
"Node (",
domain(),
"::",
Name(),
":",
since_version(),
") takes zero inputs, but got ",
ctx.getNumInputs(),
" in graph");
}
if (outputs_.empty() && ctx.getNumOutputs() > 0) {
fail_check(
"Node (",
domain(),
"::",
Name(),
":",
since_version(),
") yields zero outputs, but got ",
ctx.getNumOutputs(),
" in graph");
}
// check all input types
for (size_t in_idx = 0; in_idx < ctx.getNumInputs(); ++in_idx) {
// If the last input is Variadic by definition, checker still needs to check the rest of actual input's type
Expand Down
2 changes: 1 addition & 1 deletion onnx/onnx-ml.proto
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ message NodeProto {
repeated string output = 2; // namespace Value

// An optional identifier for this node in a graph.
// This field MAY be absent in ths version of the IR.
// This field MAY be absent in this version of the IR.
optional string name = 3; // namespace Node

// The symbolic identifier of the Operator to execute.
Expand Down
2 changes: 1 addition & 1 deletion onnx/onnx-ml.proto3
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ message NodeProto {
repeated string output = 2; // namespace Value

// An optional identifier for this node in a graph.
// This field MAY be absent in ths version of the IR.
// This field MAY be absent in this version of the IR.
string name = 3; // namespace Node

// The symbolic identifier of the Operator to execute.
Expand Down
2 changes: 1 addition & 1 deletion onnx/onnx.in.proto
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ message NodeProto {
repeated string output = 2; // namespace Value

// An optional identifier for this node in a graph.
// This field MAY be absent in ths version of the IR.
// This field MAY be absent in this version of the IR.
optional string name = 3; // namespace Node

// The symbolic identifier of the Operator to execute.
Expand Down
2 changes: 1 addition & 1 deletion onnx/onnx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ message NodeProto {
repeated string output = 2; // namespace Value

// An optional identifier for this node in a graph.
// This field MAY be absent in ths version of the IR.
// This field MAY be absent in this version of the IR.
optional string name = 3; // namespace Node

// The symbolic identifier of the Operator to execute.
Expand Down
2 changes: 1 addition & 1 deletion onnx/onnx.proto3
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ message NodeProto {
repeated string output = 2; // namespace Value

// An optional identifier for this node in a graph.
// This field MAY be absent in ths version of the IR.
// This field MAY be absent in this version of the IR.
string name = 3; // namespace Node

// The symbolic identifier of the Operator to execute.
Expand Down
27 changes: 27 additions & 0 deletions onnx/test/shape_inference_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9875,6 +9875,33 @@ def test_compress_with_axis(self) -> None:
)
self._assert_inferred(graph, [make_tensor_value_info("output", TensorProto.INT64, (2, "N", 3, None))]) # type: ignore

def test_check_type_when_schema_has_empty_io(self):
input = """
<
ir_version: 7,
opset_import: ["" : 1]
>
agraph (X, Y) => (Z)
{
Z = CustomOp(X, Y)
}
"""
model = onnx.parser.parse_model(input)

op_schema = defs.OpSchema(
"CustomOp",
"",
1,
inputs=[],
outputs=[],
)
onnx.defs.register_schema(op_schema)
with self.assertRaises(onnx.shape_inference.InferenceError):
onnx.shape_inference.infer_shapes(model, True)
onnx.defs.deregister_schema(
op_schema.name, op_schema.since_version, op_schema.domain
)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: Apache-2.0

[build-system]
requires = ["setuptools>=64", "protobuf>=3.20.2"]
requires = ["setuptools>=64", "protobuf>=3.20.2", "cmake"]
build-backend = "setuptools.build_meta"

[project]
Expand Down
4 changes: 2 additions & 2 deletions requirements-lintrunner.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This file is auto updated by dependabot
lintrunner-adapters>=0.12.1
# RUFF
ruff==0.2.1
ruff==0.3.0
# MYPY
mypy==1.8.0
types-protobuf==4.24.0.4
types-protobuf==4.24.0.20240129
# BLACK-ISORT
black==23.12.1
isort==5.13.2
Expand Down
12 changes: 0 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,6 @@ def run(self):
raise RuntimeError(
"-DONNX_DISABLE_EXCEPTIONS=ON option is only available for c++ builds. Python binding require exceptions to be enabled."
)
if (
"PYTHONPATH" in os.environ
and "pip-build-env" in os.environ["PYTHONPATH"]
):
# When the users use `pip install -e .` to install onnx and
# the cmake executable is a python entry script, there will be
# `Fix ModuleNotFoundError: No module named 'cmake'` from the cmake script.
# This is caused by the additional PYTHONPATH environment variable added by pip,
# which makes cmake python entry script not able to find correct python cmake packages.
# Actually, sys.path is well enough for `pip install -e .`.
# Therefore, we delete the PYTHONPATH variable.
del os.environ["PYTHONPATH"]
subprocess.check_call(cmake_args)

build_args = [CMAKE, "--build", os.curdir]
Expand Down

0 comments on commit 674376a

Please sign in to comment.