-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
75 changed files
with
5,731 additions
and
1,244 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,36 @@ | ||
tf2onnx - common issues when converting models. | ||
======== | ||
|
||
## tensorflow op is not supported | ||
Example: | ||
|
||
```ValueError: tensorflow op NonMaxSuppression is not supported``` | ||
|
||
means that the given tensorflow op is not mapped to ONNX. This could have multiple reasons: | ||
|
||
(1) we have not gotten to implement it. NonMaxSuppression is such an example: we implemented NonMaxSuppressionV2 and NonMaxSuppressionV3 but not the older NonMaxSuppression op. | ||
|
||
To get this fixed you can open an issue or send us a PR with a fix. | ||
|
||
(2) There is no direct mapping to ONNX. | ||
|
||
Sometimes there is no direct mapping from tensorflow to ONNX. We took care are of the most common cases. But for less frequently used ops there might be a mapping missing. To get this fixed there 2 options: | ||
|
||
a) in tf2onnx you can compose the op out of different ops. A good example for this the [Erf op](https://github.com/onnx/tensorflow-onnx/blob/master/tf2onnx/onnx_opset/math.py#L317). Before opset-9 this tf2onnx composes Erf with other ONNX ops. | ||
|
||
b) You request the missing op to be added to [ONNX](https://github.com/onnx/onnx). After it is added to ONNX and some runtime implements it we'll add it to tf2onnx. You can see that this happened for the Erf Op. Starting with opset-9, ONNX added it - tf2onnx no longer composes the op and instead passes it to ONNX. | ||
|
||
c) The op is too complex to compose and it's to exotic to add to ONNX. In that cases you can use a custom op to implement it. Custom ops are documented in the [README](README.md) and there is an example [here](https://github.com/onnx/tensorflow-onnx/blob/master/examples/custom_op_via_python.py). There are 2 flavors of it: | ||
- you could compose the functionality by using multiple ONNX ops. | ||
- you can implement the op in your runtime as custom op (assuming that most runtimes do have such a mechanism) and then map it in tf2onnx as custom op. | ||
|
||
## get tensor value: ... must be Const | ||
|
||
There is a common group of errors that reports ```get tensor value: ... must be Const```. | ||
The reason for this is that there is a dynamic input of a tensorflow op but the equivalent ONNX op uses a static attribute. In other words in tensorflow that input is only known at runtime but in ONNX it need to be known at graph creation time. | ||
|
||
An example of this is the [ONNX Slice operator before opset-10](https://github.com/onnx/onnx/blob/master/docs/Changelog.md#Slice-1) - the start and end of the slice are static attributes that need to be known at graph creation. In tensorflow the [strided slice op](https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/strided-slice) allows dynamic inputs. tf2onnx will try to find the real value of begin and end of the slice and can find them in most cases. But if those are real dynamic values calculate at runtime it will result in the message ```get tensor value: ... must be Const```. | ||
|
||
You can pass the options ```--fold_const``` in the tf2onnx command line that allows tf2onnx to apply more aggressive constant folding which will increase chances to find a constant. | ||
|
||
If this doesn't work the model is most likely not to be able to convert to ONNX. We used to see this a lot of issue with the ONNX Slice op and in opset-10 was updated for exactly this reason. |
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 +1 @@ | ||
1.5.1 | ||
1.5.2 |
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,3 @@ | ||
[paths] | ||
source = | ||
./ |
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,14 +1,38 @@ | ||
# Test against latest onnxruntime nightly package | ||
|
||
jobs: | ||
- template: 'templates/job_generator.yml' | ||
parameters: | ||
tf_versions: ['1.13.1'] | ||
onnx_opsets: [''] | ||
onnx_backends: | ||
onnxruntime: [''] | ||
job: | ||
steps: | ||
- template: 'unit_test.yml' | ||
parameters: | ||
onnx_opsets: ['10', '9', '8', '7'] | ||
stages: | ||
- stage: | ||
jobs: | ||
- template: 'templates/job_generator.yml' | ||
parameters: | ||
platforms: ['linux', 'windows', 'mac'] | ||
python_versions: ['3.6', '3.5'] | ||
tf_versions: ['1.13.1','1.12', '1.11', '1.10', '1.9', '1.8', '1.7', '1.6', '1.5'] | ||
onnx_opsets: [''] | ||
onnx_backends: {onnxruntime: ['nightly']} | ||
job: | ||
steps: | ||
- template: 'unit_test.yml' | ||
report_coverage: 'True' | ||
|
||
- template: 'templates/job_generator.yml' | ||
parameters: | ||
platforms: ['linux', 'windows', 'mac'] | ||
python_versions: ['3.7', '3.6', '3.5'] | ||
tf_versions: ['1.14'] | ||
onnx_opsets: [''] | ||
onnx_backends: {onnxruntime: ['nightly']} | ||
job: | ||
steps: | ||
- template: 'unit_test.yml' | ||
report_coverage: 'True' | ||
|
||
- template: 'templates/combine_test_coverage.yml' | ||
|
||
schedules: | ||
- cron: "0 10 * * *" | ||
displayName: Daily onnxruntime nightly unittest | ||
branches: | ||
include: | ||
- master | ||
always: true |
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
48 changes: 48 additions & 0 deletions
48
ci_build/azure_pipelines/templates/combine_test_coverage.yml
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,48 @@ | ||
# combine and report unittest coverage | ||
|
||
parameters: | ||
artifact_name: 'single_test_coverage' | ||
|
||
stages: | ||
- stage: | ||
jobs: | ||
- job: 'combine_and_report_coverage' | ||
variables: | ||
CI_ARTIFACT_NAME: '${{ parameters.artifact_name }}' | ||
|
||
pool: | ||
vmImage: 'ubuntu-16.04' | ||
|
||
steps: | ||
- task: DownloadBuildArtifacts@0 | ||
displayName: 'Download Single Test Coverage' | ||
inputs: | ||
artifactName: '${{ parameters.artifact_name }}' | ||
downloadPath: $(System.DefaultWorkingDirectory) | ||
|
||
- task: CondaEnvironment@1 | ||
inputs: | ||
createCustomEnvironment: 'true' | ||
environmentName: 'tf2onnx' | ||
packageSpecs: 'python=3.6' | ||
updateConda: 'false' | ||
|
||
- bash: | | ||
pip install -U coverage | ||
condition: succeeded() | ||
displayName: 'Install Coverage' | ||
- bash: | | ||
cat ${CI_ARTIFACT_NAME}/.coveragerc_paths* >> ci_build/azure_pipelines/coveragerc | ||
coverage combine --rcfile ci_build/azure_pipelines/coveragerc ${CI_ARTIFACT_NAME} | ||
coverage report | ||
coverage html -d ${BUILD_ARTIFACTSTAGINGDIRECTORY}/coverage_report | ||
condition: succeeded() | ||
displayName: 'Combine And Report Test Coverage' | ||
- task: PublishBuildArtifacts@1 | ||
condition: succeeded() | ||
inputs: | ||
pathtoPublish: '$(Build.ArtifactStagingDirectory)' | ||
artifactName: 'test_coverage_report' | ||
displayName: 'Deploy Test Coverage Report' |
Oops, something went wrong.