diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml
index 6c3f2eb0fbbe1..725c40c2ded53 100644
--- a/.github/workflows/rust-ci.yml
+++ b/.github/workflows/rust-ci.yml
@@ -24,7 +24,7 @@ jobs:
name: Download prebuilt ONNX Runtime archive from build.rs
runs-on: ubuntu-latest
env:
- ORT_RUST_STRATEGY=download
+ ORT_RUST_STRATEGY: download
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rust-toolchain-setup
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
index 95607f297c6bd..c94e3fa5bcb8c 100644
--- a/.github/workflows/stale.yml
+++ b/.github/workflows/stale.yml
@@ -13,7 +13,7 @@ jobs:
issues: write
pull-requests: write
steps:
- - uses: actions/stale@v8.0.0
+ - uses: actions/stale@v9.0.0
with:
# Comma separated list of labels that can be assigned to issues to exclude them from being marked as stale
exempt-issue-labels: contributions welcome, feature request, regression
@@ -29,7 +29,7 @@ jobs:
# Label you want to apply to issues that have been inactive for the amount of time specified by days-before-issue-stale
stale-issue-label: "stale"
# Comment that you want to add to issues that are labeled by the actions/stale action
- stale-issue-message: "This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs. If further support is needed, please provide an update and/or more details."
+ stale-issue-message: "This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details."
# Comment that you want to add to issues that are closed by the actions/stale action
close-issue-message: "This issue has been automatically closed due to inactivity. Please reactivate if further support is needed."
# If you never want this action to label PRs, set this value to -1
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index ba24e7eebfb03..3a780f87d2300 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -49,13 +49,10 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- - uses: actions/setup-python@v4
- with:
- python-version: '3.8.x'
- architecture: 'x64'
- uses: conda-incubator/setup-miniconda@v2
with:
- activate-environment: ""
+ activate-environment: "ort_build"
+ python-version: 3.8
- name: 'Install LLVM-Dev'
shell: pwsh
run: |
diff --git a/.pipelines/windowsai-steps.yml b/.pipelines/windowsai-steps.yml
index 45ebf889c5da1..292ce60c6b6cf 100644
--- a/.pipelines/windowsai-steps.yml
+++ b/.pipelines/windowsai-steps.yml
@@ -84,7 +84,7 @@ jobs:
7z x cmake-3.26.3-windows-x86_64.zip
set PYTHONHOME=$(Build.BinariesDirectory)\${{ parameters.PythonPackageName }}.3.9.7\tools
set PYTHONPATH=$(Build.BinariesDirectory)\${{ parameters.PythonPackageName }}.3.9.7\tools
- $(Build.BinariesDirectory)\${{ parameters.PythonPackageName }}.3.9.7\tools\python.exe "$(Build.SourcesDirectory)\tools\ci_build\build.py" --build_dir $(Build.BinariesDirectory) --build_shared_lib --enable_onnx_tests --ms_experimental --use_dml --use_winml --cmake_generator "Visual Studio 17 2022" --update --config RelWithDebInfo --enable_lto --use_telemetry --disable_rtti --enable_wcos $(BuildFlags) --cmake_extra_defines CMAKE_SYSTEM_VERSION=10.0.19041.0 --cmake_path $(Build.BinariesDirectory)\cmake-3.26.3-windows-x86_64\bin\cmake.exe --ctest_path $(Build.BinariesDirectory)\cmake-3.26.3-windows-x86_64\bin\ctest.exe
+ $(Build.BinariesDirectory)\${{ parameters.PythonPackageName }}.3.9.7\tools\python.exe "$(Build.SourcesDirectory)\tools\ci_build\build.py" --build_dir $(Build.BinariesDirectory) --build_shared_lib --enable_onnx_tests --ms_experimental --use_dml --use_winml --cmake_generator "Visual Studio 17 2022" --update --config RelWithDebInfo --enable_lto --use_telemetry --disable_rtti --enable_wcos $(BuildFlags) --cmake_extra_defines "CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO=/PROFILE" "CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO=/PROFILE" CMAKE_SYSTEM_VERSION=10.0.19041.0 --cmake_path $(Build.BinariesDirectory)\cmake-3.26.3-windows-x86_64\bin\cmake.exe --ctest_path $(Build.BinariesDirectory)\cmake-3.26.3-windows-x86_64\bin\ctest.exe
workingDirectory: '$(Build.BinariesDirectory)'
displayName: 'Generate cmake config'
diff --git a/.vscode/settings.json b/.vscode/settings.json
index c4a08e3232a82..2f2adc78f6de9 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -13,6 +13,7 @@
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
+ "editor.defaultFormatter": "ms-python.black-formatter"
},
// Enable Python linting and Pylance type checking
"python.analysis.typeCheckingMode": "basic",
diff --git a/README.md b/README.md
index 22ef387f5a7cd..33bce867e3bde 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@
|Android|[](https://dev.azure.com/onnxruntime/onnxruntime/_build/latest?definitionId=53)||
|iOS|[](https://dev.azure.com/onnxruntime/onnxruntime/_build/latest?definitionId=134)||
|Web|[](https://dev.azure.com/onnxruntime/onnxruntime/_build/latest?definitionId=161)||
-|Other|[](https://dev.azure.com/onnxruntime/onnxruntime/_build/latest?definitionId=187&repoName=microsoft%2Fonnxruntime)
[](https://dev.azure.com/onnxruntime/onnxruntime/_build/latest?definitionId=164)||
+|Other|[](https://dev.azure.com/onnxruntime/onnxruntime/_build/latest?definitionId=187&repoName=microsoft%2Fonnxruntime)||
## Third-party Pipeline Status
diff --git a/build_arm64x.bat b/build_arm64x.bat
new file mode 100644
index 0000000000000..fbcdd373086a9
--- /dev/null
+++ b/build_arm64x.bat
@@ -0,0 +1,12 @@
+:: Copyright (c) Microsoft Corporation. All rights reserved.
+:: Licensed under the MIT License.
+
+@echo off
+
+setlocal
+set PATH=C:\Program Files\Git\usr\bin;%PATH%
+set LINK_REPRO_NAME=/mylink.rsp
+
+rem Requires a Python install to be available in your PATH
+python "%~dp0\tools\ci_build\build.py" --arm64 --buildasx --build_dir "%~dp0\build\arm64-x" %*
+python "%~dp0\tools\ci_build\build.py" --arm64ec --buildasx --build_dir "%~dp0\build\arm64ec-x" %*
diff --git a/cgmanifests/generated/cgmanifest.json b/cgmanifests/generated/cgmanifest.json
index 12fbb291c3a70..137ea8a50c011 100644
--- a/cgmanifests/generated/cgmanifest.json
+++ b/cgmanifests/generated/cgmanifest.json
@@ -36,7 +36,7 @@
"component": {
"type": "git",
"git": {
- "commitHash": "29bf8085f3bf17b84d30e34b3d7ff8248fda404e",
+ "commitHash": "dcd5bd5fd593e31465af3d9ef291d26c646b0a4f",
"repositoryUrl": "https://github.com/abseil/abseil-cpp.git"
},
"comments": "abseil_cpp"
@@ -126,7 +126,7 @@
"component": {
"type": "git",
"git": {
- "commitHash": "f8d7d77c06936315286eb55f8de22cd23c188571",
+ "commitHash": "530d5c8c84abd2a46f38583ee817743c9b3a42b4",
"repositoryUrl": "https://github.com/google/googletest.git"
},
"comments": "googletest"
@@ -316,7 +316,7 @@
"component": {
"type": "git",
"git": {
- "commitHash": "a4f72a314a85732ed67d5aa8d1088d207a7e0e61",
+ "commitHash": "5356c4a943a35e74d7cdc69486afcb8703b9a59a",
"repositoryUrl": "https://github.com/ROCmSoftwarePlatform/composable_kernel.git"
},
"comments": "composable_kernel"
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index a9dc15b319c37..4a98849c05ef1 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -87,6 +87,7 @@ option(onnxruntime_USE_QNN "Build with QNN support" OFF)
option(onnxruntime_USE_SNPE "Build with SNPE support" OFF)
option(onnxruntime_USE_RKNPU "Build with RKNPU support" OFF)
option(onnxruntime_USE_DNNL "Build with DNNL support" OFF)
+option(onnxruntime_USE_JBLAS "Build MLAS with JBLAS support" ON)
option(onnxruntime_USE_JSEP "Build with JavaScript implemented kernels support" OFF)
option(onnxruntime_BUILD_UNIT_TESTS "Build ONNXRuntime unit tests" ON)
option(onnxruntime_BUILD_CSHARP "Build C# library" OFF)
@@ -1166,6 +1167,17 @@ if (onnxruntime_USE_DNNL)
add_compile_definitions(DNNL_OPENMP)
endif()
+set(USE_JBLAS FALSE)
+if (onnxruntime_USE_JBLAS AND NOT onnxruntime_MINIMAL_BUILD)
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND onnxruntime_target_platform STREQUAL "x86_64")
+ add_compile_definitions(MLAS_JBLAS)
+ set(USE_JBLAS TRUE)
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND onnxruntime_target_platform STREQUAL "x64")
+ add_compile_definitions(MLAS_JBLAS)
+ set(USE_JBLAS TRUE)
+ endif()
+endif()
+
# TVM EP
if (onnxruntime_USE_TVM)
if (NOT TARGET tvm)
@@ -1269,7 +1281,7 @@ if (onnxruntime_USE_OPENVINO)
add_definitions(-DOPENVINO_2023_1=1)
elseif ($ENV{INTEL_OPENVINO_DIR} MATCHES "2023.2")
set(OPENVINO_VERSION "2023.2")
- add_definitions(-DOPENVINO_2023_1=1)
+ add_definitions(-DOPENVINO_2023_2=1)
elseif ($ENV{INTEL_OPENVINO_DIR} MATCHES "openvino")
set(OPENVINO_VERSION "2023.2")
add_definitions(-DOPENVINO_2023_2=1)
@@ -1293,6 +1305,14 @@ if (onnxruntime_USE_OPENVINO)
add_definitions(-DOPENVINO_CONFIG_CPU_FP16=1)
endif()
+ if (onnxruntime_USE_OPENVINO_NPU_FP16)
+ add_definitions(-DOPENVINO_CONFIG_NPU_FP16=1)
+ endif()
+
+ if (onnxruntime_USE_OPENVINO_NPU_U8)
+ add_definitions(-DOPENVINO_CONFIG_NPU_U8=1)
+ endif()
+
if (onnxruntime_USE_OPENVINO_GPU_FP32_NP)
add_definitions(-DOPENVINO_CONFIG_GPU_FP32=1)
add_definitions(-DOPENVINO_DISABLE_GRAPH_PARTITION=1)
@@ -1313,6 +1333,16 @@ if (onnxruntime_USE_OPENVINO)
add_definitions(-DOPENVINO_DISABLE_GRAPH_PARTITION=1)
endif()
+ if (onnxruntime_USE_OPENVINO_NPU_FP16_NP)
+ add_definitions(-DOPENVINO_CONFIG_NPU_FP16=1)
+ add_definitions(-DOPENVINO_DISABLE_GRAPH_PARTITION=1)
+ endif()
+
+ if (onnxruntime_USE_OPENVINO_NPU_U8_NP)
+ add_definitions(-DOPENVINO_CONFIG_NPU_U8=1)
+ add_definitions(-DOPENVINO_DISABLE_GRAPH_PARTITION=1)
+ endif()
+
if (onnxruntime_USE_OPENVINO_HETERO)
add_definitions(-DOPENVINO_CONFIG_HETERO=1)
add_definitions(-DDEVICE_NAME="${onnxruntime_USE_OPENVINO_DEVICE}")
@@ -1584,6 +1614,13 @@ set(VERSION_STRING "Internal Build" CACHE STRING "String representation of
if (WIN32)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${SYS_PATH_LIB})
list(APPEND onnxruntime_EXTERNAL_LIBRARIES debug Dbghelp)
+ # In a onecore build the umbrella libs already contains references to the APIs in advapi32, so in onecore build we do not need to link to advapi32
+ # In a non-onecore build, usually we also do not need to link to advapi32 because VC++ by default should have provide everything we need, except when the build target is Windows ARM32.
+ # In the future we will add a build option to allow users disabling all API uses from advapi32 because some Windows environments do not have these APIs. For example, some Windows do not have
+ # Windows Registry so we cannot query Registry values.
+ if(onnxruntime_target_platform STREQUAL "ARM" AND CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib)
+ list(APPEND onnxruntime_EXTERNAL_LIBRARIES advapi32)
+ endif()
else()
list(APPEND onnxruntime_EXTERNAL_LIBRARIES nsync::nsync_cpp)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${ICONV_LIB} ${CMAKE_DL_LIBS} Threads::Threads)
@@ -1773,3 +1810,8 @@ if(TARGET onnxruntime)
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
endif()
+
+if(DEFINED BUILD_AS_ARM64X)
+ set(ARM64X_TARGETS onnxruntime)
+ include("${CMAKE_SOURCE_DIR}/arm64x.cmake")
+endif()
diff --git a/cmake/arm64x.cmake b/cmake/arm64x.cmake
new file mode 100644
index 0000000000000..be476e09625bd
--- /dev/null
+++ b/cmake/arm64x.cmake
@@ -0,0 +1,33 @@
+set(arm64ReproDir "${CMAKE_SOURCE_DIR}/repros")
+
+if("${BUILD_AS_ARM64X}" STREQUAL "ARM64")
+ foreach (n ${ARM64X_TARGETS})
+ add_custom_target(mkdirs_${n} ALL COMMAND cmd /c (if exist \"${arm64ReproDir}/${n}_temp/\" rmdir /s /q \"${arm64ReproDir}/${n}_temp\") && mkdir \"${arm64ReproDir}/${n}_temp\" )
+ add_dependencies(${n} mkdirs_${n})
+ target_link_options(${n} PRIVATE "/LINKREPRO:${arm64ReproDir}/${n}_temp")
+ add_custom_target(${n}_checkRepro ALL COMMAND cmd /c if exist \"${n}_temp/*.obj\" if exist \"${n}\" rmdir /s /q \"${n}\" 2>nul && if not exist \"${n}\" ren \"${n}_temp\" \"${n}\" DEPENDS ${n}
+ WORKING_DIRECTORY ${arm64ReproDir})
+ endforeach()
+
+
+elseif("${BUILD_AS_ARM64X}" STREQUAL "ARM64EC")
+ foreach (n ${ARM64X_TARGETS})
+ set(ARM64_LIBS)
+ set(ARM64_OBJS)
+ set(ARM64_DEF)
+
+ file(GLOB ARM64_OBJS "${arm64ReproDir}/${n}/*.obj")
+ file(GLOB ARM64_DEF "${arm64ReproDir}/${n}/*.def")
+ file(GLOB ARM64_LIBS "${arm64ReproDir}/${n}/*.LIB")
+
+ if(NOT "${ARM64_DEF}" STREQUAL "")
+ set(ARM64_DEF "/defArm64Native:${ARM64_DEF}")
+ endif()
+ target_sources(${n} PRIVATE ${ARM64_OBJS})
+ target_link_options(${n} PRIVATE /machine:arm64x "${ARM64_DEF}")
+
+ if(NOT "${ARM64_LIBS}" STREQUAL "")
+ target_link_libraries(${n} PUBLIC ${ARM64_LIBS})
+ endif()
+ endforeach()
+endif()
diff --git a/cmake/deps.txt b/cmake/deps.txt
index 49142372ab86e..ff07803013071 100644
--- a/cmake/deps.txt
+++ b/cmake/deps.txt
@@ -12,7 +12,7 @@
# NOTE: You must run deps_update_and_upload.py and generate_cgmanifest.py when ready to test your changes in a CI.
# See https://microsoft.sharepoint.com/teams/ONNX2/_layouts/OneNote.aspx?id=%2Fteams%2FONNX2%2FShared%20Documents%2FNotebooks%2FONNX%20Ecosystem%20Team%20Notebook&wd=target%28Development.one%7C63D3AB47-51D1-4A62-9965-66882234BD44%2FAdd%20or%20update%20a%20dependency%20in%20deps.txt%7C0E9ED71D-89D5-40FA-B05F-C0123289C591%2F%29
#
-abseil_cpp;https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.0.zip;04271dfbfac59269b6939e1e9d5faf0d18a7ba91
+abseil_cpp;https://github.com/abseil/abseil-cpp/archive/dcd5bd5fd593e31465af3d9ef291d26c646b0a4f.zip;6cc204586014e189f5c0fe3274f83162fa7c700c
cxxopts;https://github.com/jarro2783/cxxopts/archive/3c73d91c0b04e2b59462f0a741be8c07024c1bc0.zip;6c6ca7f8480b26c8d00476e0e24b7184717fe4f0
date;https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.1.zip;2dac0c81dc54ebdd8f8d073a75c053b04b56e159
dlpack;https://github.com/dmlc/dlpack/archive/refs/tags/v0.6.zip;4d565dd2e5b31321e5549591d78aa7f377173445
@@ -27,7 +27,7 @@ fp16;https://github.com/Maratyszcza/FP16/archive/0a92994d729ff76a58f692d3028ca1b
fxdiv;https://github.com/Maratyszcza/FXdiv/archive/63058eff77e11aa15bf531df5dd34395ec3017c8.zip;a5658f4036402dbca7cebee32be57fb8149811e1
google_benchmark;https://github.com/google/benchmark/archive/refs/tags/v1.7.0.zip;e97c368b176e8614e3f1bf13dd9abcf6a7ad9908
google_nsync;https://github.com/google/nsync/archive/refs/tags/1.26.0.zip;5e7c00ef6bf5b787386fc040067903ec774e2752
-googletest;https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip;0ac421f2ec11af38b0fff0f1992184032731a8bc
+googletest;https://github.com/google/googletest/archive/530d5c8c84abd2a46f38583ee817743c9b3a42b4.zip;5e3a61db2aa975cfd0f97ba92c818744e7fa7034
googlexnnpack;https://github.com/google/XNNPACK/archive/0da379fc4808f9601faef392352018c741c0f297.zip;663883491e380b628e0a5b162b5f2658032fae73
json;https://github.com/nlohmann/json/archive/refs/tags/v3.10.5.zip;f257f8dc27c5b8c085dc887b40cddd18ae1f725c
microsoft_gsl;https://github.com/microsoft/GSL/archive/refs/tags/v4.0.0.zip;cf368104cd22a87b4dd0c80228919bb2df3e2a14
@@ -54,4 +54,4 @@ tensorboard;https://github.com/tensorflow/tensorboard/archive/373eb09e4c5d2b3cc2
cutlass;https://github.com/NVIDIA/cutlass/archive/refs/tags/v3.1.0.zip;757f90a795034a89d4f48a79d1f009f7a04c8dee
utf8_range;https://github.com/protocolbuffers/utf8_range/archive/72c943dea2b9240cd09efde15191e144bc7c7d38.zip;9925739c9debc0efa2adcb194d371a35b6a03156
extensions;https://github.com/microsoft/onnxruntime-extensions/archive/94142d8391c9791ec71c38336436319a2d4ac7a0.zip;4365ac5140338b4cb75a39944a4be276e3829b3c
-composable_kernel;https://github.com/ROCmSoftwarePlatform/composable_kernel/archive/a4f72a314a85732ed67d5aa8d1088d207a7e0e61.zip;f57357ab6d300e207a632d034ebc8aa036a090d9
+composable_kernel;https://github.com/ROCmSoftwarePlatform/composable_kernel/archive/5356c4a943a35e74d7cdc69486afcb8703b9a59a.zip;522382c2af437e09124287e5879ab64af5b2e299
diff --git a/cmake/external/abseil-cpp.natvis b/cmake/external/abseil-cpp.natvis
index 708d6ba18750b..1e5a36fb9efb9 100644
--- a/cmake/external/abseil-cpp.natvis
+++ b/cmake/external/abseil-cpp.natvis
@@ -30,7 +30,6 @@
- empty
size={ _size() }
size=({_size()})
diff --git a/cmake/external/dnnl.cmake b/cmake/external/dnnl.cmake
index 397c4d6abeb9a..d7b70640781d0 100644
--- a/cmake/external/dnnl.cmake
+++ b/cmake/external/dnnl.cmake
@@ -25,6 +25,16 @@ elseif(onnxruntime_USE_DNNL AND onnxruntime_DNNL_GPU_RUNTIME STREQUAL "ocl" AND
set(DNNL_GPU_CMAKE_ARGS "-DDNNL_GPU_RUNTIME=OCL " "-DOPENCLROOT=${onnxruntime_DNNL_OPENCL_ROOT}")
endif()
+if(onnxruntime_USE_DNNL AND onnxruntime_DNNL_AARCH64_RUNTIME STREQUAL "acl" AND onnxruntime_DNNL_ACL_ROOT STREQUAL "")
+ message(FATAL_ERROR "--dnnl_acl_root required")
+elseif(onnxruntime_USE_DNNL AND onnxruntime_DNNL_AARCH64_RUNTIME STREQUAL "" AND NOT (onnxruntime_DNNL_ACL_ROOT STREQUAL ""))
+ message(FATAL_ERROR "--dnnl_aarch64_runtime required")
+elseif(onnxruntime_USE_DNNL AND onnxruntime_DNNL_AARCH64_RUNTIME STREQUAL "acl" AND NOT (onnxruntime_DNNL_ACL_ROOT STREQUAL ""))
+ file(TO_CMAKE_PATH ${onnxruntime_DNNL_ACL_ROOT} onnxruntime_DNNL_ACL_ROOT)
+ set(ACL_INCLUDE_DIR ${onnxruntime_DNNL_ACL_ROOT}/arm_compute)
+ set(DNNL_AARCH64_CMAKE_ARGS "-DDNNL_AARCH64_USE_ACL=ON")
+endif()
+
if (onnxruntime_USE_DNNL)
set(DNNL_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/dnnl/src/dnnl/src)
set(DNNL_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/dnnl/install)
@@ -51,7 +61,7 @@ if (onnxruntime_USE_DNNL)
GIT_TAG ${DNNL_TAG}
# PATCH_COMMAND ${MKLDNN_PATCH_DISCARD_COMMAND} COMMAND ${DNNL_PATCH_COMMAND}
SOURCE_DIR ${DNNL_SOURCE}
- CMAKE_ARGS -DDNNL_BUILD_TESTS=OFF -DDNNL_ENABLE_CONCURRENT_EXEC=ON -DDNNL_BUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${DNNL_INSTALL} ${DNNL_GPU_CMAKE_ARGS}
+ CMAKE_ARGS -DDNNL_BUILD_TESTS=OFF -DDNNL_ENABLE_CONCURRENT_EXEC=ON -DDNNL_BUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${DNNL_INSTALL} ${DNNL_GPU_CMAKE_ARGS} ${DNNL_AARCH64_CMAKE_ARGS}
)
link_directories(${DNNL_LIB_DIR})
endif()
diff --git a/cmake/external/onnxruntime_external_deps.cmake b/cmake/external/onnxruntime_external_deps.cmake
index 0fa5163dc06bf..78f63227c8392 100644
--- a/cmake/external/onnxruntime_external_deps.cmake
+++ b/cmake/external/onnxruntime_external_deps.cmake
@@ -47,8 +47,8 @@ if (onnxruntime_BUILD_UNIT_TESTS)
FetchContent_Declare(
googletest
URL ${DEP_URL_googletest}
- FIND_PACKAGE_ARGS 1.14.0...<2.0.0 NAMES GTest
URL_HASH SHA1=${DEP_SHA1_googletest}
+ FIND_PACKAGE_ARGS 1.14.0...<2.0.0 NAMES GTest
)
endif()
@@ -124,7 +124,7 @@ if(CMAKE_CROSSCOMPILING AND NOT ONNX_CUSTOM_PROTOC_EXECUTABLE)
if(protoc_binary_SOURCE_DIR)
message("Use prebuilt protoc")
set(ONNX_CUSTOM_PROTOC_EXECUTABLE ${protoc_binary_SOURCE_DIR}/bin/protoc.exe)
- set(PROTOC_EXECUTABLE ${ONNX_CUSTOM_PROTOC_EXECUTABLE})
+ set(PROTOC_EXECUTABLE ${ONNX_CUSTOM_PROTOC_EXECUTABLE})
endif()
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64)$")
@@ -140,7 +140,7 @@ if(CMAKE_CROSSCOMPILING AND NOT ONNX_CUSTOM_PROTOC_EXECUTABLE)
if(protoc_binary_SOURCE_DIR)
message("Use prebuilt protoc")
set(ONNX_CUSTOM_PROTOC_EXECUTABLE ${protoc_binary_SOURCE_DIR}/bin/protoc)
- set(PROTOC_EXECUTABLE ${ONNX_CUSTOM_PROTOC_EXECUTABLE})
+ set(PROTOC_EXECUTABLE ${ONNX_CUSTOM_PROTOC_EXECUTABLE})
endif()
elseif ((CMAKE_SYSTEM_NAME STREQUAL "Emscripten" OR CMAKE_SYSTEM_NAME STREQUAL "Android" OR CMAKE_SYSTEM_NAME STREQUAL "iOS") AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
FetchContent_Declare(protoc_binary URL ${DEP_URL_protoc_mac_universal} URL_HASH SHA1=${DEP_SHA1_protoc_mac_universal})
@@ -281,7 +281,7 @@ if ((CPUINFO_SUPPORTED OR onnxruntime_USE_XNNPACK) AND NOT ANDROID)
pytorch_clog
URL ${DEP_URL_pytorch_cpuinfo}
URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
- SOURCE_SUBDIR deps/clog
+ SOURCE_SUBDIR deps/clog
)
set(ONNXRUNTIME_CLOG_PROJ pytorch_clog)
set(ONNXRUNTIME_CLOG_TARGET_NAME clog)
diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake
index 9d9b006c595bb..c900f4d4b09a5 100644
--- a/cmake/onnxruntime.cmake
+++ b/cmake/onnxruntime.cmake
@@ -282,11 +282,7 @@ endif()
# Assemble the Apple static framework (iOS and macOS)
if(onnxruntime_BUILD_APPLE_FRAMEWORK)
- if(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
- set(STATIC_FRAMEWORK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}-${CMAKE_OSX_SYSROOT})
- else() # macOS
- set(STATIC_FRAMEWORK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
- endif()
+ set(STATIC_FRAMEWORK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}-${CMAKE_OSX_SYSROOT})
# Setup the various directories required. Remove any existing ones so we start with a clean directory.
set(STATIC_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/static_libraries)
diff --git a/cmake/onnxruntime_mlas.cmake b/cmake/onnxruntime_mlas.cmake
index 04efa5c2b4f6d..bee83ff07c74b 100644
--- a/cmake/onnxruntime_mlas.cmake
+++ b/cmake/onnxruntime_mlas.cmake
@@ -45,6 +45,15 @@ endif()
set(ONNXRUNTIME_MLAS_LIBS onnxruntime_mlas)
+function(add_jblas)
+ add_subdirectory(${MLAS_SRC_DIR}/x86_64/jblas jblas)
+ target_link_libraries(onnxruntime_mlas PRIVATE jblas::jblas)
+ target_sources(onnxruntime_mlas PRIVATE
+ ${MLAS_SRC_DIR}/jblas_gemm.cpp
+ )
+ set_target_properties(${target_name} PROPERTIES COMPILE_WARNING_AS_ERROR OFF)
+endfunction()
+
#TODO: set MASM flags properly
function(setup_mlas_source_for_windows)
@@ -200,7 +209,6 @@ function(setup_mlas_source_for_windows)
${MLAS_SRC_DIR}/q4gemm_avx512.cpp
)
endif()
-
else()
target_sources(onnxruntime_mlas PRIVATE
${MLAS_SRC_DIR}/qgemm_kernel_sse.cpp
@@ -284,6 +292,8 @@ else()
set(X86 TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64)$")
set(X86_64 TRUE)
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch64.*")
+ set(LOONGARCH64 TRUE)
endif()
endif()
@@ -564,7 +574,7 @@ else()
)
set_source_files_properties(${MLAS_SRC_DIR}/qgemm_kernel_amx.cpp PROPERTIES COMPILE_FLAGS "-mavx2 -mavx512bw -mavx512dq -mavx512vl -mavx512f")
set_source_files_properties(${MLAS_SRC_DIR}/x86_64/QgemmU8S8KernelAmx.S PROPERTIES COMPILE_FLAGS "-mavx2 -mavx512bw -mavx512dq -mavx512vl -mavx512f")
- endif()
+ endif()
if(ONNXRUNTIME_MLAS_MULTI_ARCH)
onnxruntime_add_static_library(onnxruntime_mlas_x86_64 ${mlas_platform_srcs})
@@ -575,6 +585,26 @@ else()
set(MLAS_SOURCE_IS_NOT_SET 0)
endif()
endif()
+ if(LOONGARCH64 AND MLAS_SOURCE_IS_NOT_SET)
+ set(mlas_platform_srcs
+ ${MLAS_SRC_DIR}/qgemm_kernel_lsx.cpp
+ ${MLAS_SRC_DIR}/loongarch64/SgemmKernelLasx.S
+ ${MLAS_SRC_DIR}/loongarch64/DgemmKernelLsx.S
+ ${MLAS_SRC_DIR}/loongarch64/DgemmKernelLasx.S
+ ${MLAS_SRC_DIR}/loongarch64/SgemmKernelLsx.S
+ ${MLAS_SRC_DIR}/loongarch64/SconvKernelLsx.S
+ ${MLAS_SRC_DIR}/loongarch64/SconvKernelLasx.S
+ ${MLAS_SRC_DIR}/loongarch64/SpoolKernelLSX.S
+ ${MLAS_SRC_DIR}/loongarch64/SpoolKernelLasx.S
+ ${MLAS_SRC_DIR}/loongarch64/SgemmTransposePackB16x4LSX.S
+ ${MLAS_SRC_DIR}/loongarch64/SgemmTransposePackB16x4Lasx.S
+ ${MLAS_SRC_DIR}/loongarch64/SoftmaxKernelLasx.S
+ )
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlsx -mlasx")
+ if(NOT ONNXRUNTIME_MLAS_MULTI_ARCH)
+ set(MLAS_SOURCE_IS_NOT_SET 0)
+ endif()
+ endif()
if(NOT ONNXRUNTIME_MLAS_MULTI_ARCH AND MLAS_SOURCE_IS_NOT_SET)
file(GLOB_RECURSE mlas_platform_srcs
"${MLAS_SRC_DIR}/scalar/*.cpp")
@@ -582,6 +612,10 @@ else()
target_sources(onnxruntime_mlas PRIVATE ${mlas_platform_srcs})
endif()
+if(USE_JBLAS)
+ add_jblas()
+endif()
+
foreach(mlas_target ${ONNXRUNTIME_MLAS_LIBS})
target_include_directories(${mlas_target} PRIVATE ${ONNXRUNTIME_ROOT}/core/mlas/inc ${MLAS_SRC_DIR})
onnxruntime_add_include_to_target(${mlas_target} ${GSL_TARGET})
diff --git a/cmake/onnxruntime_optimizer.cmake b/cmake/onnxruntime_optimizer.cmake
index baea52e84ace2..6f09583199ffd 100644
--- a/cmake/onnxruntime_optimizer.cmake
+++ b/cmake/onnxruntime_optimizer.cmake
@@ -86,6 +86,8 @@ if (onnxruntime_ENABLE_TRAINING)
"${ORTTRAINING_SOURCE_DIR}/core/optimizer/*.cc"
"${ORTTRAINING_SOURCE_DIR}/core/optimizer/compute_optimizer/*.h"
"${ORTTRAINING_SOURCE_DIR}/core/optimizer/compute_optimizer/*.cc"
+ "${ORTTRAINING_SOURCE_DIR}/core/optimizer/memory_optimizer/*.h"
+ "${ORTTRAINING_SOURCE_DIR}/core/optimizer/memory_optimizer/*.cc"
)
endif()
diff --git a/cmake/onnxruntime_providers_cuda.cmake b/cmake/onnxruntime_providers_cuda.cmake
index f2a16fb29dc62..84d1376f99d5e 100644
--- a/cmake/onnxruntime_providers_cuda.cmake
+++ b/cmake/onnxruntime_providers_cuda.cmake
@@ -34,6 +34,8 @@
if (NOT onnxruntime_USE_NCCL)
list(REMOVE_ITEM onnxruntime_cuda_contrib_ops_cc_srcs
"${ONNXRUNTIME_ROOT}/contrib_ops/cuda/collective/nccl_kernels.cc"
+ "${ONNXRUNTIME_ROOT}/contrib_ops/cuda/collective/sharded_moe.h"
+ "${ONNXRUNTIME_ROOT}/contrib_ops/cuda/collective/sharded_moe.cc"
"${ONNXRUNTIME_ROOT}/contrib_ops/cuda/collective/sharding_spec.cc"
"${ONNXRUNTIME_ROOT}/contrib_ops/cuda/collective/sharding.cc"
"${ONNXRUNTIME_ROOT}/contrib_ops/cuda/collective/distributed_matmul.cc"
@@ -172,10 +174,8 @@
target_link_libraries(${target} PRIVATE cuda)
endif()
- if (onnxruntime_USE_FLASH_ATTENTION OR onnxruntime_USE_MEMORY_EFFICIENT_ATTENTION)
- include(cutlass)
- target_include_directories(${target} PRIVATE ${cutlass_SOURCE_DIR}/include ${cutlass_SOURCE_DIR}/examples)
- endif()
+ include(cutlass)
+ target_include_directories(${target} PRIVATE ${cutlass_SOURCE_DIR}/include ${cutlass_SOURCE_DIR}/examples)
target_include_directories(${target} PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${eigen_INCLUDE_DIRS} ${TVM_INCLUDES} PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
# ${CMAKE_CURRENT_BINARY_DIR} is so that #include "onnxruntime_config.h" inside tensor_shape.h is found
diff --git a/cmake/onnxruntime_providers_vitisai.cmake b/cmake/onnxruntime_providers_vitisai.cmake
index 7ac4a82c89a76..0951c2d02664d 100644
--- a/cmake/onnxruntime_providers_vitisai.cmake
+++ b/cmake/onnxruntime_providers_vitisai.cmake
@@ -15,16 +15,10 @@
"${ONNXRUNTIME_ROOT}/core/providers/vitisai/imp/*.cc"
"${ONNXRUNTIME_ROOT}/core/providers/vitisai/imp/*.h"
)
- list(REMOVE_ITEM onnxruntime_providers_vitisai_cc_srcs "${ONNXRUNTIME_ROOT}/core/providers/vitisai/onnxruntime_vitisai_ep_stub.cc")
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_vitisai_cc_srcs})
onnxruntime_add_static_library(onnxruntime_providers_vitisai ${onnxruntime_providers_vitisai_cc_srcs})
onnxruntime_add_include_to_target(onnxruntime_providers_vitisai onnxruntime_common onnxruntime_framework onnx onnx_proto)
- onnxruntime_add_shared_library(onnxruntime_vitisai_ep ${ONNXRUNTIME_ROOT}/core/providers/vitisai/onnxruntime_vitisai_ep_stub.cc)
- onnxruntime_add_include_to_target(onnxruntime_vitisai_ep onnxruntime_common)
- target_include_directories(onnxruntime_vitisai_ep PRIVATE "${ONNXRUNTIME_ROOT}" "${ONNXRUNTIME_ROOT}/core/providers/vitisai/include")
- target_link_libraries(onnxruntime_providers_vitisai PUBLIC onnxruntime_vitisai_ep PRIVATE onnx protobuf::libprotobuf nlohmann_json::nlohmann_json )
- target_compile_definitions(onnxruntime_vitisai_ep
- PRIVATE "-DONNXRUNTIME_VITISAI_EP_STUB=1" "-DONNXRUNTIME_VITISAI_EP_EXPORT_DLL=1")
+ target_link_libraries(onnxruntime_providers_vitisai PRIVATE onnx protobuf::libprotobuf nlohmann_json::nlohmann_json)
if(NOT MSVC)
target_compile_options(onnxruntime_providers_vitisai PUBLIC $<$:-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0>)
endif(NOT MSVC)
@@ -49,4 +43,4 @@
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR})
- endif()
\ No newline at end of file
+ endif()
diff --git a/cmake/onnxruntime_python.cmake b/cmake/onnxruntime_python.cmake
index a9a78668b4810..61922961588b2 100644
--- a/cmake/onnxruntime_python.cmake
+++ b/cmake/onnxruntime_python.cmake
@@ -339,9 +339,6 @@ configure_file(${ONNXRUNTIME_ROOT}/python/_pybind_state.py.in
${CMAKE_BINARY_DIR}/onnxruntime/capi/_pybind_state.py)
if (onnxruntime_ENABLE_TRAINING)
- file(GLOB onnxruntime_python_capi_training_srcs CONFIGURE_DEPENDS
- "${ORTTRAINING_SOURCE_DIR}/python/deprecated/*.py"
- )
file(GLOB onnxruntime_python_root_srcs CONFIGURE_DEPENDS
"${ORTTRAINING_SOURCE_DIR}/python/training/*.py"
)
@@ -419,10 +416,6 @@ if (onnxruntime_ENABLE_TRAINING)
"${ORTTRAINING_SOURCE_DIR}/python/training/onnxblock/optim/*"
)
endif()
-else()
- file(GLOB onnxruntime_python_capi_training_srcs CONFIGURE_DEPENDS
- "${ONNXRUNTIME_ROOT}/python/training/*.py"
- )
endif()
if (onnxruntime_BUILD_UNIT_TESTS)
@@ -443,6 +436,9 @@ if (onnxruntime_BUILD_UNIT_TESTS)
file(GLOB onnxruntime_python_transformers_testdata_whisper CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/test/python/transformers/test_data/models/whisper/*.onnx"
)
+ file(GLOB onnxruntime_python_transformers_testdata_conformer CONFIGURE_DEPENDS
+ "${ONNXRUNTIME_ROOT}/test/python/transformers/test_data/models/conformer/*.onnx"
+ )
endif()
file(GLOB onnxruntime_python_tools_srcs CONFIGURE_DEPENDS
@@ -457,6 +453,12 @@ file(GLOB onnxruntime_python_quantization_operators_src CONFIGURE_DEPENDS
file(GLOB onnxruntime_python_quantization_cal_table_flatbuffers_src CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/python/tools/quantization/CalTableFlatBuffers/*.py"
)
+file(GLOB onnxruntime_python_quantization_fusions_src CONFIGURE_DEPENDS
+ "${ONNXRUNTIME_ROOT}/python/tools/quantization/fusions/*.py"
+)
+file(GLOB onnxruntime_python_quantization_ep_qnn_src CONFIGURE_DEPENDS
+ "${ONNXRUNTIME_ROOT}/python/tools/quantization/execution_providers/qnn/*.py"
+)
file(GLOB onnxruntime_python_transformers_src CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/python/tools/transformers/*.py"
)
@@ -551,11 +553,15 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/quantization
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/quantization/operators
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/quantization/CalTableFlatBuffers
+ COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/quantization/fusions
+ COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/quantization/execution_providers
+ COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/quantization/execution_providers/qnn
COMMAND ${CMAKE_COMMAND} -E make_directory $/quantization
COMMAND ${CMAKE_COMMAND} -E make_directory $/transformers
COMMAND ${CMAKE_COMMAND} -E make_directory $/transformers/test_data/models
COMMAND ${CMAKE_COMMAND} -E make_directory $/transformers/test_data/models/whisper
COMMAND ${CMAKE_COMMAND} -E make_directory $/eager_test
+ COMMAND ${CMAKE_COMMAND} -E make_directory $/transformers/test_data/models/conformer
COMMAND ${CMAKE_COMMAND} -E copy
${ONNXRUNTIME_ROOT}/__init__.py
$/onnxruntime/
@@ -577,9 +583,6 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_BINARY_DIR}/onnxruntime/capi/_pybind_state.py
$/onnxruntime/capi/
- COMMAND ${CMAKE_COMMAND} -E copy
- ${onnxruntime_python_capi_training_srcs}
- $/onnxruntime/capi/training/
COMMAND ${CMAKE_COMMAND} -E copy
$
$/onnxruntime/capi/
@@ -623,6 +626,12 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_python_quantization_cal_table_flatbuffers_src}
$/onnxruntime/quantization/CalTableFlatBuffers/
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${onnxruntime_python_quantization_fusions_src}
+ $/onnxruntime/quantization/fusions/
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${onnxruntime_python_quantization_ep_qnn_src}
+ $/onnxruntime/quantization/execution_providers/qnn/
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_python_transformers_src}
$/onnxruntime/transformers/
@@ -711,6 +720,9 @@ if (onnxruntime_BUILD_UNIT_TESTS)
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_python_transformers_testdata_whisper}
$/transformers/test_data/models/whisper/
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${onnxruntime_python_transformers_testdata_conformer}
+ $/transformers/test_data/models/conformer/
)
endif()
@@ -750,9 +762,6 @@ if (onnxruntime_ENABLE_TRAINING)
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/utils
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/utils/data/
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/utils/hooks/
- COMMAND ${CMAKE_COMMAND} -E copy
- ${onnxruntime_python_capi_training_srcs}
- $/onnxruntime/capi/training/
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_python_root_srcs}
$/onnxruntime/training/
diff --git a/cmake/onnxruntime_rocm_hipify.cmake b/cmake/onnxruntime_rocm_hipify.cmake
index 980bd59b22c3f..f70961a66329a 100644
--- a/cmake/onnxruntime_rocm_hipify.cmake
+++ b/cmake/onnxruntime_rocm_hipify.cmake
@@ -109,6 +109,8 @@ if (NOT onnxruntime_USE_NCCL)
# Those are string patterns to exclude. Do NOT use stars such as
# collective/*.cc or *.h.
list(APPEND contrib_ops_excluded_files "collective/nccl_kernels.cc")
+ list(APPEND contrib_ops_excluded_files "collective/sharded_moe.h")
+ list(APPEND contrib_ops_excluded_files "collective/sharded_moe.cc")
list(APPEND contrib_ops_excluded_files "collective/sharding.cc")
list(APPEND contrib_ops_excluded_files "collective/sharding_spec.cc")
list(APPEND contrib_ops_excluded_files "collective/distributed_matmul.cc")
diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake
index a52e941b235b4..7c8c70f913dca 100644
--- a/cmake/onnxruntime_unittests.cmake
+++ b/cmake/onnxruntime_unittests.cmake
@@ -783,7 +783,7 @@ if (onnxruntime_ENABLE_CUDA_EP_INTERNAL_TESTS)
onnxruntime_add_shared_library_module(onnxruntime_providers_cuda_ut ${onnxruntime_test_providers_cuda_ut_src} $)
config_cuda_provider_shared_module(onnxruntime_providers_cuda_ut)
onnxruntime_add_include_to_target(onnxruntime_providers_cuda_ut GTest::gtest GTest::gmock)
- target_link_libraries(onnxruntime_providers_cuda_ut PRIVATE GTest::gtest GTest::gmock)
+ target_link_libraries(onnxruntime_providers_cuda_ut PRIVATE GTest::gtest GTest::gmock ${ONNXRUNTIME_MLAS_LIBS} onnxruntime_common)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_cuda_ut)
endif()
@@ -1373,56 +1373,55 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
target_link_libraries(compare_two_sessions PRIVATE ${GETOPT_LIB_WIDE} tdh Advapi32)
endif()
- file(GLOB onnxruntime_mlas_test_src CONFIGURE_DEPENDS
- "${TEST_SRC_DIR}/mlas/unittest/*.h"
- "${TEST_SRC_DIR}/mlas/unittest/*.cpp"
- )
- onnxruntime_add_executable(onnxruntime_mlas_test ${onnxruntime_mlas_test_src})
- if(MSVC)
- target_compile_options(onnxruntime_mlas_test PRIVATE "$<$:SHELL:--compiler-options /wd26409>"
- "$<$>:/wd26409>")
- target_compile_options(onnxruntime_mlas_test PRIVATE "$<$:SHELL:--compiler-options /utf-8>"
- "$<$>:/utf-8>")
- target_compile_options(onnxruntime_mlas_test PRIVATE "$<$:SHELL:--compiler-options /wd6326>"
- "$<$>:/wd6326>")
- target_compile_options(onnxruntime_mlas_test PRIVATE "$<$:SHELL:--compiler-options /wd26426>"
- "$<$>:/wd26426>")
- endif()
- if(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
- set_target_properties(onnxruntime_mlas_test PROPERTIES
- XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
+ if(NOT onnxruntime_target_platform STREQUAL "ARM64EC")
+ file(GLOB onnxruntime_mlas_test_src CONFIGURE_DEPENDS
+ "${TEST_SRC_DIR}/mlas/unittest/*.h"
+ "${TEST_SRC_DIR}/mlas/unittest/*.cpp"
)
- endif()
- target_include_directories(onnxruntime_mlas_test PRIVATE ${ONNXRUNTIME_ROOT}/core/mlas/inc ${ONNXRUNTIME_ROOT}
- ${CMAKE_CURRENT_BINARY_DIR})
- target_link_libraries(onnxruntime_mlas_test PRIVATE GTest::gtest GTest::gmock ${ONNXRUNTIME_MLAS_LIBS} onnxruntime_common)
- if (CPUINFO_SUPPORTED AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
- target_link_libraries(onnxruntime_mlas_test PRIVATE cpuinfo)
- endif()
- if(NOT WIN32)
- target_link_libraries(onnxruntime_mlas_test PRIVATE nsync::nsync_cpp ${CMAKE_DL_LIBS})
- endif()
- if (CMAKE_SYSTEM_NAME STREQUAL "Android")
- target_link_libraries(onnxruntime_mlas_test PRIVATE ${android_shared_libs})
- endif()
-
- if(WIN32)
- target_link_libraries(onnxruntime_mlas_test PRIVATE debug Dbghelp Advapi32)
- endif()
- if (onnxruntime_LINK_LIBATOMIC)
- target_link_libraries(onnxruntime_mlas_test PRIVATE atomic)
- endif()
- target_link_libraries(onnxruntime_mlas_test PRIVATE Threads::Threads)
-
- set_target_properties(onnxruntime_mlas_test PROPERTIES FOLDER "ONNXRuntimeTest")
- if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
- if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
- set_target_properties(onnxruntime_mlas_test PROPERTIES LINK_FLAGS "-s ALLOW_MEMORY_GROWTH=1 -s PROXY_TO_PTHREAD=1 -s EXIT_RUNTIME=1")
- else()
- set_target_properties(onnxruntime_mlas_test PROPERTIES LINK_FLAGS "-s ALLOW_MEMORY_GROWTH=1")
+ onnxruntime_add_executable(onnxruntime_mlas_test ${onnxruntime_mlas_test_src})
+ if(MSVC)
+ target_compile_options(onnxruntime_mlas_test PRIVATE "$<$:SHELL:--compiler-options /wd26409>"
+ "$<$>:/wd26409>")
+ target_compile_options(onnxruntime_mlas_test PRIVATE "$<$:SHELL:--compiler-options /utf-8>"
+ "$<$>:/utf-8>")
+ target_compile_options(onnxruntime_mlas_test PRIVATE "$<$:SHELL:--compiler-options /wd6326>"
+ "$<$>:/wd6326>")
+ target_compile_options(onnxruntime_mlas_test PRIVATE "$<$:SHELL:--compiler-options /wd26426>"
+ "$<$>:/wd26426>")
endif()
- endif()
-
+ if(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
+ set_target_properties(onnxruntime_mlas_test PROPERTIES
+ XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
+ )
+ endif()
+ target_include_directories(onnxruntime_mlas_test PRIVATE ${ONNXRUNTIME_ROOT}/core/mlas/inc ${ONNXRUNTIME_ROOT}
+ ${CMAKE_CURRENT_BINARY_DIR})
+ target_link_libraries(onnxruntime_mlas_test PRIVATE GTest::gtest GTest::gmock ${ONNXRUNTIME_MLAS_LIBS} onnxruntime_common)
+ if (CPUINFO_SUPPORTED AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
+ target_link_libraries(onnxruntime_mlas_test PRIVATE cpuinfo)
+ endif()
+ if(NOT WIN32)
+ target_link_libraries(onnxruntime_mlas_test PRIVATE nsync::nsync_cpp ${CMAKE_DL_LIBS})
+ endif()
+ if (CMAKE_SYSTEM_NAME STREQUAL "Android")
+ target_link_libraries(onnxruntime_mlas_test PRIVATE ${android_shared_libs})
+ endif()
+ if(WIN32)
+ target_link_libraries(onnxruntime_mlas_test PRIVATE debug Dbghelp Advapi32)
+ endif()
+ if (onnxruntime_LINK_LIBATOMIC)
+ target_link_libraries(onnxruntime_mlas_test PRIVATE atomic)
+ endif()
+ target_link_libraries(onnxruntime_mlas_test PRIVATE Threads::Threads)
+ set_target_properties(onnxruntime_mlas_test PROPERTIES FOLDER "ONNXRuntimeTest")
+ if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
+ if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
+ set_target_properties(onnxruntime_mlas_test PROPERTIES LINK_FLAGS "-s ALLOW_MEMORY_GROWTH=1 -s PROXY_TO_PTHREAD=1 -s EXIT_RUNTIME=1")
+ else()
+ set_target_properties(onnxruntime_mlas_test PROPERTIES LINK_FLAGS "-s ALLOW_MEMORY_GROWTH=1")
+ endif()
+ endif()
+endif()
# Training API Tests
# Disabling training_api_test_trainer. CXXOPT generates a ton of warnings because of which nuget pipeline is failing.
# TODO(askhade): Fix the warnings.
diff --git a/cmake/patches/composable_kernel/Fix_Clang_Build.patch b/cmake/patches/composable_kernel/Fix_Clang_Build.patch
index 02b30af9eef52..15844dd917744 100644
--- a/cmake/patches/composable_kernel/Fix_Clang_Build.patch
+++ b/cmake/patches/composable_kernel/Fix_Clang_Build.patch
@@ -1,5 +1,5 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
-index b09da41a8..fca2bdf69 100644
+index 04674124c..12e8b8b00 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,7 @@ endif()
@@ -48,7 +48,18 @@ index b09da41a8..fca2bdf69 100644
## tidy
include(EnableCompilerWarnings)
-@@ -489,11 +466,3 @@ rocm_install(FILES
+@@ -376,7 +353,9 @@ if(BUILD_DEV)
+ add_compile_options(-Werror -Weverything)
+ endif()
+ #add flags to reduce the size of binaries
+-add_compile_options(-Oz -flto=thin)
++# -flto requires ORT to use a linker that support LTO and -flto flag shoud be passed to linker together.
++# add_compile_options(-Oz -flto=thin)
++add_compile_options(-Oz)
+ message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
+
+ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR})
+@@ -482,11 +461,3 @@ rocm_install(FILES
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
@@ -61,7 +72,7 @@ index b09da41a8..fca2bdf69 100644
- HEADER_ONLY
-)
diff --git a/library/src/tensor_operation_instance/gpu/CMakeLists.txt b/library/src/tensor_operation_instance/gpu/CMakeLists.txt
-index a0478c9f0..1e7782cd4 100644
+index 9cb5d0e9a..141a46f3d 100644
--- a/library/src/tensor_operation_instance/gpu/CMakeLists.txt
+++ b/library/src/tensor_operation_instance/gpu/CMakeLists.txt
@@ -44,8 +44,14 @@ function(add_instance_library INSTANCE_NAME)
diff --git a/cmake/winml.cmake b/cmake/winml.cmake
index 395996f0fa4b9..268ee3960e75a 100644
--- a/cmake/winml.cmake
+++ b/cmake/winml.cmake
@@ -451,6 +451,8 @@ onnxruntime_add_static_library(winml_lib_api
${winml_lib_api_dir}/impl/TensorKindFrom.h
${winml_lib_api_dir}/impl/TensorMemoryBufferReference.h
${winml_lib_api_dir}/NumericData.cpp
+ ${winml_lib_api_dir}/HardwareCoreEnumerator.cpp
+ ${winml_lib_api_dir}/HardwareCoreEnumerator.h
${winml_lib_api_dir}/ImageFeatureDescriptor.cpp
${winml_lib_api_dir}/ImageFeatureDescriptor.h
${winml_lib_api_dir}/ImageFeatureValue.cpp
diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj
index 0c74a23204d4f..1d15383239baf 100644
--- a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj
+++ b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj
@@ -6,7 +6,7 @@
true
- netstandard2.0
+ netstandard2.0;netcoreapp3.1;net6.0
diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/OrtValue.shared.cs b/csharp/src/Microsoft.ML.OnnxRuntime/OrtValue.shared.cs
index 86b44a6784817..163a2b394c4ae 100644
--- a/csharp/src/Microsoft.ML.OnnxRuntime/OrtValue.shared.cs
+++ b/csharp/src/Microsoft.ML.OnnxRuntime/OrtValue.shared.cs
@@ -263,12 +263,16 @@ public ReadOnlyMemory GetStringElementAsMemory(int index)
/// UTF-16 string instance
public string GetStringElement(int index)
{
- var chars = GetStringTensorElementChars(index);
- if (chars.Length == 0)
+ GetStringTensorElementBuffer((UIntPtr)index, out uint bytesLen, out IntPtr bufferPtr);
+ if (bytesLen == 0)
{
return string.Empty;
}
- return new string(chars);
+
+ unsafe
+ {
+ return Encoding.UTF8.GetString((byte*)bufferPtr.ToPointer(), (int)bytesLen);
+ }
}
diff --git a/docs/ContribOperators.md b/docs/ContribOperators.md
index 9c31978c66486..131db5d8d9b37 100644
--- a/docs/ContribOperators.md
+++ b/docs/ContribOperators.md
@@ -1599,14 +1599,14 @@ This version of the operator has been available since version 1 of the 'com.micr
#### Inputs (1 - ∞)
-- inputs (variadic) : T
+- inputs (variadic, heterogeneous) : T
- List of tensors for inputs
#### Outputs (1 - ∞)
-- outputs (variadic) : T
+- outputs (variadic, heterogeneous) : T
- One or more outputs, list of tensors for outputs
@@ -2385,7 +2385,7 @@ This version of the operator has been available since version 1 of the 'com.micr
Group Query Self/Cross Attention.
- Supports different number of heads for q and kv.
+ Supports different number of heads for q and kv. Only supports causal or local attention.
#### Version
@@ -2396,6 +2396,8 @@ This version of the operator has been available since version 1 of the 'com.micr
- kv_num_heads : int (required)
- Number of attention heads for k and v
+- local_window_size : int
+- left_window_size for local attention (like Mistral). Default value is -1 meaning unused.
- num_heads : int (required)
- Number of attention heads for q
- scale : float
@@ -2647,8 +2649,8 @@ This version of the operator has been available since version 1 of the 'com.micr
#### Type Constraints
-- T1 : tensor(float), tensor(float16)
-- Constrain input and output types to float/half_float tensors.
+- T1 : tensor(float), tensor(float16), tensor(bfloat16)
+- Constrain input and output types to float/half_float/brain_float tensors.
- T2 : tensor(uint8)
- Constrain quantized weight types to uint8.
@@ -2822,6 +2824,8 @@ This version of the operator has been available since version 1 of the 'com.micr
- size of each input feature
- N : int (required)
- size of each output feature
+- accuracy_level : int
+- The minimum accuracy level of input A, can be: 0(unset), 1(fp32), 2(fp16), 3(bf16), or 4(int8) (default unset). It is used to control how input A is quantized or downcast internally while doing computation, for example: 0 means input A will not be quantized or downcast while doing computation. 4 means input A can be quantized with the same block_size to int8 internally from type T1.
- bits : int (required)
- number of bits used for weight quantization (default 4)
- block_size : int (required)
@@ -5021,7 +5025,7 @@ This version of the operator has been available since version 1 of the 'com.micr
- input : T
-- 3D tensor with shape (batch_size, sequence_length, hidden_size)
+- 3D tensor with shape (batch_size, sequence_length, hidden_size) or 4D with shape (batch_size, num_heads, sequence_length, head_size)
- position_ids : M
- 1D tensor with shape (1) or 2D tensor with shape (batch_size, sequence_length)
- cos_cache : T
@@ -5034,7 +5038,7 @@ This version of the operator has been available since version 1 of the 'com.micr
- output : T
-- 3D tensor with shape (batch_size, sequence_length, hidden_size)
+- tensor with same shape as input.
#### Type Constraints
diff --git a/docs/Memory_Optimizer.md b/docs/Memory_Optimizer.md
index e9ceae00a684d..97f7e7ff2c14b 100644
--- a/docs/Memory_Optimizer.md
+++ b/docs/Memory_Optimizer.md
@@ -17,74 +17,149 @@ Classical scenarios include:
Not all models and recipes need this optimizer technique. Imagine if your training recipe uses a batch size 6 (GPU compute and memory are fully saturated), and you don't need bump it to 8 to maintain a fixed global batch size. Enabling recompute maybe not bring better throughput on batch size 8 than the original batch size 6.
-## Quick trial
+## Usage
-1. Make sure ONNX Runtime training wheel is installed and correctly configured.
-2. Integrate models using `ORTModule`, be noted log_level should be equal to or lower than DEVINFO.
- > ort_model = ORTModule(pt_model, DebugOptions(log_level=LogLevel.DEVINFO))
-3. Run the training as usual and redirect all outputs into the log file; then stop it after training a few steps.
-4. Check the logging file, and search "Summary", you could find something like this:
+
+Make sure ONNX Runtime training wheel is installed and correctly configured.
+Integrate models using `ORTModule`.
+```diff
+ model = build_model()
+
++ from onnxruntime.training.ortmodule import ORTModule
++ model = ORTModule(model)
+```
+
+There are two modes to enable the memory optimizations:
+- Aggressively Recompute All Within Each Transformer Layer, enabled by `export ORTMODULE_MEMORY_OPT_LEVEL=1`. This will recompute all detected subgraphs within each Transformer Attention+MLP layer. It is easy to enable, but be noted this recompute plan may NOT be the best one. In this mode, `ORTMODULE_MEMORY_OPT_CONFIG` env values passed by users are not respected.
+- User Specified Subgraph Recompute, enabled by `export ORTMODULE_MEMORY_OPT_LEVEL=0` and `export ORTMODULE_MEMORY_OPT_CONFIG=,,...`. This is an advanced usage, that allows users to find the most suitable graphs to recompute, at the cost of overhead to look for the best plans.
+
+### Mode 1 - Simple Usage (Aggressively Recompute All Within Each Transformer Layer)
+
+
+1. Set memory optimization level to be TRANSFORMER_LAYERWISE_RECOMPUTE, by `export ORTMODULE_MEMORY_OPT_LEVEL=1`
+2. Run the training as usual; check the logs, you could find something like this if the current log level <= LogLevel.INFO:
+ ```
+ Memory Optimizer : ON : Memory Optimization Level: [TRANSFORMER_LAYERWISE_RECOMPUTE], Optimization Config: [Reshape+Where+:1:-1,BiasSoftmax+:1:-1,Cast+:1:-1,BiasGelu+:1:-1,FusedMatMul+:1:-1,Add+:1:-1,Reshape+Unsqueeze+Unsqueeze+Cast+Sub+Mul+Cast+:1:-1]
+ Configs Freq Max Saving(Bytes) Saving Symbolic(Bytes)
+ - Plan 1 : ON : Reshape+Where+:1:-1 1 134,217,728 128.0*inputs_input_ids_dim0*inputs_input_ids_dim1**2
+ - Plan 2 : ON : BiasSoftmax+:1:-1 1 134,086,656 128.0*inputs_input_ids_dim0*inputs_input_ids_dim1*(inputs_input_ids_dim1 - 1)
+ - Plan 3 : ON : Cast+:1:-1 1 67,043,328 64.0*inputs_input_ids_dim0*inputs_input_ids_dim1*(inputs_input_ids_dim1 - 1)
+ - Plan 4 : ON : BiasGelu+:1:-1 1 20,951,040 20480.0*inputs_input_ids_dim0*(inputs_input_ids_dim1 - 1)
+ - Plan 5 : ON : FusedMatMul+:1:-1 1 20,951,040 20480.0*inputs_input_ids_dim0*(inputs_input_ids_dim1 - 1)
+ - Plan 6 : ON : Add+:1:-1 1 5,237,760 5120.0*inputs_input_ids_dim0*(inputs_input_ids_dim1 - 1)
+ - Plan 7 : ON : Reshape+Unsqueeze+Unsqueeze+Cast+Sub+Mul+Cast+:1:-1 1 4,096 4.0*inputs_input_ids_dim0*inputs_input_ids_dim1
+ - Plan 8 : OFF : Cast+:2:-1 1 2,048 2.0*inputs_input_ids_dim0*inputs_input_ids_dim1
```
- MemoryOptimizer Summary:
- User config:
-
- =================================
- ########Recompute########
- Subgraph: CumSum+Sub+Mul+Unsqueeze+Cast+Mul+Cast+Reshape+Mul+FusedMatMul+Add+Reshape+Cast+Where+Softmax+
- OptimizationType: Disabled
- Patterns:
- PatternShape:input_ids_dim0 x 16 x input_ids_dim1 x input_ids_dim1 x Frequency:23
- --------------------------------
- Subgraph: FastGelu+
- OptimizationType: Disabled
- Patterns:
- PatternShape:input_ids_dim0 x input_ids_dim1 x 4096 x Frequency:24
- =================================
- ########RecomputeWithCompromise########
- Subgraph: Cast+Where+Softmax+
- OptimizationType: Disabled
- Patterns:
- PatternShape:input_ids_dim0 x 16 x input_ids_dim1 x input_ids_dim1 x Frequency:24
- --------------------------------
- =================================
+3. As shown above, `Config` is a string representative for a re-computable subgraph. All are enabled for recompute in this case.
+
+
+### Mode 2 - Advanced Usage (User Selected Subgraph Recompute)
+
+1. Be noted `ORTMODULE_MEMORY_OPT_LEVEL` is by default be 0. Run the training as usual; then stop it after training a few steps.
+2. Check the logs, you could find something like this if the current log level <= LogLevel.INFO::
```
-5. As shown above, 'Subgraph' shows 1) a string representative for a re-computable subgraph; and 2) current status of memory optimization. All are disabled for recompute in this case.
-6. Set environment variable `ORTMODULE_MEMORY_OPT_CONFIG` to enable some of the subgraph to do recompute. In below example, 12 FastGelu related subgraphs are allowed to recompute.
-`FastGelu+` is the subgraph string representative; `1` in the middle indicates 'Recompute' is enabled (0, on the contrary indicates it's disabled); `12` means the initial 12 subgraph occurrences will be recomputed, all others are left as it is, filling `-1` will make all occurrences be recomputed.
+ Memory Optimizer : OFF : Enable with env ORTMODULE_MEMORY_OPT_LEVEL=1 or ORTMODULE_MEMORY_OPT_CONFIG=,,...
+ Configs Freq Max Saving(Bytes) Saving Symbolic(Bytes)
+ - Plan 1 : OFF : Reshape+Where+:1:-1 1 134,217,728 128.0*inputs_input_ids_dim0*inputs_input_ids_dim1**2
+ - Plan 2 : OFF : BiasSoftmax+:1:-1 1 134,086,656 128.0*inputs_input_ids_dim0*inputs_input_ids_dim1*(inputs_input_ids_dim1 - 1)
+ - Plan 3 : OFF : Cast+:1:-1 1 67,043,328 64.0*inputs_input_ids_dim0*inputs_input_ids_dim1*(inputs_input_ids_dim1 - 1)
+ - Plan 4 : OFF : BiasGelu+:1:-1 1 20,951,040 20480.0*inputs_input_ids_dim0*(inputs_input_ids_dim1 - 1)
+ - Plan 5 : OFF : FusedMatMul+:1:-1 1 20,951,040 20480.0*inputs_input_ids_dim0*(inputs_input_ids_dim1 - 1)
+ - Plan 6 : OFF : Add+:1:-1 1 5,237,760 5120.0*inputs_input_ids_dim0*(inputs_input_ids_dim1 - 1)
+ - Plan 7 : OFF : Reshape+Unsqueeze+Unsqueeze+Cast+Sub+Mul+Cast+:1:-1 1 4,096 4.0*inputs_input_ids_dim0*inputs_input_ids_dim1
+ - Plan 8 : OFF : Cast+:2:-1 1 2,048 2.0*inputs_input_ids_dim0*inputs_input_ids_dim1
```
- export ORTMODULE_MEMORY_OPT_CONFIG="FastGelu+:1:12"
+3. As shown above, `Config` is a string representative for a re-computable subgraph. All are disabled for recompute in this case.
+4. Set environment variable `ORTMODULE_MEMORY_OPT_CONFIG` to enable some of the subgraphs to do recompute.
+ ```bash
+ # Use comma as a separator for enabling more than one subgraphs.
+ export ORTMODULE_MEMORY_OPT_CONFIG="BiasGelu+:1:1"
+ # Explanation:
+ # > BiasGelu+ is the subgraph string representative;
+ # > 1 in the middle indicates 'Recompute' is enabled (0, on the contrary indicates it's disabled)
+ # > The last 1 means the initial 1 subgraph occurrences will be recomputed, all others are left as it is, filling `-1` will make all occurrences be recomputed.
+
```
-7. Then run the training again, you will see logs like this:
+5. Then run the training again, and you will see logs like this:
```
- MemoryOptimizer Summary:
- User config:
- **FastGelu+:1:12**
- =================================
- ########Recompute########
- Subgraph: CumSum+Sub+Mul+Unsqueeze+Cast+Mul+Cast+Reshape+Mul+FusedMatMul+Add+Reshape+Cast+Where+Softmax+
- OptimizationType: Disabled
- Patterns:
- PatternShape:input_ids_dim0 x 16 x input_ids_dim1 x input_ids_dim1 x Frequency:23
- --------------------------------
- Subgraph: FastGelu+
- OptimizationType: **Recompute (requested_count=12, actual applied_count=12)**
- Patterns:
- PatternShape:input_ids_dim0 x input_ids_dim1 x 4096 x Frequency:24
- =================================
- ########RecomputeWithCompromise########
- Subgraph: Cast+Where+Softmax+
- OptimizationType: Disabled
- Patterns:
- PatternShape:input_ids_dim0 x 16 x input_ids_dim1 x input_ids_dim1 x Frequency:24
- --------------------------------
- =================================
+ Memory Optimizer : ON : Memory Optimization Level: [USER_SPECIFIED], Optimization Config: [BiasGelu+:1:-1]
+ Configs Freq Max Saving(Bytes) Saving Symbolic(Bytes)
+ - Plan 1 : OFF : Reshape+Where+:1:-1 1 134,217,728 128.0*inputs_input_ids_dim0*inputs_input_ids_dim1**2
+ - Plan 2 : OFF : BiasSoftmax+:1:-1 1 134,086,656 128.0*inputs_input_ids_dim0*inputs_input_ids_dim1*(inputs_input_ids_dim1 - 1)
+ - Plan 3 : OFF : Cast+:1:-1 1 67,043,328 64.0*inputs_input_ids_dim0*inputs_input_ids_dim1*(inputs_input_ids_dim1 - 1)
+ - Plan 4 : ON : BiasGelu+:1:-1 1 20,951,040 20480.0*inputs_input_ids_dim0*(inputs_input_ids_dim1 - 1)
+ - Plan 5 : OFF : FusedMatMul+:1:-1 1 20,951,040 20480.0*inputs_input_ids_dim0*(inputs_input_ids_dim1 - 1)
+ - Plan 6 : OFF : Add+:1:-1 1 5,237,760 5120.0*inputs_input_ids_dim0*(inputs_input_ids_dim1 - 1)
+ - Plan 7 : OFF : Reshape+Unsqueeze+Unsqueeze+Cast+Sub+Mul+Cast+:1:-1 1 4,096 4.0*inputs_input_ids_dim0*inputs_input_ids_dim1
+ - Plan 8 : OFF : Cast+:2:-1 1 2,048 2.0*inputs_input_ids_dim0*inputs_input_ids_dim1
```
-8. You may need iterate few times on step 6 and 7 until you find a good config for this model to run a bigger batch size. Or you may fail to find if memory optimization does not apply to the model well.
+6. You may need iterate a few times on step 4 and 5 until you find a good config for this model to run a bigger batch size. Or you may fail to find if memory optimization does not apply to the model well.
+
+## Optimization Configuration
+
+The basic optimization unit is represented with a unique `cluster id`, for example `BiasGelu+` is one `cluster id`.
+Following `cluster id` is the `optimization strategy`: 0 - none, 1 - recompute, 2 - recompute with compromised memory saving.
+Following `optimization strategy` is the `request count` to apply the given optimization. Using `-1` to apply all. This would give user a bit more flexibility to avoid unnecessary memory saving.
+
+### Compromised Recompute
+
+If you check the above logs, there is a config `Cast+:2:-1`, `2` indicates it's a recomputation than can save part of the stashed activation size, not all. Recompute the subgraphs under it usually will save part of the activation (for example half of them), not all of them. Follow the same way to enable it.
+
+## Dev Notes
+
+### Memory Optimization Debug Infos
+
+Using following log level
+> ort_model = ORTModule(pt_model, DebugOptions(log_level=LogLevel.DEVINFO))
+
+Besides the logs shown in `LogLevel.INFO`, you can also see different node patterns that can apply different optimization options.
+
+The way we get the table:
+- For a specific node, it might has different optimization options, we [generates](../orttraining/orttraining/core/optimizer/memory_optimizer/common.h#L124C26-L124C26) a hash (called `Node Cluster ID`) for the node according to all available optimization options.
+- Map all nodes having same `Node Cluster ID` in buckets, each bucket is displayed as one row.
-## Compromised Recompute
+```
+MemoryInsight Summary - User config: not provided
+===========================================================================================================================================
+|Freq | Memory Optimization Opportunities (Clustered by node-level activation patterns) |
+|_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|
+|6 |For each row options are mutually exclusive, only one of them can be enabled. |
+| | |
+| |>>Option 1 : Recompute subgraph FusedMatMul+Add+Reshape+ |
+| | Status : Disabled. Enable with export ORTMODULE_MEMORY_OPT_CONFIG=FusedMatMul+Add+Reshape+:1:-1 |
+| | Stashed Activations: |
+| | - ReuseFreq : Output 0(6), |
+| | - Output 0 : [((inputs_input_ids_dim0)*(inputs_input_ids_dim1)*(32)*(240))], byte/elem: 2, 100% saved |
+|_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|
+|5 |For each row options are mutually exclusive, only one of them can be enabled. |
+| | |
+| |>>Option 1 : Recompute subgraph FusedMatMul+ |
+| | Status : Disabled. Enable with export ORTMODULE_MEMORY_OPT_CONFIG=FusedMatMul+:1:-1 |
+| | Stashed Activations: |
+| | - Output 0 : [((inputs_input_ids_dim0)*(inputs_input_ids_dim1)*(10240))], byte/elem: 2, 100% saved |
+|_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|
+|5 |For each row options are mutually exclusive, only one of them can be enabled. |
+| | |
+| |>>Option 1 : Recompute subgraph Cast+ |
+| | Status : Disabled. Enable with export ORTMODULE_MEMORY_OPT_CONFIG=Cast+:1:-1 |
+| | Stashed Activations: |
+| | - Output 0 : [((inputs_input_ids_dim0)*(32)*(inputs_input_ids_dim1)*(inputs_input_ids_dim1))], byte/elem: 2, 100% saved |
+|_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|
+|1 |For each row options are mutually exclusive, only one of them can be enabled. |
+| | |
+| |>>Option 1 : Recompute subgraph Reshape+Unsqueeze+Unsqueeze+Cast+Sub+Mul+Cast+ |
+| | Status : Disabled. Enable with export ORTMODULE_MEMORY_OPT_CONFIG=Reshape+Unsqueeze+Unsqueeze+Cast+Sub+Mul+Cast+:1:-1 |
+| | Stashed Activations: |
+| | - Output 0 : [((inputs_input_ids_dim0)*(1)*(1)*(inputs_input_ids_dim1))], byte/elem: 4, 100% saved |
+| | |
+| |>>Option 2 : RecomputeWithCompromise subgraph Cast+ |
+| | Status : Disabled. Enable with export ORTMODULE_MEMORY_OPT_CONFIG=Cast+:2:-1 |
+| | Stashed Activations: |
+| | - Output 0 : [((inputs_input_ids_dim0)*(1)*(1)*(inputs_input_ids_dim1))], byte/elem: 4, 50% saved |
+|_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|
-If you check the above logs, there is a separate section called "RecomputeWithCompromise". Recompute the subgraphs under it usually will save part of the activation (for example half of them), not all of them. Follow the same way to enable it.
+```
## Notes
-The feature is in experimental stage, we will tune and refine it according to real use cases.
+The feature is in the experimental stage, we will tune and refine it according to real use cases.
diff --git a/docs/ORTModule_Training_Guidelines.md b/docs/ORTModule_Training_Guidelines.md
index 12733c3551704..bede16204d420 100644
--- a/docs/ORTModule_Training_Guidelines.md
+++ b/docs/ORTModule_Training_Guidelines.md
@@ -146,7 +146,6 @@ Check [DebugOptions implementation](../orttraining/orttraining/python/training/o
export ORTMODULE_ONNX_OPSET_VERSION=14
```
-
#### ORTMODULE_FALLBACK_POLICY
- **Feature Area**: *ORTMODULE/FallbackToPytorch*
@@ -155,7 +154,6 @@ Check [DebugOptions implementation](../orttraining/orttraining/python/training/o
export ORTMODULE_FALLBACK_POLICY="FALLBACK_DISABLE"
```
-
#### ORTMODULE_LOG_LEVEL
- **Feature Area**: *ORTMODULE/DebugOptions*
@@ -182,7 +180,6 @@ The output directory of the onnx models by default is set to the current working
> On the other hand, if the wrapped computation graph is small, it is reasonable to allow it.
> Overall users should be aware that ORT performance boost might be trivial when they explicitly allow it.
-
#### ORTMODULE_ENABLE_CUSTOM_AUTOGRAD
- **Feature Area**: *ORTMODULE/PythonOp (torch.autograd.Function)*
@@ -199,8 +196,6 @@ The output directory of the onnx models by default is set to the current working
enable_custom_autograd_support(False)
```
-
-
#### ORTMODULE_ENABLE_COMPUTE_OPTIMIZER
- **Feature Area**: *ORTMODULE/Optimizations*
@@ -269,6 +264,35 @@ data sparsity based performance optimizations.
unset ORTMODULE_CACHE_DIR # Disable
```
+#### ORTMODULE_USE_EFFICIENT_ATTENTION
+
+- **Feature Area**: *ORTMODULE/Optimizations*
+- **Description**: By default, this is disabled. This env var can be used for enabling attention fusion and falling back to PyTorch's efficient_attention ATen kernel for execution. NOTE that it requires torch's version is 2.1.1 or above. There are some build-in patterns for attention fusion, if none of the patterns works for your model, you can add a custom one in your user script manually.
+
+ ```bash
+ export ORTMODULE_USE_EFFICIENT_ATTENTION=1
+ ```
+
+#### ORTMODULE_DEEPCOPY_BEFORE_MODEL_EXPORT
+
+- **Feature Area**: *ORTMODULE/Optimizations*
+- **Description**: By default, this is enabled. This env var can be used for enabling or disabling the module deep copy when preparing output data which will be used by ONNX export.
+A classical usage of disabling the deep copy: when the deep copy before module export bring the memory peak, then we should disable it and have a try.
+
+ ```bash
+ export ORTMODULE_DEEPCOPY_BEFORE_MODEL_EXPORT=1 # Enable
+ export ORTMODULE_DEEPCOPY_BEFORE_MODEL_EXPORT=0 # Disable
+ ```
+
+#### ORTMODULE_MEMORY_OPT_LEVEL
+
+- **Feature Area**: *ORTMODULE/Optimizations*
+- **Description**: By default, the level is 0. This env var can be used for enabling recomputation for reducing memory peak requirement. Setting the level to be 0 means all detected subgraphs with each transformer-based model layer generating stashed activations will be recomputed. This is conceptually equivalent to PyTorch's gradient checkpoint. When level is not 0, check Check [Memory Optimizer for ONNX Runtime Training](Memory_Optimizer.md) for more details.
+
+ ```bash
+ export ORTMODULE_MEMORY_OPT_LEVEL=0
+ ```
+
### 2.2 Memory Optimization
Q: *Want to run a bigger batch size?*
@@ -370,6 +394,30 @@ Check [FP16_Optimizer implementation](../orttraining/orttraining/python/training
export ORTMODULE_USE_TRITON=1
```
+#### ORTMODULE_TRITON_CONFIG_FILE
+
+- **Feature Area**: *ORTMODULE/TritonOp*
+- **Description**: Triton codegen currently supported some Ops such as some elementwise Ops and some reduction Ops. If Triton optimization is enabled, all these supported Ops will be optimized by default if possible. User can provide a customized JSON config file to control which Ops to optimize and how to optimize them. Below is a sample of config JSON. For each Op, Opset version list and domain is needed. Currently "conditions" field can be used to control axis/axes attribute or input, by specify the real value, or "single" means it contains only one dimension, or "constant" means it must be constant tensor. Save the JSON as a file somewhere and assign its path to below env variable to enable the customized config.
+
+ ```json
+ {
+ "ops": {
+ "Add": {"versions": [13, 14]},
+ "Sub": {"versions": [13, 14]},
+ "Identity": {"versions": [13], "is_no_op": True},
+ "ReduceSum": {"versions": [13], "conditions": {"axes": "[-1]"}},
+ "Softmax": {"versions": [13]},
+ "SoftmaxGrad_13": {"domain": "com.microsoft", "versions": [1]}
+ },
+ "initializer": "scalar",
+ "min_nodes": 2
+ }
+ ```
+
+ ```bash
+ export ORTMODULE_TRITON_CONFIG_FILE=triton_config.json
+ ```
+
#### ORTMODULE_ENABLE_TUNING
- **Feature Area**: *ORTMODULE/TritonOp*
@@ -397,6 +445,15 @@ Check [FP16_Optimizer implementation](../orttraining/orttraining/python/training
export ORTMODULE_TUNING_RESULTS_PATH=/tmp/tuning_results
```
+#### ORTMODULE_USE_FLASH_ATTENTION
+
+- **Feature Area**: *ORTMODULE/TritonOp*
+- **Description**: By default, this is disabled. This env var can be used for enabling attention fusion and using Flash Attention's Triton version as the kernel. NOTE that it requires ORTMODULE_USE_TRITON to be enabled, and CUDA device capability is 8.0 or above. There are some build-in patterns for attention fusion, if none of the patterns works for your model, you can add a custom one in your user script manually.
+
+ ```bash
+ export ORTMODULE_USE_FLASH_ATTENTION=1
+ ```
+
#### ORTMODULE_TRITON_DEBUG
- **Feature Area**: *ORTMODULE/TritonOp*
diff --git a/docs/OperatorKernels.md b/docs/OperatorKernels.md
index 26b5ebbdbec36..1ce9b3254d91f 100644
--- a/docs/OperatorKernels.md
+++ b/docs/OperatorKernels.md
@@ -80,7 +80,8 @@ Do not modify directly.*
|Crop|*in* input:**T**
*out* output:**T**|1+|**T** = tensor(float)|
|CumSum|*in* x:**T**
*in* axis:**T2**
*out* y:**T**|14+|**T** = tensor(double), tensor(float), tensor(int32), tensor(int64)
**T2** = tensor(int32), tensor(int64)|
|||[11, 13]|**T** = tensor(double), tensor(float), tensor(int32), tensor(int64)
**T2** = tensor(int32), tensor(int64)|
-|DFT|*in* input:**T1**
*in* dft_length:**T2**
*in* axis:**tensor(int64)**
*out* output:**T1**
or
*in* input:**T1**
*in* dft_length:**T2**
*out* output:**T1**|17+|**T1** = tensor(double), tensor(float)
**T2** = tensor(int32), tensor(int64)|
+|DFT|*in* input:**T1**
*in* dft_length:**T2**
*in* axis:**tensor(int64)**
*out* output:**T1**
or
*in* input:**T1**
*in* dft_length:**T2**
*out* output:**T1**|20+|**T1** = tensor(double), tensor(float)
**T2** = tensor(int32), tensor(int64)|
+|||[17, 19]|**T1** = tensor(double), tensor(float)
**T2** = tensor(int32), tensor(int64)|
|DepthToSpace|*in* input:**T**
*out* output:**T**|13+|**T** = tensor(double), tensor(float)|
|||[11, 12]|**T** = tensor(double), tensor(float)|
|||[1, 10]|**T** = tensor(double), tensor(float)|
@@ -373,7 +374,7 @@ Do not modify directly.*
|||[13, 17]|**T** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
|||[11, 12]|**T** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
|||[2, 10]|**T** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
-|SplitToSequence|*in* input:**T**
*in* split:**I**
*out* output_sequence:**S**|11+|**I** = tensor(int32), tensor(int64)
**S** = seq(tensor(bfloat16)), seq(tensor(bool)), seq(tensor(double)), seq(tensor(float)), seq(tensor(float16)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(int8)), seq(tensor(string)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(uint8))
**T** = tensor(double), tensor(float), tensor(int32), tensor(int64), tensor(string)|
+|SplitToSequence|*in* input:**T**
*in* split:**I**
*out* output_sequence:**S**|11+|**I** = tensor(int32), tensor(int64)
**S** = seq(tensor(bfloat16)), seq(tensor(bool)), seq(tensor(double)), seq(tensor(float)), seq(tensor(float16)), seq(tensor(int16)), seq(tensor(int32)), seq(tensor(int64)), seq(tensor(int8)), seq(tensor(string)), seq(tensor(uint16)), seq(tensor(uint32)), seq(tensor(uint64)), seq(tensor(uint8))
**T** = tensor(double), tensor(float), tensor(float16), tensor(int32), tensor(int64), tensor(string)|
|Sqrt|*in* X:**T**
*out* Y:**T**|13+|**T** = tensor(double), tensor(float)|
|||[6, 12]|**T** = tensor(double), tensor(float)|
|Squeeze|*in* data:**T**
*in* axes:**tensor(int64)**
*out* squeezed:**T**
or
*in* data:**T**
*out* squeezed:**T**|13+|**T** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
@@ -840,7 +841,7 @@ Do not modify directly.*
|Inverse|*in* X:**T**
*out* Y:**T**|1+|**T** = tensor(double), tensor(float), tensor(float16)|
|Irfft|*in* X:**T**
*out* Y:**T**|1+|**T** = tensor(double), tensor(float), tensor(float16)|
|LongformerAttention|*in* input:**T**
*in* weight:**T**
*in* bias:**T**
*in* mask:**T**
*in* global_weight:**T**
*in* global_bias:**T**
*in* global:**G**
*out* output:**T**|1+|**T** = tensor(float), tensor(float16)|
-|MatMulBnb4|*in* A:**T1**
*in* B:**T2**
*in* absmax:**T1**
*out* Y:**T1**|1+|**T1** = tensor(float), tensor(float16)
**T2** = tensor(uint8)|
+|MatMulBnb4|*in* A:**T1**
*in* B:**T2**
*in* absmax:**T1**
*out* Y:**T1**|1+|**T1** = tensor(bfloat16), tensor(float), tensor(float16)
**T2** = tensor(uint8)|
|MatMulNBits|*in* A:**T1**
*in* B:**T2**
*in* scales:**T1**
*in* zero_points:**T2**
*out* Y:**T1**|1+|**T1** = tensor(float), tensor(float16)
**T2** = tensor(uint8)|
|MoE|*in* input:**T**
*in* router_probs:**T**
*in* fc1_experts_weights:**T**
*in* fc2_experts_weights:**T**
*in* fc1_experts_bias:**T**
*in* fc2_experts_bias:**T**
*out* output:**T**|1+|**T** = tensor(float), tensor(float16)|
|MultiHeadAttention|*in* query:**T**
*in* key:**T**
*in* value:**T**
*in* bias:**T**
*in* key_padding_mask:**M**
*in* relative_position_bias:**T**
*in* past_key:**T**
*in* past_value:**T**
*out* output:**T**
*out* present_key:**T**
*out* present_value:**T**|1+|**T** = tensor(float), tensor(float16)|
diff --git a/docs/python/api_summary.rst b/docs/python/api_summary.rst
index cecd62aff15c4..092b42010a5c6 100644
--- a/docs/python/api_summary.rst
+++ b/docs/python/api_summary.rst
@@ -274,6 +274,77 @@ SessionOptions
.. autoclass:: onnxruntime.SessionOptions
:members:
+.. autoclass:: onnxruntime.ExecutionMode
+ :members:
+
+.. autoclass:: onnxruntime.ExecutionOrder
+ :members:
+
+.. autoclass:: onnxruntime.GraphOptimizationLevel
+ :members:
+
+.. autoclass:: onnxruntime.OrtAllocatorType
+ :members:
+
+.. autoclass:: onnxruntime.OrtArenaCfg
+ :members:
+
+.. autoclass:: onnxruntime.OrtMemoryInfo
+ :members:
+
+.. autoclass:: onnxruntime.OrtMemType
+ :members:
+
+Functions
+---------
+
+Allocators
+^^^^^^^^^^
+
+.. autofunction:: onnxruntime.create_and_register_allocator
+
+.. autofunction:: onnxruntime.create_and_register_allocator_v2
+
+Telemetry events
+^^^^^^^^^^^^^^^^
+
+.. autofunction:: onnxruntime.disable_telemetry_events
+
+.. autofunction:: onnxruntime.enable_telemetry_events
+
+Providers
+^^^^^^^^^
+
+.. autofunction:: onnxruntime.get_all_providers
+
+.. autofunction:: onnxruntime.get_available_providers
+
+Build, Version
+^^^^^^^^^^^^^^
+
+.. autofunction:: onnxruntime.get_build_info
+
+.. autofunction:: onnxruntime.get_version_string
+
+.. autofunction:: onnxruntime.has_collective_ops
+
+Device
+^^^^^^
+
+.. autofunction:: onnxruntime.get_device
+
+Logging
+^^^^^^^
+
+.. autofunction:: onnxruntime.set_default_logger_severity
+
+.. autofunction:: onnxruntime.set_default_logger_verbosity
+
+Random
+^^^^^^
+
+.. autofunction:: onnxruntime.set_seed
+
Data
----
@@ -298,6 +369,9 @@ IOBinding
.. autoclass:: onnxruntime.IOBinding
:members:
+.. autoclass:: onnxruntime.SessionIOBinding
+ :members:
+
OrtDevice
^^^^^^^^^
diff --git a/include/onnxruntime/core/framework/tensor_shape.h b/include/onnxruntime/core/framework/tensor_shape.h
index b3783696b8d78..82a1c1de83523 100644
--- a/include/onnxruntime/core/framework/tensor_shape.h
+++ b/include/onnxruntime/core/framework/tensor_shape.h
@@ -2,34 +2,17 @@
// Licensed under the MIT License.
#pragma once
-#include
-#include
+
#include
-#include
#include
-#include "core/common/gsl.h"
-#include "onnxruntime_config.h"
-
-#ifndef DISABLE_ABSEIL
-// Need to include abseil inlined_vector.h header directly here
-// as hash tables cause CUDA 10.2 compilers to fail. inlined_vector.h is fine.
-#ifdef _MSC_VER
-#pragma warning(push)
-// C4127: conditional expression is constant
-#pragma warning(disable : 4127)
-// C4324: structure was padded due to alignment specifier
-// Usage of alignas causes some internal padding in places.
-#pragma warning(disable : 4324)
-#endif
-
-#include
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-#endif // DISABLE_ABSEIL
+#include
+#include
+#include
+#include "core/common/gsl.h"
+#include "core/common/inlined_containers_fwd.h"
#include "core/common/span_utils.h"
+#include "onnxruntime_config.h"
namespace onnxruntime {
#ifdef __GNUC__
@@ -41,18 +24,10 @@ namespace onnxruntime {
constexpr size_t kTensorShapeSmallBufferElementsSize = 5;
-#ifndef DISABLE_ABSEIL
// Use this type to build a shape and then create TensorShape.
-using TensorShapeVector = absl::InlinedVector;
-#else
-class TensorShapeVector : public std::vector {
- using Base = std::vector;
-
- public:
- using Base::Base;
-};
-
-#endif // DISABLE_ABSEIL
+// We opt to re-use a common instantiation instead of a typedef with kTensorShapeSmallBufferElementsSize
+// To reduce on binary size.
+using TensorShapeVector = InlinedVector;
inline TensorShapeVector ToShapeVector(const gsl::span& span) {
TensorShapeVector out;
@@ -194,9 +169,7 @@ class TensorShape {
friend struct ProviderHostImpl; // So that the shared provider interface can access Allocate
};
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
+
// operator<< to nicely output to a stream
std::ostream& operator<<(std::ostream& out, const TensorShape& shape);
diff --git a/include/onnxruntime/core/graph/constants.h b/include/onnxruntime/core/graph/constants.h
index 7e59aad80cc47..9b26ba914c7dd 100644
--- a/include/onnxruntime/core/graph/constants.h
+++ b/include/onnxruntime/core/graph/constants.h
@@ -55,4 +55,7 @@ constexpr const char* kAzureExecutionProvider = "AzureExecutionProvider";
constexpr const char* kExecutionProviderSharedLibraryPath = "shared_lib_path";
constexpr const char* kExecutionProviderSharedLibraryEntry = "provider_factory_entry_point";
+// For Priority based graph topology sorting.
+constexpr const char* kBackwardNodeAttributeName = "__backwardpass";
+
} // namespace onnxruntime
diff --git a/include/onnxruntime/core/graph/graph.h b/include/onnxruntime/core/graph/graph.h
index fe0734c51f807..22827d43b200f 100644
--- a/include/onnxruntime/core/graph/graph.h
+++ b/include/onnxruntime/core/graph/graph.h
@@ -668,7 +668,7 @@ class Node {
The Graph representation containing the graph inputs and outputs, the Node instances,
and the edges connecting the nodes.
*/
-class Graph {
+class Graph { // NOLINT(clang-analyzer-optin.performance.Padding): preserve existing data member order for readability
public:
/** Gets the Graph name. */
const std::string& Name() const noexcept;
diff --git a/include/onnxruntime/core/providers/dml/dml_provider_factory.h b/include/onnxruntime/core/providers/dml/dml_provider_factory.h
index cf3ddc3f125f9..7d7f05193f486 100644
--- a/include/onnxruntime/core/providers/dml/dml_provider_factory.h
+++ b/include/onnxruntime/core/providers/dml/dml_provider_factory.h
@@ -37,9 +37,13 @@ enum OrtDmlPerformancePreference {
};
enum OrtDmlDeviceFilter : uint32_t {
+#ifdef ENABLE_NPU_ADAPTER_ENUMERATION
Any = 0xffffffff,
Gpu = 1 << 0,
Npu = 1 << 1,
+#else
+ Gpu = 1 << 0,
+#endif
};
inline OrtDmlDeviceFilter operator~(OrtDmlDeviceFilter a) { return (OrtDmlDeviceFilter) ~(int)a; }
diff --git a/include/onnxruntime/core/session/onnxruntime_c_api.h b/include/onnxruntime/core/session/onnxruntime_c_api.h
index cddad732104ed..c41700453a73b 100644
--- a/include/onnxruntime/core/session/onnxruntime_c_api.h
+++ b/include/onnxruntime/core/session/onnxruntime_c_api.h
@@ -3598,6 +3598,7 @@ struct OrtApi {
* "qnn_context_cache_path": explicitly provide the QNN context cache file. Default to model_file.onnx.bin if not provided.
* "profiling_level": QNN profiling level, options: "off", "basic", "detailed". Default to off.
* "rpc_control_latency": QNN RPC control latency.
+ * "vtcm_mb": QNN VTCM size in MB. default to 0(not set).
* "htp_performance_mode": QNN performance mode, options: "burst", "balanced", "default", "high_performance",
* "high_power_saver", "low_balanced", "low_power_saver", "power_saver", "sustained_high_performance". Default to "default".
* "qnn_context_embed_mode", 1 means dump the QNN context binary into node attribute EPContext->ep_cache_context in the ONNX skeleton model.
diff --git a/include/onnxruntime/core/session/onnxruntime_lite_custom_op.h b/include/onnxruntime/core/session/onnxruntime_lite_custom_op.h
index 443710884743a..0c0af16d4e20c 100644
--- a/include/onnxruntime/core/session/onnxruntime_lite_custom_op.h
+++ b/include/onnxruntime/core/session/onnxruntime_lite_custom_op.h
@@ -399,6 +399,15 @@ struct TensorArray : public ArgBase {
using Variadic = TensorArray;
+/*
+Note:
+OrtLiteCustomOp inherits from OrtCustomOp to bridge tween a custom func/struct and ort core.
+The lifetime of an OrtLiteCustomOp instance is managed by customer code, not ort, so:
+1. DO NOT cast OrtLiteCustomOp to OrtCustomOp and release since there is no virtual destructor in the hierachy.
+2. OrtLiteCustomFunc and OrtLiteCustomStruct, as two sub-structs, can be released in form of OrtLiteCustomOp since all members are kept in the OrtLiteCustomOp,
+ hence memory could still be recycled properly.
+Further, OrtCustomOp is a c struct bearing no v-table, so offspring structs are by design to be of zero virtual functions to maintain cast safety.
+*/
struct OrtLiteCustomOp : public OrtCustomOp {
using ConstOptionalFloatTensor = std::optional&>;
using OptionalFloatTensor = std::optional>;
@@ -774,10 +783,13 @@ struct OrtLiteCustomOp : public OrtCustomOp {
OrtLiteCustomOp(const char* op_name,
const char* execution_provider,
- int start_ver = 1, int end_ver = MAX_CUSTOM_OP_END_VER) : op_name_(op_name),
- execution_provider_(execution_provider),
- start_ver_(start_ver),
- end_ver_(end_ver) {
+ ShapeInferFn shape_infer_fn,
+ int start_ver = 1,
+ int end_ver = MAX_CUSTOM_OP_END_VER) : op_name_(op_name),
+ execution_provider_(execution_provider),
+ shape_infer_fn_(shape_infer_fn),
+ start_ver_(start_ver),
+ end_ver_(end_ver) {
OrtCustomOp::version = ORT_API_VERSION;
OrtCustomOp::GetName = [](const OrtCustomOp* op) { return static_cast(op)->op_name_.c_str(); };
@@ -858,8 +870,13 @@ struct OrtLiteCustomOp : public OrtCustomOp {
std::vector input_types_;
std::vector output_types_;
+ ShapeInferFn shape_infer_fn_ = {};
+
int start_ver_ = 1;
int end_ver_ = MAX_CUSTOM_OP_END_VER;
+
+ void* compute_fn_ = {};
+ void* compute_fn_return_status_ = {};
};
//////////////////////////// OrtLiteCustomFunc ////////////////////////////////
@@ -891,9 +908,8 @@ struct OrtLiteCustomFunc : public OrtLiteCustomOp {
ComputeFn compute_fn,
ShapeInferFn shape_infer_fn = {},
int start_ver = 1,
- int end_ver = MAX_CUSTOM_OP_END_VER) : OrtLiteCustomOp(op_name, execution_provider, start_ver, end_ver),
- compute_fn_(compute_fn),
- shape_infer_fn_(shape_infer_fn) {
+ int end_ver = MAX_CUSTOM_OP_END_VER) : OrtLiteCustomOp(op_name, execution_provider, shape_infer_fn, start_ver, end_ver) {
+ compute_fn_ = reinterpret_cast(compute_fn);
ParseArgs(input_types_, output_types_);
OrtCustomOp::KernelCompute = [](void* op_kernel, OrtKernelContext* context) {
@@ -905,7 +921,8 @@ struct OrtLiteCustomFunc : public OrtLiteCustomOp {
OrtCustomOp::CreateKernel = [](const OrtCustomOp* this_, const OrtApi* ort_api, const OrtKernelInfo* info) {
auto kernel = std::make_unique();
- kernel->compute_fn_ = static_cast(this_)->compute_fn_;
+ auto me = static_cast(this_);
+ kernel->compute_fn_ = reinterpret_cast(me->compute_fn_);
Ort::ThrowOnError(ort_api->KernelInfo_GetInputCount(info, &kernel->num_input_));
Ort::ThrowOnError(ort_api->KernelInfo_GetOutputCount(info, &kernel->num_output_));
auto self = static_cast(this_);
@@ -931,9 +948,8 @@ struct OrtLiteCustomFunc : public OrtLiteCustomOp {
ComputeFnReturnStatus compute_fn_return_status,
ShapeInferFn shape_infer_fn = {},
int start_ver = 1,
- int end_ver = MAX_CUSTOM_OP_END_VER) : OrtLiteCustomOp(op_name, execution_provider, start_ver, end_ver),
- compute_fn_return_status_(compute_fn_return_status),
- shape_infer_fn_(shape_infer_fn) {
+ int end_ver = MAX_CUSTOM_OP_END_VER) : OrtLiteCustomOp(op_name, execution_provider, shape_infer_fn, start_ver, end_ver) {
+ compute_fn_return_status_ = reinterpret_cast(compute_fn_return_status);
ParseArgs(input_types_, output_types_);
OrtCustomOp::KernelComputeV2 = [](void* op_kernel, OrtKernelContext* context) -> OrtStatusPtr {
@@ -945,7 +961,8 @@ struct OrtLiteCustomFunc : public OrtLiteCustomOp {
OrtCustomOp::CreateKernel = [](const OrtCustomOp* this_, const OrtApi* ort_api, const OrtKernelInfo* info) {
auto kernel = std::make_unique();
- kernel->compute_fn_return_status_ = static_cast(this_)->compute_fn_return_status_;
+ auto me = static_cast(this_);
+ kernel->compute_fn_return_status_ = reinterpret_cast(me->compute_fn_return_status_);
Ort::ThrowOnError(ort_api->KernelInfo_GetInputCount(info, &kernel->num_input_));
Ort::ThrowOnError(ort_api->KernelInfo_GetOutputCount(info, &kernel->num_output_));
auto self = static_cast(this_);
@@ -965,10 +982,6 @@ struct OrtLiteCustomFunc : public OrtLiteCustomOp {
};
}
}
-
- ComputeFn compute_fn_ = {};
- ComputeFnReturnStatus compute_fn_return_status_ = {};
- ShapeInferFn shape_infer_fn_ = {};
}; // struct OrtLiteCustomFunc
/////////////////////////// OrtLiteCustomStruct ///////////////////////////
@@ -1007,7 +1020,7 @@ struct OrtLiteCustomStruct : public OrtLiteCustomOp {
OrtLiteCustomStruct(const char* op_name,
const char* execution_provider,
int start_ver = 1,
- int end_ver = MAX_CUSTOM_OP_END_VER) : OrtLiteCustomOp(op_name, execution_provider, start_ver, end_ver) {
+ int end_ver = MAX_CUSTOM_OP_END_VER) : OrtLiteCustomOp(op_name, execution_provider, {}, start_ver, end_ver) {
SetCompute(&CustomOp::Compute);
OrtCustomOp::CreateKernel = [](const OrtCustomOp* this_, const OrtApi* ort_api, const OrtKernelInfo* info) {
diff --git a/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h b/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h
index 831def24e4f5e..a94973b2cc5d7 100644
--- a/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h
+++ b/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h
@@ -80,17 +80,17 @@ static const char* const kOrtSessionOptionsDisableAheadOfTimeFunctionInlining =
#ifdef ENABLE_TRAINING
// Specifies a list of op types for memory footprint reduction.
// The value should be a ","-delimited list of pair of
-// .
+// .
// For example, "Gelu+Cast+:1:0,Dropout+:1:1".
// A valid "subgraph string" should be one subgraph representation output by ORT graph transformations.
// "optimization strategy" currently has valid values: 0 - disabled, 1 - recompute.
// "number of subgraph to apply" is used to control how many subgraphs to apply optimization, to avoid "oversaving"
// the memory.
-static const char* const kOrtSessionOptionsMemoryOptimizerEnabler = "optimization.enable_memory_optimizer";
+static const char* const kOrtSessionOptionsMemoryOptimizerEnabler = "optimization.memory_optimizer_config";
-// Specifies the level for detecting subgraphs for memory footprint reduction.
-// The value should be an integer. The default value is 0.
-static const char* const kOrtSessionOptionsMemoryOptimizerProbeLevel = "optimization.enable_memory_probe_recompute_level";
+// Specifies the config for detecting subgraphs for memory footprint reduction.
+// The value should be a string contains int separated using commas. The default value is "0:0".
+static const char* const kOrtSessionOptionsMemoryOptimizerProbeConfig = "optimization.enable_memory_probe_recompute_config";
#endif
// Enable or disable using device allocator for allocating initialized tensor memory. "1": enable; "0": disable. The default is "0".
diff --git a/js/.eslintrc.js b/js/.eslintrc.js
index fd30cb96a5bd0..0bf47c5264f61 100644
--- a/js/.eslintrc.js
+++ b/js/.eslintrc.js
@@ -5,10 +5,18 @@
module.exports = {
root: true,
- ignorePatterns: ['**/*.js', 'ort-schema/', 'common/test/type-tests/', 'test/data/', 'node_modules/', 'dist/'],
+ ignorePatterns: [
+ '**/*.js',
+ 'node_modules/',
+ 'ort-schema/',
+ 'common/test/type-tests/',
+ 'web/types.d.ts',
+ 'test/data/',
+ 'dist/',
+ ],
env: { 'es6': true },
parser: '@typescript-eslint/parser',
- parserOptions: { 'project': 'tsconfig.json', 'sourceType': 'module' },
+ parserOptions: { 'project': true, 'sourceType': 'module' },
plugins: ['@typescript-eslint', 'prefer-arrow', 'header', 'import', 'unicorn', 'jsdoc'],
rules: {
'unicorn/filename-case': 'error',
@@ -144,15 +152,56 @@ module.exports = {
'no-unused-expressions': 'off',
}
}, {
- files: ['web/lib/**/*.ts'],
- excludedFiles: 'web/lib/wasm/proxy-worker/**/*',
- parserOptions: { 'project': 'web/tsconfig.json' },
- rules: {
- 'no-underscore-dangle': 'off',
+ files: ['web/lib/**/*.ts'], rules: {
+ 'no-underscore-dangle': ['error', {
+ 'allow': [
+ '_free',
+ '_malloc',
+ '_JsepGetNodeName',
+ '_JsepOutput',
+ '_OrtAddFreeDimensionOverride',
+ '_OrtAddRunConfigEntry',
+ '_OrtAddSessionConfigEntry',
+ '_OrtAppendExecutionProvider',
+ '_OrtBindInput',
+ '_OrtBindOutput',
+ '_OrtClearBoundOutputs',
+ '_OrtCreateBinding',
+ '_OrtCreateRunOptions',
+ '_OrtCreateSession',
+ '_OrtCreateSessionOptions',
+ '_OrtCreateTensor',
+ '_OrtEndProfiling',
+ '_OrtFree',
+ '_OrtGetInputName',
+ '_OrtGetInputOutputCount',
+ '_OrtGetLastError',
+ '_OrtGetOutputName',
+ '_OrtGetTensorData',
+ '_OrtInit',
+ '_OrtReleaseBinding',
+ '_OrtReleaseRunOptions',
+ '_OrtReleaseSession',
+ '_OrtReleaseSessionOptions',
+ '_OrtReleaseTensor',
+ '_OrtRun',
+ '_OrtRunWithBinding',
+ '_OrtTrainingCopyParametersFromBuffer',
+ '_OrtTrainingCopyParametersToBuffer',
+ '_OrtTrainingCreateSession',
+ '_OrtTrainingEvalStep',
+ '_OrtTrainingGetModelInputOutputCount',
+ '_OrtTrainingGetModelInputOutputName',
+ '_OrtTrainingGetParametersSize',
+ '_OrtTrainingLazyResetGrad',
+ '_OrtTrainingLoadCheckpoint',
+ '_OrtTrainingOptimizerStep',
+ '_OrtTrainingReleaseCheckpoint',
+ '_OrtTrainingReleaseSession',
+ '_OrtTrainingRunTrainStep'
+ ]
+ }]
}
- }, {
- files: ['web/lib/wasm/proxy-worker/**/*.ts'],
- parserOptions: { 'project': 'web/lib/wasm/proxy-worker/tsconfig.json' },
}, {
files: ['web/lib/onnxjs/**/*.ts'], rules: {
// TODO: those rules are useful. should turn on them in future (webgl refactor)
@@ -164,6 +213,7 @@ module.exports = {
'import/no-internal-modules': 'off',
'prefer-arrow/prefer-arrow-functions': 'off',
'no-param-reassign': 'off',
+ 'no-underscore-dangle': 'off',
'guard-for-in': 'off'
}
}, {
diff --git a/js/README.md b/js/README.md
index 7e6681e6bd897..1662de6d4ac78 100644
--- a/js/README.md
+++ b/js/README.md
@@ -344,13 +344,13 @@ From ORT v1.13 onwards the 'full' ONNX Runtime package is used. It supports both
Full build:
```sh
- python tools/ci_build/github/apple/build_ios_framework.py tools/ci_build/github/apple/default_full_ios_framework_build_settings.json --config Release
+ python tools/ci_build/github/apple/build_apple_framework.py tools/ci_build/github/apple/default_full_apple_framework_build_settings.json --config Release
```
Reduced size build:
```sh
- python tools/ci_build/github/apple/build_ios_framework.py tools/ci_build/github/apple/default_mobile_ios_framework_build_settings.json --config MinSizeRel --include_ops_by_config --enable_reduced_operator_type_support
+ python tools/ci_build/github/apple/build_apple_framework.py tools/ci_build/github/apple/default_mobile_ios_framework_build_settings.json --config MinSizeRel --include_ops_by_config --enable_reduced_operator_type_support
```
The build creates `Headers`, `LICENSE`, and `onnxruntime.xcframework` in `build/iOS_framework/framework_out` directory. From `framework_out` directory, create an archive file named `onnxruntime-c.zip` for a full build or `onnxruntime-mobile-c.zip` for a reduced size build and copy to `/js/react_native/local_pods` directory.
diff --git a/js/common/lib/backend.ts b/js/common/lib/backend.ts
index dd04ef3f15997..5460ae086fc2f 100644
--- a/js/common/lib/backend.ts
+++ b/js/common/lib/backend.ts
@@ -45,12 +45,21 @@ export interface InferenceSessionHandler extends SessionHandler {
* @ignore
*/
export interface TrainingSessionHandler extends SessionHandler {
+ readonly evalInputNames: readonly string[];
+ readonly evalOutputNames: readonly string[];
+
+ lazyResetGrad(): Promise;
runTrainStep(
feeds: SessionHandler.FeedsType, fetches: SessionHandler.FetchesType,
options: InferenceSession.RunOptions): Promise;
+ runOptimizerStep(options: InferenceSession.RunOptions): Promise;
+ runEvalStep(
+ feeds: SessionHandler.FeedsType, fetches: SessionHandler.FetchesType,
+ options: InferenceSession.RunOptions): Promise;
+ getParametersSize(trainableOnly: boolean): Promise;
loadParametersBuffer(array: Uint8Array, trainableOnly: boolean): Promise;
- getContiguousParameters(trainableOnly: boolean): Promise;
+ getContiguousParameters(trainableOnly: boolean): Promise;
}
/**
diff --git a/js/common/lib/env.ts b/js/common/lib/env.ts
index 76575ef7b9368..0cded7e5edbcb 100644
--- a/js/common/lib/env.ts
+++ b/js/common/lib/env.ts
@@ -92,11 +92,48 @@ export declare namespace Env {
async?: boolean;
}
+ export interface WebGpuProfilingDataV1TensorMetadata {
+ dims: readonly number[];
+ dataType: string;
+ }
+ export interface WebGpuProfilingDataV1 {
+ version: 1;
+ inputsMetadata: readonly WebGpuProfilingDataV1TensorMetadata[];
+ outputsMetadata: readonly WebGpuProfilingDataV1TensorMetadata[];
+ kernelId: number;
+ kernelType: string;
+ kernelName: string;
+ startTime: number;
+ endTime: number;
+ }
+
+ export type WebGpuProfilingData = WebGpuProfilingDataV1;
+
export interface WebGpuFlags {
/**
* Set or get the profiling mode.
+ *
+ * @deprecated Use `env.webgpu.profiling.mode` instead. If `env.webgpu.profiling.mode` is set, this property will be
+ * ignored.
*/
profilingMode?: 'off'|'default';
+ /**
+ * Set or get the profiling configuration.
+ */
+ profiling?: {
+ /**
+ * Set or get the profiling mode.
+ *
+ * @defaultValue `'off'`
+ */
+ mode?: 'off'|'default';
+
+ /**
+ * Set or get a callback function when a profiling data is received. If not set, the profiling data will be
+ * printed to console.
+ */
+ ondata?: (data: WebGpuProfilingData) => void;
+ };
/**
* Get the device for WebGPU.
*
diff --git a/js/common/lib/training-session-impl.ts b/js/common/lib/training-session-impl.ts
index ee6d26b22b1f6..23bd4421ae672 100644
--- a/js/common/lib/training-session-impl.ts
+++ b/js/common/lib/training-session-impl.ts
@@ -18,18 +18,37 @@ const noBackendErrMsg: string = 'Training backend could not be resolved. ' +
'Make sure you\'re using the correct configuration & WebAssembly files.';
export class TrainingSession implements TrainingSessionInterface {
- private constructor(handler: TrainingSessionHandler) {
+ private constructor(handler: TrainingSessionHandler, hasOptimizerModel: boolean, hasEvalModel: boolean) {
this.handler = handler;
+ this.hasOptimizerModel = hasOptimizerModel;
+ this.hasEvalModel = hasEvalModel;
}
private handler: TrainingSessionHandler;
+ private hasOptimizerModel: boolean;
+ private hasEvalModel: boolean;
- get inputNames(): readonly string[] {
+ get trainingInputNames(): readonly string[] {
return this.handler.inputNames;
}
- get outputNames(): readonly string[] {
+ get trainingOutputNames(): readonly string[] {
return this.handler.outputNames;
}
+ get evalInputNames(): readonly string[] {
+ if (this.hasEvalModel) {
+ return this.handler.evalInputNames;
+ } else {
+ throw new Error('This training session has no evalModel loaded.');
+ }
+ }
+ get evalOutputNames(): readonly string[] {
+ if (this.hasEvalModel) {
+ return this.handler.evalOutputNames;
+ } else {
+ throw new Error('This training session has no evalModel loaded.');
+ }
+ }
+
static async create(trainingOptions: TrainingSessionCreateOptions, sessionOptions?: SessionOptions):
Promise {
const evalModel: string|Uint8Array = trainingOptions.evalModel || '';
@@ -43,7 +62,7 @@ export class TrainingSession implements TrainingSessionInterface {
if (backend.createTrainingSessionHandler) {
const handler = await backend.createTrainingSessionHandler(
trainingOptions.checkpointState, trainingOptions.trainModel, evalModel, optimizerModel, options);
- return new TrainingSession(handler);
+ return new TrainingSession(handler, !!trainingOptions.optimizerModel, !!trainingOptions.evalModel);
} else {
throw new Error(noBackendErrMsg);
}
@@ -53,13 +72,18 @@ export class TrainingSession implements TrainingSessionInterface {
* Helper function for runTrainStep and future runStep methods that handles the type-narrowing conversion from
* the given parameters to SessionHandler.FetchesType and RunOptions.
*
+ * @param inputNames the feeds object is checked that they contain all input names in the provided list of input
+ * names.
+ * @param outputNames the fetches object is checked that their keys match up with valid names in the list of output
+ * names.
* @param feeds the required input
* @param arg1 narrowed & converted into the SessionHandler.FetchesType or RunOptions object
* @param arg2 optional RunOptions object.
* @returns
*/
- typeNarrowingForRunStep(feeds: FeedsType, arg1?: FetchesType|RunOptions, arg2?: RunOptions):
- [SessionHandler.FetchesType, RunOptions] {
+ typeNarrowingForRunStep(
+ inputNames: readonly string[], outputNames: readonly string[], feeds: FeedsType, arg1?: FetchesType|RunOptions,
+ arg2?: RunOptions): [SessionHandler.FetchesType, RunOptions] {
const fetches: {[name: string]: OnnxValue|null} = {};
let options: RunOptions = {};
// check inputs
@@ -88,7 +112,7 @@ export class TrainingSession implements TrainingSessionInterface {
if (typeof name !== 'string') {
throw new TypeError('\'fetches\' must be a string array or an object.');
}
- if (this.outputNames.indexOf(name) === -1) {
+ if (outputNames.indexOf(name) === -1) {
throw new RangeError(`'fetches' contains invalid output name: ${name}.`);
}
fetches[name] = null;
@@ -104,7 +128,7 @@ export class TrainingSession implements TrainingSessionInterface {
// if any output name is present and its value is valid OnnxValue, we consider it fetches
let isFetches = false;
const arg1Keys = Object.getOwnPropertyNames(arg1);
- for (const name of this.outputNames) {
+ for (const name of outputNames) {
if (arg1Keys.indexOf(name) !== -1) {
const v = (arg1 as InferenceSession.NullableOnnxValueMapType)[name];
if (v === null || v instanceof Tensor) {
@@ -130,7 +154,7 @@ export class TrainingSession implements TrainingSessionInterface {
}
// check if all inputs are in feed
- for (const name of this.inputNames) {
+ for (const name of inputNames) {
if (typeof feeds[name] === 'undefined') {
throw new Error(`input '${name}' is missing in 'feeds'.`);
}
@@ -138,7 +162,7 @@ export class TrainingSession implements TrainingSessionInterface {
// if no fetches is specified, we use the full output names list
if (isFetchesEmpty) {
- for (const name of this.outputNames) {
+ for (const name of outputNames) {
fetches[name] = null;
}
}
@@ -168,20 +192,58 @@ export class TrainingSession implements TrainingSessionInterface {
return returnValue;
}
+ async lazyResetGrad(): Promise {
+ await this.handler.lazyResetGrad();
+ }
+
runTrainStep(feeds: FeedsType, options?: RunOptions): Promise;
runTrainStep(feeds: FeedsType, fetches: FetchesType, options?: RunOptions): Promise;
async runTrainStep(feeds: FeedsType, arg1?: FetchesType|RunOptions, arg2?: RunOptions): Promise {
- const [fetches, options] = this.typeNarrowingForRunStep(feeds, arg1, arg2);
+ const [fetches, options] =
+ this.typeNarrowingForRunStep(this.trainingInputNames, this.trainingOutputNames, feeds, arg1, arg2);
const results = await this.handler.runTrainStep(feeds, fetches, options);
return this.convertHandlerReturnTypeToMapOfTensors(results);
}
- async loadParametersBuffer(_array: Uint8Array, _trainableOnly: boolean): Promise {
- throw new Error('Method not implemented.');
+ async runOptimizerStep(options?: InferenceSession.RunOptions|undefined): Promise {
+ if (this.hasOptimizerModel) {
+ await this.handler.runOptimizerStep(options || {});
+ } else {
+ throw new Error('This TrainingSession has no OptimizerModel loaded.');
+ }
+ }
+
+ runEvalStep(feeds: FeedsType, options?: RunOptions|undefined): Promise;
+ runEvalStep(feeds: FeedsType, fetches: FetchesType, options?: RunOptions|undefined): Promise;
+ async runEvalStep(feeds: FeedsType, arg1?: FetchesType|RunOptions, arg2?: RunOptions): Promise {
+ if (this.hasEvalModel) {
+ const [fetches, options] =
+ this.typeNarrowingForRunStep(this.evalInputNames, this.evalOutputNames, feeds, arg1, arg2);
+ const results = await this.handler.runEvalStep(feeds, fetches, options);
+ return this.convertHandlerReturnTypeToMapOfTensors(results);
+ } else {
+ throw new Error('This TrainingSession has no EvalModel loaded.');
+ }
+ }
+
+ async getParametersSize(trainableOnly = true): Promise {
+ return this.handler.getParametersSize(trainableOnly);
+ }
+
+ async loadParametersBuffer(array: Uint8Array, trainableOnly = true): Promise {
+ const paramsSize = await this.getParametersSize(trainableOnly);
+ // checking that the size of the Uint8Array is equivalent to the byte length of a Float32Array of the number
+ // of parameters
+ if (array.length !== 4 * paramsSize) {
+ throw new Error(
+ 'Size of the buffer passed into loadParametersBuffer must match the number of parameters in ' +
+ 'the model. Please use getParametersSize method to check.');
+ }
+ return this.handler.loadParametersBuffer(array, trainableOnly);
}
- async getContiguousParameters(_trainableOnly: boolean): Promise {
- throw new Error('Method not implemented.');
+ async getContiguousParameters(trainableOnly = true): Promise {
+ return this.handler.getContiguousParameters(trainableOnly);
}
async release(): Promise {
diff --git a/js/common/lib/training-session.ts b/js/common/lib/training-session.ts
index 0967d79b33434..e54aed90e702c 100644
--- a/js/common/lib/training-session.ts
+++ b/js/common/lib/training-session.ts
@@ -2,6 +2,7 @@
// Licensed under the MIT License.
import {InferenceSession} from './inference-session.js';
+import {OnnxValue} from './onnx-value.js';
import {TrainingSession as TrainingSessionImpl} from './training-session-impl.js';
/* eslint-disable @typescript-eslint/no-redeclare */
@@ -21,6 +22,12 @@ export declare namespace TrainingSession {
export interface TrainingSession {
// #region run()
+ /**
+ * Lazily resets the gradients of all trainable parameters to zero. Should happen after the invocation of
+ * runOptimizerStep.
+ */
+ lazyResetGrad(): Promise;
+
/**
* Run TrainStep asynchronously with the given feeds and options.
*
@@ -38,7 +45,7 @@ export interface TrainingSession {
* @param feeds - Representation of the model input.
* @param fetches - Representation of the model output.
* detail.
- * @param options - Optional. A set of options that controls the behavior of model inference.
+ * @param options - Optional. A set of options that controls the behavior of model training.
* @returns A promise that resolves to a map, which uses output names as keys and OnnxValue as corresponding
values.
*/
@@ -46,24 +53,68 @@ export interface TrainingSession {
feeds: InferenceSession.FeedsType, fetches: InferenceSession.FetchesType,
options?: InferenceSession.RunOptions): Promise;
+ /**
+ * Runs a single optimizer step, which performs weight updates for the trainable parameters using the optimizer model.
+ *
+ * @param options - Optional. A set of options that controls the behavior of model optimizing.
+ */
+ runOptimizerStep(options?: InferenceSession.RunOptions): Promise;
+
+ /**
+ * Run a single eval step with the given inputs and options using the eval model.
+ *
+ * @param feeds - Representation of the model input.
+ * @param options - Optional. A set of options that controls the behavior of model eval step.
+ * @returns A promise that resolves to a map, which uses output names as keys and OnnxValue as corresponding
+ values.
+ */
+ runEvalStep(feeds: InferenceSession.FeedsType, options?: InferenceSession.RunOptions):
+ Promise;
+
+ /**
+ * Run a single eval step with the given inputs and options using the eval model.
+ *
+ * @param feeds - Representation of the model input.
+ * @param fetches - Representation of the model output.
+ * detail.
+ * @param options - Optional. A set of options that controls the behavior of model eval step.
+ * @returns A promise that resolves to a map, which uses output names as keys and OnnxValue as corresponding
+ values.
+ */
+ runEvalStep(
+ feeds: InferenceSession.FeedsType, fetches: InferenceSession.FetchesType,
+ options?: InferenceSession.RunOptions): Promise;
+
// #endregion
// #region copy parameters
+
/**
- * Copies from a buffer containing parameters to the TrainingSession parameters.
+ * Retrieves the size of all parameters for the training state. Calculates the total number of primitive (datatype of
+ * the parameters) elements of all the parameters in the training state.
*
- * @param buffer - buffer containing parameters
- * @param trainableOnly - True if trainable parameters only to be modified, false otherwise.
+ * @param trainableOnly - When set to true, the size is calculated for trainable params only. Default value is true.
+ */
+ getParametersSize(trainableOnly: boolean): Promise;
+
+ /**
+ * Copies parameter values from the given array to the training state. Currently, only supporting models with
+ * parameters of type Float32.
+ *
+ * @param buffer - Float32 buffer containing parameters converted to a Uint8Array.
+ * @param trainableOnly - True if trainable parameters only to be modified, false otherwise. Default value is true.
*/
loadParametersBuffer(array: Uint8Array, trainableOnly: boolean): Promise;
/**
- * Copies from the TrainingSession parameters to a buffer.
+ * Copies the model parameters to a contiguous buffer. Usually used in the context of Federated Learning.
+ * Currently, only supporting models with parameters of type Float32.
*
- * @param trainableOnly - True if trainable parameters only to be copied, false othrwise.
- * @returns A promise that resolves to a buffer of the requested parameters.
+ * @param trainableOnly - When set to true, only trainable parameters are copied. Trainable parameters are parameters
+ * for which requires_grad is set to true. Default value is true.
+ * @returns A promise that resolves to a Float32 OnnxValue of the requested parameters.
*/
- getContiguousParameters(trainableOnly: boolean): Promise;
+ getContiguousParameters(trainableOnly: boolean): Promise;
// #endregion
// #region release()
@@ -77,14 +128,25 @@ export interface TrainingSession {
// #region metadata
/**
- * Get input names of the loaded model.
+ * Get input names of the loaded training model.
+ */
+ readonly trainingInputNames: readonly string[];
+
+ /**
+ * Get output names of the loaded training model.
*/
- readonly inputNames: readonly string[];
+ readonly trainingOutputNames: readonly string[];
/**
- * Get output names of the loaded model.
+ * Get input names of the loaded eval model. Is an empty array if no eval model is loaded.
*/
- readonly outputNames: readonly string[];
+ readonly evalInputNames: readonly string[];
+
+ /**
+ * Get output names of the loaded eval model. Is an empty array if no eval model is loaded.
+ */
+ readonly evalOutputNames: readonly string[];
+
// #endregion
}
diff --git a/js/node/lib/backend.ts b/js/node/lib/backend.ts
index 5f5ad49a2dea8..e8eb0e9babf5a 100644
--- a/js/node/lib/backend.ts
+++ b/js/node/lib/backend.ts
@@ -20,7 +20,7 @@ class OnnxruntimeSessionHandler implements InferenceSessionHandler {
}
async dispose(): Promise {
- return Promise.resolve();
+ this.#inferenceSession.dispose();
}
readonly inputNames: string[];
diff --git a/js/node/lib/binding.ts b/js/node/lib/binding.ts
index 8a0ce89abfa64..54b5767139904 100644
--- a/js/node/lib/binding.ts
+++ b/js/node/lib/binding.ts
@@ -28,6 +28,8 @@ export declare namespace Binding {
readonly outputNames: string[];
run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType;
+
+ dispose(): void;
}
export interface InferenceSessionConstructor {
diff --git a/js/node/package-lock.json b/js/node/package-lock.json
index e8968bafc4a9f..c1cf8af4bb80e 100644
--- a/js/node/package-lock.json
+++ b/js/node/package-lock.json
@@ -22,7 +22,7 @@
"jsonc": "^2.0.0",
"minimist": "^1.2.8",
"node-addon-api": "^6.0.0",
- "onnx-proto": "^8.0.1"
+ "protobufjs": "^7.2.4"
}
},
"../common": {
@@ -97,12 +97,6 @@
"integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==",
"dev": true
},
- "node_modules/@types/long": {
- "version": "4.0.2",
- "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz",
- "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==",
- "dev": true
- },
"node_modules/@types/minimist": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz",
@@ -528,9 +522,9 @@
"dev": true
},
"node_modules/long": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
- "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==",
+ "version": "5.2.3",
+ "resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz",
+ "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==",
"dev": true
},
"node_modules/lru-cache": {
@@ -663,15 +657,6 @@
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
}
},
- "node_modules/onnx-proto": {
- "version": "8.0.1",
- "resolved": "https://registry.npmjs.org/onnx-proto/-/onnx-proto-8.0.1.tgz",
- "integrity": "sha512-ZpPTqp5dneh2bvavk/QpDsf20JJRArjqTkiMfshGmxR8ocjmfTk80fkW00FwLO7qRtybo9NPugcWQrumHYctLQ==",
- "dev": true,
- "dependencies": {
- "protobufjs": "^6.11.2"
- }
- },
"node_modules/onnxruntime-common": {
"resolved": "../common",
"link": true
@@ -690,9 +675,9 @@
}
},
"node_modules/protobufjs": {
- "version": "6.11.4",
- "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.4.tgz",
- "integrity": "sha512-5kQWPaJHi1WoCpjTGszzQ32PG2F4+wRY6BmAT4Vfw56Q2FZ4YZzK20xUYQH4YkfehY1e6QSICrJquM6xXZNcrw==",
+ "version": "7.2.5",
+ "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.5.tgz",
+ "integrity": "sha512-gGXRSXvxQ7UiPgfw8gevrfRWcTlSbOFg+p/N+JVJEK5VhueL2miT6qTymqAmjr1Q5WbOCyJbyrk6JfWKwlFn6A==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
@@ -706,13 +691,11 @@
"@protobufjs/path": "^1.1.2",
"@protobufjs/pool": "^1.1.0",
"@protobufjs/utf8": "^1.1.0",
- "@types/long": "^4.0.1",
"@types/node": ">=13.7.0",
- "long": "^4.0.0"
+ "long": "^5.0.0"
},
- "bin": {
- "pbjs": "bin/pbjs",
- "pbts": "bin/pbts"
+ "engines": {
+ "node": ">=12.0.0"
}
},
"node_modules/proxy-from-env": {
@@ -789,9 +772,9 @@
]
},
"node_modules/semver": {
- "version": "7.3.8",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
- "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
+ "version": "7.5.4",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
+ "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
@@ -1070,12 +1053,6 @@
"integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==",
"dev": true
},
- "@types/long": {
- "version": "4.0.2",
- "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz",
- "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==",
- "dev": true
- },
"@types/minimist": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz",
@@ -1413,9 +1390,9 @@
"dev": true
},
"long": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
- "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==",
+ "version": "5.2.3",
+ "resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz",
+ "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==",
"dev": true
},
"lru-cache": {
@@ -1523,15 +1500,6 @@
"set-blocking": "^2.0.0"
}
},
- "onnx-proto": {
- "version": "8.0.1",
- "resolved": "https://registry.npmjs.org/onnx-proto/-/onnx-proto-8.0.1.tgz",
- "integrity": "sha512-ZpPTqp5dneh2bvavk/QpDsf20JJRArjqTkiMfshGmxR8ocjmfTk80fkW00FwLO7qRtybo9NPugcWQrumHYctLQ==",
- "dev": true,
- "requires": {
- "protobufjs": "^6.11.2"
- }
- },
"onnxruntime-common": {
"version": "file:../common",
"requires": {
@@ -1549,9 +1517,9 @@
}
},
"protobufjs": {
- "version": "6.11.4",
- "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.4.tgz",
- "integrity": "sha512-5kQWPaJHi1WoCpjTGszzQ32PG2F4+wRY6BmAT4Vfw56Q2FZ4YZzK20xUYQH4YkfehY1e6QSICrJquM6xXZNcrw==",
+ "version": "7.2.5",
+ "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.5.tgz",
+ "integrity": "sha512-gGXRSXvxQ7UiPgfw8gevrfRWcTlSbOFg+p/N+JVJEK5VhueL2miT6qTymqAmjr1Q5WbOCyJbyrk6JfWKwlFn6A==",
"dev": true,
"requires": {
"@protobufjs/aspromise": "^1.1.2",
@@ -1564,9 +1532,8 @@
"@protobufjs/path": "^1.1.2",
"@protobufjs/pool": "^1.1.0",
"@protobufjs/utf8": "^1.1.0",
- "@types/long": "^4.0.1",
"@types/node": ">=13.7.0",
- "long": "^4.0.0"
+ "long": "^5.0.0"
}
},
"proxy-from-env": {
@@ -1619,9 +1586,9 @@
"dev": true
},
"semver": {
- "version": "7.3.8",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
- "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
+ "version": "7.5.4",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
+ "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
"dev": true,
"requires": {
"lru-cache": "^6.0.0"
diff --git a/js/node/package.json b/js/node/package.json
index 0f8f0e9d2260c..8e591d8f46b9d 100644
--- a/js/node/package.json
+++ b/js/node/package.json
@@ -19,6 +19,7 @@
},
"scripts": {
"buildr": "tsc && node ./script/build --config=RelWithDebInfo",
+ "preprepare": "node -e \"require('node:fs').copyFileSync('./node_modules/long/index.d.ts', './node_modules/long/umd/index.d.ts')\"",
"prepare": "tsc --build script test .",
"rebuild": "tsc && node ./script/build --rebuild",
"rebuildd": "tsc && node ./script/build --rebuild --config=Debug",
@@ -39,7 +40,7 @@
"jsonc": "^2.0.0",
"minimist": "^1.2.8",
"node-addon-api": "^6.0.0",
- "onnx-proto": "^8.0.1"
+ "protobufjs": "^7.2.4"
},
"main": "dist/index.js",
"os": [
diff --git a/js/node/src/inference_session_wrap.cc b/js/node/src/inference_session_wrap.cc
index c409fdc8895f7..1bbb6df1ce1c8 100644
--- a/js/node/src/inference_session_wrap.cc
+++ b/js/node/src/inference_session_wrap.cc
@@ -31,6 +31,7 @@ Napi::Object InferenceSessionWrap::Init(Napi::Env env, Napi::Object exports) {
Napi::Function func = DefineClass(
env, "InferenceSession",
{InstanceMethod("loadModel", &InferenceSessionWrap::LoadModel), InstanceMethod("run", &InferenceSessionWrap::Run),
+ InstanceMethod("dispose", &InferenceSessionWrap::Dispose),
InstanceAccessor("inputNames", &InferenceSessionWrap::GetInputNames, nullptr, napi_default, nullptr),
InstanceAccessor("outputNames", &InferenceSessionWrap::GetOutputNames, nullptr, napi_default, nullptr)});
@@ -45,7 +46,7 @@ Napi::Object InferenceSessionWrap::Init(Napi::Env env, Napi::Object exports) {
}
InferenceSessionWrap::InferenceSessionWrap(const Napi::CallbackInfo &info)
- : Napi::ObjectWrap(info), initialized_(false), session_(nullptr),
+ : Napi::ObjectWrap(info), initialized_(false), disposed_(false), session_(nullptr),
defaultRunOptions_(nullptr) {}
Napi::Value InferenceSessionWrap::LoadModel(const Napi::CallbackInfo &info) {
@@ -53,6 +54,7 @@ Napi::Value InferenceSessionWrap::LoadModel(const Napi::CallbackInfo &info) {
Napi::HandleScope scope(env);
ORT_NAPI_THROW_ERROR_IF(this->initialized_, env, "Model already loaded. Cannot load model multiple times.");
+ ORT_NAPI_THROW_ERROR_IF(this->disposed_, env, "Session already disposed.");
size_t argsLength = info.Length();
ORT_NAPI_THROW_TYPEERROR_IF(argsLength == 0, env, "Expect argument: model file path or buffer.");
@@ -129,6 +131,7 @@ Napi::Value InferenceSessionWrap::LoadModel(const Napi::CallbackInfo &info) {
Napi::Value InferenceSessionWrap::GetInputNames(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
ORT_NAPI_THROW_ERROR_IF(!this->initialized_, env, "Session is not initialized.");
+ ORT_NAPI_THROW_ERROR_IF(this->disposed_, env, "Session already disposed.");
Napi::EscapableHandleScope scope(env);
return scope.Escape(CreateNapiArrayFrom(env, inputNames_));
@@ -137,6 +140,7 @@ Napi::Value InferenceSessionWrap::GetInputNames(const Napi::CallbackInfo &info)
Napi::Value InferenceSessionWrap::GetOutputNames(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
ORT_NAPI_THROW_ERROR_IF(!this->initialized_, env, "Session is not initialized.");
+ ORT_NAPI_THROW_ERROR_IF(this->disposed_, env, "Session already disposed.");
Napi::EscapableHandleScope scope(env);
return scope.Escape(CreateNapiArrayFrom(env, outputNames_));
@@ -145,6 +149,7 @@ Napi::Value InferenceSessionWrap::GetOutputNames(const Napi::CallbackInfo &info)
Napi::Value InferenceSessionWrap::Run(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
ORT_NAPI_THROW_ERROR_IF(!this->initialized_, env, "Session is not initialized.");
+ ORT_NAPI_THROW_ERROR_IF(this->disposed_, env, "Session already disposed.");
ORT_NAPI_THROW_TYPEERROR_IF(info.Length() < 2, env, "Expect argument: inputs(feed) and outputs(fetch).");
ORT_NAPI_THROW_TYPEERROR_IF(!info[0].IsObject() || !info[1].IsObject(), env,
"Expect inputs(feed) and outputs(fetch) to be objects.");
@@ -209,6 +214,18 @@ Napi::Value InferenceSessionWrap::Run(const Napi::CallbackInfo &info) {
}
}
+Napi::Value InferenceSessionWrap::Dispose(const Napi::CallbackInfo &info) {
+ Napi::Env env = info.Env();
+ ORT_NAPI_THROW_ERROR_IF(!this->initialized_, env, "Session is not initialized.");
+ ORT_NAPI_THROW_ERROR_IF(this->disposed_, env, "Session already disposed.");
+
+ this->defaultRunOptions_.reset(nullptr);
+ this->session_.reset(nullptr);
+
+ this->disposed_ = true;
+ return env.Undefined();
+}
+
Napi::Value InferenceSessionWrap::ListSupportedBackends(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::EscapableHandleScope scope(env);
diff --git a/js/node/src/inference_session_wrap.h b/js/node/src/inference_session_wrap.h
index 9eee45b72dcb1..1e789c4814cd6 100644
--- a/js/node/src/inference_session_wrap.h
+++ b/js/node/src/inference_session_wrap.h
@@ -55,6 +55,14 @@ class InferenceSessionWrap : public Napi::ObjectWrap {
*/
Napi::Value Run(const Napi::CallbackInfo &info);
+ /**
+ * [sync] dispose the session.
+ * @param nothing
+ * @returns nothing
+ * @throw nothing
+ */
+ Napi::Value Dispose(const Napi::CallbackInfo &info);
+
// private members
// persistent constructor
@@ -62,6 +70,7 @@ class InferenceSessionWrap : public Napi::ObjectWrap {
// session objects
bool initialized_;
+ bool disposed_;
std::unique_ptr session_;
std::unique_ptr defaultRunOptions_;
diff --git a/js/node/test/ort-schema/protobuf/.gitignore b/js/node/test/ort-schema/protobuf/.gitignore
new file mode 100644
index 0000000000000..092bb6c1c9fb4
--- /dev/null
+++ b/js/node/test/ort-schema/protobuf/.gitignore
@@ -0,0 +1,2 @@
+!onnx.js
+!onnx.d.ts
diff --git a/js/node/test/ort-schema/protobuf/README.md b/js/node/test/ort-schema/protobuf/README.md
new file mode 100644
index 0000000000000..f5f52c602f1ad
--- /dev/null
+++ b/js/node/test/ort-schema/protobuf/README.md
@@ -0,0 +1,21 @@
+# ONNX protobuf
+
+This directory contains generated protobuf definition for onnx:
+
+- onnx.js
+- onnx.d.ts
+
+These files are generated from [a fork of onnx-proto](https://github.com/fs-eire/onnx-proto/tree/update-v9).
+
+The ONNX protobuf uses protobufjs@7.2.4, which depends on long@5.2.3, the version contains 2 bugs:
+
+- type export does not work with commonjs. described in https://github.com/dcodeIO/long.js/pull/124. added a "postinstall" script to fix.
+- in the generated typescript declaration file 'onnx.d.ts', the following line:
+ ```ts
+ import Long = require("long");
+ ```
+ need to be replaced to fix type import error:
+ ```ts
+ import Long from "long";
+ ```
+ this replacement is done and code format is also applied to file 'onnx.d.ts'.
diff --git a/js/node/test/ort-schema/protobuf/onnx.d.ts b/js/node/test/ort-schema/protobuf/onnx.d.ts
new file mode 100644
index 0000000000000..c60264dca2a8d
--- /dev/null
+++ b/js/node/test/ort-schema/protobuf/onnx.d.ts
@@ -0,0 +1,2627 @@
+import Long from 'long';
+import * as $protobuf from 'protobufjs';
+
+/** Namespace onnx. */
+export namespace onnx {
+
+ /** Version enum. */
+ enum Version {
+ _START_VERSION = 0,
+ IR_VERSION_2017_10_10 = 1,
+ IR_VERSION_2017_10_30 = 2,
+ IR_VERSION_2017_11_3 = 3,
+ IR_VERSION_2019_1_22 = 4,
+ IR_VERSION_2019_3_18 = 5,
+ IR_VERSION_2019_9_19 = 6,
+ IR_VERSION_2020_5_8 = 7,
+ IR_VERSION_2021_7_30 = 8,
+ IR_VERSION = 9
+ }
+
+ /** Properties of an AttributeProto. */
+ interface IAttributeProto {
+ /** AttributeProto name */
+ name?: (string|null);
+
+ /** AttributeProto refAttrName */
+ refAttrName?: (string|null);
+
+ /** AttributeProto docString */
+ docString?: (string|null);
+
+ /** AttributeProto type */
+ type?: (onnx.AttributeProto.AttributeType|null);
+
+ /** AttributeProto f */
+ f?: (number|null);
+
+ /** AttributeProto i */
+ i?: (number|Long|null);
+
+ /** AttributeProto s */
+ s?: (Uint8Array|null);
+
+ /** AttributeProto t */
+ t?: (onnx.ITensorProto|null);
+
+ /** AttributeProto g */
+ g?: (onnx.IGraphProto|null);
+
+ /** AttributeProto sparseTensor */
+ sparseTensor?: (onnx.ISparseTensorProto|null);
+
+ /** AttributeProto tp */
+ tp?: (onnx.ITypeProto|null);
+
+ /** AttributeProto floats */
+ floats?: (number[]|null);
+
+ /** AttributeProto ints */
+ ints?: ((number | Long)[]|null);
+
+ /** AttributeProto strings */
+ strings?: (Uint8Array[]|null);
+
+ /** AttributeProto tensors */
+ tensors?: (onnx.ITensorProto[]|null);
+
+ /** AttributeProto graphs */
+ graphs?: (onnx.IGraphProto[]|null);
+
+ /** AttributeProto sparseTensors */
+ sparseTensors?: (onnx.ISparseTensorProto[]|null);
+
+ /** AttributeProto typeProtos */
+ typeProtos?: (onnx.ITypeProto[]|null);
+ }
+
+ /** Represents an AttributeProto. */
+ class AttributeProto implements IAttributeProto {
+ /**
+ * Constructs a new AttributeProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.IAttributeProto);
+
+ /** AttributeProto name. */
+ public name: string;
+
+ /** AttributeProto refAttrName. */
+ public refAttrName: string;
+
+ /** AttributeProto docString. */
+ public docString: string;
+
+ /** AttributeProto type. */
+ public type: onnx.AttributeProto.AttributeType;
+
+ /** AttributeProto f. */
+ public f: number;
+
+ /** AttributeProto i. */
+ public i: (number|Long);
+
+ /** AttributeProto s. */
+ public s: Uint8Array;
+
+ /** AttributeProto t. */
+ public t?: (onnx.ITensorProto|null);
+
+ /** AttributeProto g. */
+ public g?: (onnx.IGraphProto|null);
+
+ /** AttributeProto sparseTensor. */
+ public sparseTensor?: (onnx.ISparseTensorProto|null);
+
+ /** AttributeProto tp. */
+ public tp?: (onnx.ITypeProto|null);
+
+ /** AttributeProto floats. */
+ public floats: number[];
+
+ /** AttributeProto ints. */
+ public ints: (number|Long)[];
+
+ /** AttributeProto strings. */
+ public strings: Uint8Array[];
+
+ /** AttributeProto tensors. */
+ public tensors: onnx.ITensorProto[];
+
+ /** AttributeProto graphs. */
+ public graphs: onnx.IGraphProto[];
+
+ /** AttributeProto sparseTensors. */
+ public sparseTensors: onnx.ISparseTensorProto[];
+
+ /** AttributeProto typeProtos. */
+ public typeProtos: onnx.ITypeProto[];
+
+ /**
+ * Creates a new AttributeProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns AttributeProto instance
+ */
+ public static create(properties?: onnx.IAttributeProto): onnx.AttributeProto;
+
+ /**
+ * Encodes the specified AttributeProto message. Does not implicitly {@link onnx.AttributeProto.verify|verify}
+ * messages.
+ * @param message AttributeProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.IAttributeProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified AttributeProto message, length delimited. Does not implicitly {@link
+ * onnx.AttributeProto.verify|verify} messages.
+ * @param message AttributeProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.IAttributeProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes an AttributeProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns AttributeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.AttributeProto;
+
+ /**
+ * Decodes an AttributeProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns AttributeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.AttributeProto;
+
+ /**
+ * Verifies an AttributeProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates an AttributeProto message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns AttributeProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.AttributeProto;
+
+ /**
+ * Creates a plain object from an AttributeProto message. Also converts values to other types if specified.
+ * @param message AttributeProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.AttributeProto, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this AttributeProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for AttributeProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ namespace AttributeProto {
+
+ /** AttributeType enum. */
+ enum AttributeType {
+ UNDEFINED = 0,
+ FLOAT = 1,
+ INT = 2,
+ STRING = 3,
+ TENSOR = 4,
+ GRAPH = 5,
+ SPARSE_TENSOR = 11,
+ TYPE_PROTO = 13,
+ FLOATS = 6,
+ INTS = 7,
+ STRINGS = 8,
+ TENSORS = 9,
+ GRAPHS = 10,
+ SPARSE_TENSORS = 12,
+ TYPE_PROTOS = 14
+ }
+ }
+
+ /** Properties of a ValueInfoProto. */
+ interface IValueInfoProto {
+ /** ValueInfoProto name */
+ name?: (string|null);
+
+ /** ValueInfoProto type */
+ type?: (onnx.ITypeProto|null);
+
+ /** ValueInfoProto docString */
+ docString?: (string|null);
+ }
+
+ /** Represents a ValueInfoProto. */
+ class ValueInfoProto implements IValueInfoProto {
+ /**
+ * Constructs a new ValueInfoProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.IValueInfoProto);
+
+ /** ValueInfoProto name. */
+ public name: string;
+
+ /** ValueInfoProto type. */
+ public type?: (onnx.ITypeProto|null);
+
+ /** ValueInfoProto docString. */
+ public docString: string;
+
+ /**
+ * Creates a new ValueInfoProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns ValueInfoProto instance
+ */
+ public static create(properties?: onnx.IValueInfoProto): onnx.ValueInfoProto;
+
+ /**
+ * Encodes the specified ValueInfoProto message. Does not implicitly {@link onnx.ValueInfoProto.verify|verify}
+ * messages.
+ * @param message ValueInfoProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.IValueInfoProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified ValueInfoProto message, length delimited. Does not implicitly {@link
+ * onnx.ValueInfoProto.verify|verify} messages.
+ * @param message ValueInfoProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.IValueInfoProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a ValueInfoProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns ValueInfoProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.ValueInfoProto;
+
+ /**
+ * Decodes a ValueInfoProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns ValueInfoProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.ValueInfoProto;
+
+ /**
+ * Verifies a ValueInfoProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a ValueInfoProto message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns ValueInfoProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.ValueInfoProto;
+
+ /**
+ * Creates a plain object from a ValueInfoProto message. Also converts values to other types if specified.
+ * @param message ValueInfoProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.ValueInfoProto, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this ValueInfoProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for ValueInfoProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** Properties of a NodeProto. */
+ interface INodeProto {
+ /** NodeProto input */
+ input?: (string[]|null);
+
+ /** NodeProto output */
+ output?: (string[]|null);
+
+ /** NodeProto name */
+ name?: (string|null);
+
+ /** NodeProto opType */
+ opType?: (string|null);
+
+ /** NodeProto domain */
+ domain?: (string|null);
+
+ /** NodeProto attribute */
+ attribute?: (onnx.IAttributeProto[]|null);
+
+ /** NodeProto docString */
+ docString?: (string|null);
+ }
+
+ /** Represents a NodeProto. */
+ class NodeProto implements INodeProto {
+ /**
+ * Constructs a new NodeProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.INodeProto);
+
+ /** NodeProto input. */
+ public input: string[];
+
+ /** NodeProto output. */
+ public output: string[];
+
+ /** NodeProto name. */
+ public name: string;
+
+ /** NodeProto opType. */
+ public opType: string;
+
+ /** NodeProto domain. */
+ public domain: string;
+
+ /** NodeProto attribute. */
+ public attribute: onnx.IAttributeProto[];
+
+ /** NodeProto docString. */
+ public docString: string;
+
+ /**
+ * Creates a new NodeProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns NodeProto instance
+ */
+ public static create(properties?: onnx.INodeProto): onnx.NodeProto;
+
+ /**
+ * Encodes the specified NodeProto message. Does not implicitly {@link onnx.NodeProto.verify|verify} messages.
+ * @param message NodeProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.INodeProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified NodeProto message, length delimited. Does not implicitly {@link
+ * onnx.NodeProto.verify|verify} messages.
+ * @param message NodeProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.INodeProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a NodeProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns NodeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.NodeProto;
+
+ /**
+ * Decodes a NodeProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns NodeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.NodeProto;
+
+ /**
+ * Verifies a NodeProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a NodeProto message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns NodeProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.NodeProto;
+
+ /**
+ * Creates a plain object from a NodeProto message. Also converts values to other types if specified.
+ * @param message NodeProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.NodeProto, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this NodeProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for NodeProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** Properties of a TrainingInfoProto. */
+ interface ITrainingInfoProto {
+ /** TrainingInfoProto initialization */
+ initialization?: (onnx.IGraphProto|null);
+
+ /** TrainingInfoProto algorithm */
+ algorithm?: (onnx.IGraphProto|null);
+
+ /** TrainingInfoProto initializationBinding */
+ initializationBinding?: (onnx.IStringStringEntryProto[]|null);
+
+ /** TrainingInfoProto updateBinding */
+ updateBinding?: (onnx.IStringStringEntryProto[]|null);
+ }
+
+ /** Represents a TrainingInfoProto. */
+ class TrainingInfoProto implements ITrainingInfoProto {
+ /**
+ * Constructs a new TrainingInfoProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.ITrainingInfoProto);
+
+ /** TrainingInfoProto initialization. */
+ public initialization?: (onnx.IGraphProto|null);
+
+ /** TrainingInfoProto algorithm. */
+ public algorithm?: (onnx.IGraphProto|null);
+
+ /** TrainingInfoProto initializationBinding. */
+ public initializationBinding: onnx.IStringStringEntryProto[];
+
+ /** TrainingInfoProto updateBinding. */
+ public updateBinding: onnx.IStringStringEntryProto[];
+
+ /**
+ * Creates a new TrainingInfoProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns TrainingInfoProto instance
+ */
+ public static create(properties?: onnx.ITrainingInfoProto): onnx.TrainingInfoProto;
+
+ /**
+ * Encodes the specified TrainingInfoProto message. Does not implicitly {@link onnx.TrainingInfoProto.verify|verify}
+ * messages.
+ * @param message TrainingInfoProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.ITrainingInfoProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified TrainingInfoProto message, length delimited. Does not implicitly {@link
+ * onnx.TrainingInfoProto.verify|verify} messages.
+ * @param message TrainingInfoProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.ITrainingInfoProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a TrainingInfoProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns TrainingInfoProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.TrainingInfoProto;
+
+ /**
+ * Decodes a TrainingInfoProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns TrainingInfoProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.TrainingInfoProto;
+
+ /**
+ * Verifies a TrainingInfoProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a TrainingInfoProto message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns TrainingInfoProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.TrainingInfoProto;
+
+ /**
+ * Creates a plain object from a TrainingInfoProto message. Also converts values to other types if specified.
+ * @param message TrainingInfoProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.TrainingInfoProto, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this TrainingInfoProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for TrainingInfoProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** Properties of a ModelProto. */
+ interface IModelProto {
+ /** ModelProto irVersion */
+ irVersion?: (number|Long|null);
+
+ /** ModelProto opsetImport */
+ opsetImport?: (onnx.IOperatorSetIdProto[]|null);
+
+ /** ModelProto producerName */
+ producerName?: (string|null);
+
+ /** ModelProto producerVersion */
+ producerVersion?: (string|null);
+
+ /** ModelProto domain */
+ domain?: (string|null);
+
+ /** ModelProto modelVersion */
+ modelVersion?: (number|Long|null);
+
+ /** ModelProto docString */
+ docString?: (string|null);
+
+ /** ModelProto graph */
+ graph?: (onnx.IGraphProto|null);
+
+ /** ModelProto metadataProps */
+ metadataProps?: (onnx.IStringStringEntryProto[]|null);
+
+ /** ModelProto trainingInfo */
+ trainingInfo?: (onnx.ITrainingInfoProto[]|null);
+
+ /** ModelProto functions */
+ functions?: (onnx.IFunctionProto[]|null);
+ }
+
+ /** Represents a ModelProto. */
+ class ModelProto implements IModelProto {
+ /**
+ * Constructs a new ModelProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.IModelProto);
+
+ /** ModelProto irVersion. */
+ public irVersion: (number|Long);
+
+ /** ModelProto opsetImport. */
+ public opsetImport: onnx.IOperatorSetIdProto[];
+
+ /** ModelProto producerName. */
+ public producerName: string;
+
+ /** ModelProto producerVersion. */
+ public producerVersion: string;
+
+ /** ModelProto domain. */
+ public domain: string;
+
+ /** ModelProto modelVersion. */
+ public modelVersion: (number|Long);
+
+ /** ModelProto docString. */
+ public docString: string;
+
+ /** ModelProto graph. */
+ public graph?: (onnx.IGraphProto|null);
+
+ /** ModelProto metadataProps. */
+ public metadataProps: onnx.IStringStringEntryProto[];
+
+ /** ModelProto trainingInfo. */
+ public trainingInfo: onnx.ITrainingInfoProto[];
+
+ /** ModelProto functions. */
+ public functions: onnx.IFunctionProto[];
+
+ /**
+ * Creates a new ModelProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns ModelProto instance
+ */
+ public static create(properties?: onnx.IModelProto): onnx.ModelProto;
+
+ /**
+ * Encodes the specified ModelProto message. Does not implicitly {@link onnx.ModelProto.verify|verify} messages.
+ * @param message ModelProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.IModelProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified ModelProto message, length delimited. Does not implicitly {@link
+ * onnx.ModelProto.verify|verify} messages.
+ * @param message ModelProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.IModelProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a ModelProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns ModelProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.ModelProto;
+
+ /**
+ * Decodes a ModelProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns ModelProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.ModelProto;
+
+ /**
+ * Verifies a ModelProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a ModelProto message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns ModelProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.ModelProto;
+
+ /**
+ * Creates a plain object from a ModelProto message. Also converts values to other types if specified.
+ * @param message ModelProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.ModelProto, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this ModelProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for ModelProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** Properties of a StringStringEntryProto. */
+ interface IStringStringEntryProto {
+ /** StringStringEntryProto key */
+ key?: (string|null);
+
+ /** StringStringEntryProto value */
+ value?: (string|null);
+ }
+
+ /** Represents a StringStringEntryProto. */
+ class StringStringEntryProto implements IStringStringEntryProto {
+ /**
+ * Constructs a new StringStringEntryProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.IStringStringEntryProto);
+
+ /** StringStringEntryProto key. */
+ public key: string;
+
+ /** StringStringEntryProto value. */
+ public value: string;
+
+ /**
+ * Creates a new StringStringEntryProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns StringStringEntryProto instance
+ */
+ public static create(properties?: onnx.IStringStringEntryProto): onnx.StringStringEntryProto;
+
+ /**
+ * Encodes the specified StringStringEntryProto message. Does not implicitly {@link
+ * onnx.StringStringEntryProto.verify|verify} messages.
+ * @param message StringStringEntryProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.IStringStringEntryProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified StringStringEntryProto message, length delimited. Does not implicitly {@link
+ * onnx.StringStringEntryProto.verify|verify} messages.
+ * @param message StringStringEntryProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.IStringStringEntryProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a StringStringEntryProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns StringStringEntryProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.StringStringEntryProto;
+
+ /**
+ * Decodes a StringStringEntryProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns StringStringEntryProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.StringStringEntryProto;
+
+ /**
+ * Verifies a StringStringEntryProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a StringStringEntryProto message from a plain object. Also converts values to their respective internal
+ * types.
+ * @param object Plain object
+ * @returns StringStringEntryProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.StringStringEntryProto;
+
+ /**
+ * Creates a plain object from a StringStringEntryProto message. Also converts values to other types if specified.
+ * @param message StringStringEntryProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.StringStringEntryProto, options?: $protobuf.IConversionOptions):
+ {[k: string]: any};
+
+ /**
+ * Converts this StringStringEntryProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for StringStringEntryProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** Properties of a TensorAnnotation. */
+ interface ITensorAnnotation {
+ /** TensorAnnotation tensorName */
+ tensorName?: (string|null);
+
+ /** TensorAnnotation quantParameterTensorNames */
+ quantParameterTensorNames?: (onnx.IStringStringEntryProto[]|null);
+ }
+
+ /** Represents a TensorAnnotation. */
+ class TensorAnnotation implements ITensorAnnotation {
+ /**
+ * Constructs a new TensorAnnotation.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.ITensorAnnotation);
+
+ /** TensorAnnotation tensorName. */
+ public tensorName: string;
+
+ /** TensorAnnotation quantParameterTensorNames. */
+ public quantParameterTensorNames: onnx.IStringStringEntryProto[];
+
+ /**
+ * Creates a new TensorAnnotation instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns TensorAnnotation instance
+ */
+ public static create(properties?: onnx.ITensorAnnotation): onnx.TensorAnnotation;
+
+ /**
+ * Encodes the specified TensorAnnotation message. Does not implicitly {@link onnx.TensorAnnotation.verify|verify}
+ * messages.
+ * @param message TensorAnnotation message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.ITensorAnnotation, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified TensorAnnotation message, length delimited. Does not implicitly {@link
+ * onnx.TensorAnnotation.verify|verify} messages.
+ * @param message TensorAnnotation message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.ITensorAnnotation, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a TensorAnnotation message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns TensorAnnotation
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.TensorAnnotation;
+
+ /**
+ * Decodes a TensorAnnotation message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns TensorAnnotation
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.TensorAnnotation;
+
+ /**
+ * Verifies a TensorAnnotation message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a TensorAnnotation message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns TensorAnnotation
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.TensorAnnotation;
+
+ /**
+ * Creates a plain object from a TensorAnnotation message. Also converts values to other types if specified.
+ * @param message TensorAnnotation
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.TensorAnnotation, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this TensorAnnotation to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for TensorAnnotation
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** Properties of a GraphProto. */
+ interface IGraphProto {
+ /** GraphProto node */
+ node?: (onnx.INodeProto[]|null);
+
+ /** GraphProto name */
+ name?: (string|null);
+
+ /** GraphProto initializer */
+ initializer?: (onnx.ITensorProto[]|null);
+
+ /** GraphProto sparseInitializer */
+ sparseInitializer?: (onnx.ISparseTensorProto[]|null);
+
+ /** GraphProto docString */
+ docString?: (string|null);
+
+ /** GraphProto input */
+ input?: (onnx.IValueInfoProto[]|null);
+
+ /** GraphProto output */
+ output?: (onnx.IValueInfoProto[]|null);
+
+ /** GraphProto valueInfo */
+ valueInfo?: (onnx.IValueInfoProto[]|null);
+
+ /** GraphProto quantizationAnnotation */
+ quantizationAnnotation?: (onnx.ITensorAnnotation[]|null);
+ }
+
+ /** Represents a GraphProto. */
+ class GraphProto implements IGraphProto {
+ /**
+ * Constructs a new GraphProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.IGraphProto);
+
+ /** GraphProto node. */
+ public node: onnx.INodeProto[];
+
+ /** GraphProto name. */
+ public name: string;
+
+ /** GraphProto initializer. */
+ public initializer: onnx.ITensorProto[];
+
+ /** GraphProto sparseInitializer. */
+ public sparseInitializer: onnx.ISparseTensorProto[];
+
+ /** GraphProto docString. */
+ public docString: string;
+
+ /** GraphProto input. */
+ public input: onnx.IValueInfoProto[];
+
+ /** GraphProto output. */
+ public output: onnx.IValueInfoProto[];
+
+ /** GraphProto valueInfo. */
+ public valueInfo: onnx.IValueInfoProto[];
+
+ /** GraphProto quantizationAnnotation. */
+ public quantizationAnnotation: onnx.ITensorAnnotation[];
+
+ /**
+ * Creates a new GraphProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns GraphProto instance
+ */
+ public static create(properties?: onnx.IGraphProto): onnx.GraphProto;
+
+ /**
+ * Encodes the specified GraphProto message. Does not implicitly {@link onnx.GraphProto.verify|verify} messages.
+ * @param message GraphProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.IGraphProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified GraphProto message, length delimited. Does not implicitly {@link
+ * onnx.GraphProto.verify|verify} messages.
+ * @param message GraphProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.IGraphProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a GraphProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns GraphProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.GraphProto;
+
+ /**
+ * Decodes a GraphProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns GraphProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.GraphProto;
+
+ /**
+ * Verifies a GraphProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a GraphProto message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns GraphProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.GraphProto;
+
+ /**
+ * Creates a plain object from a GraphProto message. Also converts values to other types if specified.
+ * @param message GraphProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.GraphProto, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this GraphProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for GraphProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** Properties of a TensorProto. */
+ interface ITensorProto {
+ /** TensorProto dims */
+ dims?: ((number | Long)[]|null);
+
+ /** TensorProto dataType */
+ dataType?: (number|null);
+
+ /** TensorProto segment */
+ segment?: (onnx.TensorProto.ISegment|null);
+
+ /** TensorProto floatData */
+ floatData?: (number[]|null);
+
+ /** TensorProto int32Data */
+ int32Data?: (number[]|null);
+
+ /** TensorProto stringData */
+ stringData?: (Uint8Array[]|null);
+
+ /** TensorProto int64Data */
+ int64Data?: ((number | Long)[]|null);
+
+ /** TensorProto name */
+ name?: (string|null);
+
+ /** TensorProto docString */
+ docString?: (string|null);
+
+ /** TensorProto rawData */
+ rawData?: (Uint8Array|null);
+
+ /** TensorProto externalData */
+ externalData?: (onnx.IStringStringEntryProto[]|null);
+
+ /** TensorProto dataLocation */
+ dataLocation?: (onnx.TensorProto.DataLocation|null);
+
+ /** TensorProto doubleData */
+ doubleData?: (number[]|null);
+
+ /** TensorProto uint64Data */
+ uint64Data?: ((number | Long)[]|null);
+ }
+
+ /** Represents a TensorProto. */
+ class TensorProto implements ITensorProto {
+ /**
+ * Constructs a new TensorProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.ITensorProto);
+
+ /** TensorProto dims. */
+ public dims: (number|Long)[];
+
+ /** TensorProto dataType. */
+ public dataType: number;
+
+ /** TensorProto segment. */
+ public segment?: (onnx.TensorProto.ISegment|null);
+
+ /** TensorProto floatData. */
+ public floatData: number[];
+
+ /** TensorProto int32Data. */
+ public int32Data: number[];
+
+ /** TensorProto stringData. */
+ public stringData: Uint8Array[];
+
+ /** TensorProto int64Data. */
+ public int64Data: (number|Long)[];
+
+ /** TensorProto name. */
+ public name: string;
+
+ /** TensorProto docString. */
+ public docString: string;
+
+ /** TensorProto rawData. */
+ public rawData: Uint8Array;
+
+ /** TensorProto externalData. */
+ public externalData: onnx.IStringStringEntryProto[];
+
+ /** TensorProto dataLocation. */
+ public dataLocation: onnx.TensorProto.DataLocation;
+
+ /** TensorProto doubleData. */
+ public doubleData: number[];
+
+ /** TensorProto uint64Data. */
+ public uint64Data: (number|Long)[];
+
+ /**
+ * Creates a new TensorProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns TensorProto instance
+ */
+ public static create(properties?: onnx.ITensorProto): onnx.TensorProto;
+
+ /**
+ * Encodes the specified TensorProto message. Does not implicitly {@link onnx.TensorProto.verify|verify} messages.
+ * @param message TensorProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.ITensorProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified TensorProto message, length delimited. Does not implicitly {@link
+ * onnx.TensorProto.verify|verify} messages.
+ * @param message TensorProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.ITensorProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a TensorProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns TensorProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.TensorProto;
+
+ /**
+ * Decodes a TensorProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns TensorProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.TensorProto;
+
+ /**
+ * Verifies a TensorProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a TensorProto message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns TensorProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.TensorProto;
+
+ /**
+ * Creates a plain object from a TensorProto message. Also converts values to other types if specified.
+ * @param message TensorProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.TensorProto, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this TensorProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for TensorProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ namespace TensorProto {
+
+ /** DataType enum. */
+ enum DataType {
+ UNDEFINED = 0,
+ FLOAT = 1,
+ UINT8 = 2,
+ INT8 = 3,
+ UINT16 = 4,
+ INT16 = 5,
+ INT32 = 6,
+ INT64 = 7,
+ STRING = 8,
+ BOOL = 9,
+ FLOAT16 = 10,
+ DOUBLE = 11,
+ UINT32 = 12,
+ UINT64 = 13,
+ COMPLEX64 = 14,
+ COMPLEX128 = 15,
+ BFLOAT16 = 16,
+ FLOAT8E4M3FN = 17,
+ FLOAT8E4M3FNUZ = 18,
+ FLOAT8E5M2 = 19,
+ FLOAT8E5M2FNUZ = 20
+ }
+
+ /** Properties of a Segment. */
+ interface ISegment {
+ /** Segment begin */
+ begin?: (number|Long|null);
+
+ /** Segment end */
+ end?: (number|Long|null);
+ }
+
+ /** Represents a Segment. */
+ class Segment implements ISegment {
+ /**
+ * Constructs a new Segment.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.TensorProto.ISegment);
+
+ /** Segment begin. */
+ public begin: (number|Long);
+
+ /** Segment end. */
+ public end: (number|Long);
+
+ /**
+ * Creates a new Segment instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns Segment instance
+ */
+ public static create(properties?: onnx.TensorProto.ISegment): onnx.TensorProto.Segment;
+
+ /**
+ * Encodes the specified Segment message. Does not implicitly {@link onnx.TensorProto.Segment.verify|verify}
+ * messages.
+ * @param message Segment message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.TensorProto.ISegment, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified Segment message, length delimited. Does not implicitly {@link
+ * onnx.TensorProto.Segment.verify|verify} messages.
+ * @param message Segment message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.TensorProto.ISegment, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a Segment message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns Segment
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.TensorProto.Segment;
+
+ /**
+ * Decodes a Segment message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns Segment
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.TensorProto.Segment;
+
+ /**
+ * Verifies a Segment message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a Segment message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns Segment
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.TensorProto.Segment;
+
+ /**
+ * Creates a plain object from a Segment message. Also converts values to other types if specified.
+ * @param message Segment
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.TensorProto.Segment, options?: $protobuf.IConversionOptions):
+ {[k: string]: any};
+
+ /**
+ * Converts this Segment to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for Segment
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** DataLocation enum. */
+ enum DataLocation { DEFAULT = 0, EXTERNAL = 1 }
+ }
+
+ /** Properties of a SparseTensorProto. */
+ interface ISparseTensorProto {
+ /** SparseTensorProto values */
+ values?: (onnx.ITensorProto|null);
+
+ /** SparseTensorProto indices */
+ indices?: (onnx.ITensorProto|null);
+
+ /** SparseTensorProto dims */
+ dims?: ((number | Long)[]|null);
+ }
+
+ /** Represents a SparseTensorProto. */
+ class SparseTensorProto implements ISparseTensorProto {
+ /**
+ * Constructs a new SparseTensorProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.ISparseTensorProto);
+
+ /** SparseTensorProto values. */
+ public values?: (onnx.ITensorProto|null);
+
+ /** SparseTensorProto indices. */
+ public indices?: (onnx.ITensorProto|null);
+
+ /** SparseTensorProto dims. */
+ public dims: (number|Long)[];
+
+ /**
+ * Creates a new SparseTensorProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns SparseTensorProto instance
+ */
+ public static create(properties?: onnx.ISparseTensorProto): onnx.SparseTensorProto;
+
+ /**
+ * Encodes the specified SparseTensorProto message. Does not implicitly {@link onnx.SparseTensorProto.verify|verify}
+ * messages.
+ * @param message SparseTensorProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.ISparseTensorProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified SparseTensorProto message, length delimited. Does not implicitly {@link
+ * onnx.SparseTensorProto.verify|verify} messages.
+ * @param message SparseTensorProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.ISparseTensorProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a SparseTensorProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns SparseTensorProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.SparseTensorProto;
+
+ /**
+ * Decodes a SparseTensorProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns SparseTensorProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.SparseTensorProto;
+
+ /**
+ * Verifies a SparseTensorProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a SparseTensorProto message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns SparseTensorProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.SparseTensorProto;
+
+ /**
+ * Creates a plain object from a SparseTensorProto message. Also converts values to other types if specified.
+ * @param message SparseTensorProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.SparseTensorProto, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this SparseTensorProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for SparseTensorProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** Properties of a TensorShapeProto. */
+ interface ITensorShapeProto {
+ /** TensorShapeProto dim */
+ dim?: (onnx.TensorShapeProto.IDimension[]|null);
+ }
+
+ /** Represents a TensorShapeProto. */
+ class TensorShapeProto implements ITensorShapeProto {
+ /**
+ * Constructs a new TensorShapeProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.ITensorShapeProto);
+
+ /** TensorShapeProto dim. */
+ public dim: onnx.TensorShapeProto.IDimension[];
+
+ /**
+ * Creates a new TensorShapeProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns TensorShapeProto instance
+ */
+ public static create(properties?: onnx.ITensorShapeProto): onnx.TensorShapeProto;
+
+ /**
+ * Encodes the specified TensorShapeProto message. Does not implicitly {@link onnx.TensorShapeProto.verify|verify}
+ * messages.
+ * @param message TensorShapeProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.ITensorShapeProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified TensorShapeProto message, length delimited. Does not implicitly {@link
+ * onnx.TensorShapeProto.verify|verify} messages.
+ * @param message TensorShapeProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.ITensorShapeProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a TensorShapeProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns TensorShapeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.TensorShapeProto;
+
+ /**
+ * Decodes a TensorShapeProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns TensorShapeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.TensorShapeProto;
+
+ /**
+ * Verifies a TensorShapeProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a TensorShapeProto message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns TensorShapeProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.TensorShapeProto;
+
+ /**
+ * Creates a plain object from a TensorShapeProto message. Also converts values to other types if specified.
+ * @param message TensorShapeProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.TensorShapeProto, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this TensorShapeProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for TensorShapeProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ namespace TensorShapeProto {
+
+ /** Properties of a Dimension. */
+ interface IDimension {
+ /** Dimension dimValue */
+ dimValue?: (number|Long|null);
+
+ /** Dimension dimParam */
+ dimParam?: (string|null);
+
+ /** Dimension denotation */
+ denotation?: (string|null);
+ }
+
+ /** Represents a Dimension. */
+ class Dimension implements IDimension {
+ /**
+ * Constructs a new Dimension.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.TensorShapeProto.IDimension);
+
+ /** Dimension dimValue. */
+ public dimValue?: (number|Long|null);
+
+ /** Dimension dimParam. */
+ public dimParam?: (string|null);
+
+ /** Dimension denotation. */
+ public denotation: string;
+
+ /** Dimension value. */
+ public value?: ('dimValue'|'dimParam');
+
+ /**
+ * Creates a new Dimension instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns Dimension instance
+ */
+ public static create(properties?: onnx.TensorShapeProto.IDimension): onnx.TensorShapeProto.Dimension;
+
+ /**
+ * Encodes the specified Dimension message. Does not implicitly {@link
+ * onnx.TensorShapeProto.Dimension.verify|verify} messages.
+ * @param message Dimension message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.TensorShapeProto.IDimension, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified Dimension message, length delimited. Does not implicitly {@link
+ * onnx.TensorShapeProto.Dimension.verify|verify} messages.
+ * @param message Dimension message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.TensorShapeProto.IDimension, writer?: $protobuf.Writer):
+ $protobuf.Writer;
+
+ /**
+ * Decodes a Dimension message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns Dimension
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.TensorShapeProto.Dimension;
+
+ /**
+ * Decodes a Dimension message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns Dimension
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.TensorShapeProto.Dimension;
+
+ /**
+ * Verifies a Dimension message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a Dimension message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns Dimension
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.TensorShapeProto.Dimension;
+
+ /**
+ * Creates a plain object from a Dimension message. Also converts values to other types if specified.
+ * @param message Dimension
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.TensorShapeProto.Dimension, options?: $protobuf.IConversionOptions):
+ {[k: string]: any};
+
+ /**
+ * Converts this Dimension to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for Dimension
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+ }
+
+ /** Properties of a TypeProto. */
+ interface ITypeProto {
+ /** TypeProto tensorType */
+ tensorType?: (onnx.TypeProto.ITensor|null);
+
+ /** TypeProto sequenceType */
+ sequenceType?: (onnx.TypeProto.ISequence|null);
+
+ /** TypeProto mapType */
+ mapType?: (onnx.TypeProto.IMap|null);
+
+ /** TypeProto optionalType */
+ optionalType?: (onnx.TypeProto.IOptional|null);
+
+ /** TypeProto sparseTensorType */
+ sparseTensorType?: (onnx.TypeProto.ISparseTensor|null);
+
+ /** TypeProto denotation */
+ denotation?: (string|null);
+ }
+
+ /** Represents a TypeProto. */
+ class TypeProto implements ITypeProto {
+ /**
+ * Constructs a new TypeProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.ITypeProto);
+
+ /** TypeProto tensorType. */
+ public tensorType?: (onnx.TypeProto.ITensor|null);
+
+ /** TypeProto sequenceType. */
+ public sequenceType?: (onnx.TypeProto.ISequence|null);
+
+ /** TypeProto mapType. */
+ public mapType?: (onnx.TypeProto.IMap|null);
+
+ /** TypeProto optionalType. */
+ public optionalType?: (onnx.TypeProto.IOptional|null);
+
+ /** TypeProto sparseTensorType. */
+ public sparseTensorType?: (onnx.TypeProto.ISparseTensor|null);
+
+ /** TypeProto denotation. */
+ public denotation: string;
+
+ /** TypeProto value. */
+ public value?: ('tensorType'|'sequenceType'|'mapType'|'optionalType'|'sparseTensorType');
+
+ /**
+ * Creates a new TypeProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns TypeProto instance
+ */
+ public static create(properties?: onnx.ITypeProto): onnx.TypeProto;
+
+ /**
+ * Encodes the specified TypeProto message. Does not implicitly {@link onnx.TypeProto.verify|verify} messages.
+ * @param message TypeProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.ITypeProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified TypeProto message, length delimited. Does not implicitly {@link
+ * onnx.TypeProto.verify|verify} messages.
+ * @param message TypeProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.ITypeProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a TypeProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns TypeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.TypeProto;
+
+ /**
+ * Decodes a TypeProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns TypeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.TypeProto;
+
+ /**
+ * Verifies a TypeProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a TypeProto message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns TypeProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.TypeProto;
+
+ /**
+ * Creates a plain object from a TypeProto message. Also converts values to other types if specified.
+ * @param message TypeProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.TypeProto, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this TypeProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for TypeProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ namespace TypeProto {
+
+ /** Properties of a Tensor. */
+ interface ITensor {
+ /** Tensor elemType */
+ elemType?: (number|null);
+
+ /** Tensor shape */
+ shape?: (onnx.ITensorShapeProto|null);
+ }
+
+ /** Represents a Tensor. */
+ class Tensor implements ITensor {
+ /**
+ * Constructs a new Tensor.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.TypeProto.ITensor);
+
+ /** Tensor elemType. */
+ public elemType: number;
+
+ /** Tensor shape. */
+ public shape?: (onnx.ITensorShapeProto|null);
+
+ /**
+ * Creates a new Tensor instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns Tensor instance
+ */
+ public static create(properties?: onnx.TypeProto.ITensor): onnx.TypeProto.Tensor;
+
+ /**
+ * Encodes the specified Tensor message. Does not implicitly {@link onnx.TypeProto.Tensor.verify|verify} messages.
+ * @param message Tensor message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.TypeProto.ITensor, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified Tensor message, length delimited. Does not implicitly {@link
+ * onnx.TypeProto.Tensor.verify|verify} messages.
+ * @param message Tensor message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.TypeProto.ITensor, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a Tensor message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns Tensor
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.TypeProto.Tensor;
+
+ /**
+ * Decodes a Tensor message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns Tensor
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.TypeProto.Tensor;
+
+ /**
+ * Verifies a Tensor message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a Tensor message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns Tensor
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.TypeProto.Tensor;
+
+ /**
+ * Creates a plain object from a Tensor message. Also converts values to other types if specified.
+ * @param message Tensor
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.TypeProto.Tensor, options?: $protobuf.IConversionOptions):
+ {[k: string]: any};
+
+ /**
+ * Converts this Tensor to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for Tensor
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** Properties of a Sequence. */
+ interface ISequence {
+ /** Sequence elemType */
+ elemType?: (onnx.ITypeProto|null);
+ }
+
+ /** Represents a Sequence. */
+ class Sequence implements ISequence {
+ /**
+ * Constructs a new Sequence.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.TypeProto.ISequence);
+
+ /** Sequence elemType. */
+ public elemType?: (onnx.ITypeProto|null);
+
+ /**
+ * Creates a new Sequence instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns Sequence instance
+ */
+ public static create(properties?: onnx.TypeProto.ISequence): onnx.TypeProto.Sequence;
+
+ /**
+ * Encodes the specified Sequence message. Does not implicitly {@link onnx.TypeProto.Sequence.verify|verify}
+ * messages.
+ * @param message Sequence message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.TypeProto.ISequence, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified Sequence message, length delimited. Does not implicitly {@link
+ * onnx.TypeProto.Sequence.verify|verify} messages.
+ * @param message Sequence message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.TypeProto.ISequence, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a Sequence message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns Sequence
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.TypeProto.Sequence;
+
+ /**
+ * Decodes a Sequence message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns Sequence
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.TypeProto.Sequence;
+
+ /**
+ * Verifies a Sequence message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a Sequence message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns Sequence
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.TypeProto.Sequence;
+
+ /**
+ * Creates a plain object from a Sequence message. Also converts values to other types if specified.
+ * @param message Sequence
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.TypeProto.Sequence, options?: $protobuf.IConversionOptions):
+ {[k: string]: any};
+
+ /**
+ * Converts this Sequence to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for Sequence
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** Properties of a Map. */
+ interface IMap {
+ /** Map keyType */
+ keyType?: (number|null);
+
+ /** Map valueType */
+ valueType?: (onnx.ITypeProto|null);
+ }
+
+ /** Represents a Map. */
+ class Map implements IMap {
+ /**
+ * Constructs a new Map.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.TypeProto.IMap);
+
+ /** Map keyType. */
+ public keyType: number;
+
+ /** Map valueType. */
+ public valueType?: (onnx.ITypeProto|null);
+
+ /**
+ * Creates a new Map instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns Map instance
+ */
+ public static create(properties?: onnx.TypeProto.IMap): onnx.TypeProto.Map;
+
+ /**
+ * Encodes the specified Map message. Does not implicitly {@link onnx.TypeProto.Map.verify|verify} messages.
+ * @param message Map message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.TypeProto.IMap, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified Map message, length delimited. Does not implicitly {@link
+ * onnx.TypeProto.Map.verify|verify} messages.
+ * @param message Map message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.TypeProto.IMap, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a Map message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns Map
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.TypeProto.Map;
+
+ /**
+ * Decodes a Map message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns Map
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.TypeProto.Map;
+
+ /**
+ * Verifies a Map message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a Map message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns Map
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.TypeProto.Map;
+
+ /**
+ * Creates a plain object from a Map message. Also converts values to other types if specified.
+ * @param message Map
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.TypeProto.Map, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this Map to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for Map
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** Properties of an Optional. */
+ interface IOptional {
+ /** Optional elemType */
+ elemType?: (onnx.ITypeProto|null);
+ }
+
+ /** Represents an Optional. */
+ class Optional implements IOptional {
+ /**
+ * Constructs a new Optional.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.TypeProto.IOptional);
+
+ /** Optional elemType. */
+ public elemType?: (onnx.ITypeProto|null);
+
+ /**
+ * Creates a new Optional instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns Optional instance
+ */
+ public static create(properties?: onnx.TypeProto.IOptional): onnx.TypeProto.Optional;
+
+ /**
+ * Encodes the specified Optional message. Does not implicitly {@link onnx.TypeProto.Optional.verify|verify}
+ * messages.
+ * @param message Optional message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.TypeProto.IOptional, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified Optional message, length delimited. Does not implicitly {@link
+ * onnx.TypeProto.Optional.verify|verify} messages.
+ * @param message Optional message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.TypeProto.IOptional, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes an Optional message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns Optional
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.TypeProto.Optional;
+
+ /**
+ * Decodes an Optional message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns Optional
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.TypeProto.Optional;
+
+ /**
+ * Verifies an Optional message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates an Optional message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns Optional
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.TypeProto.Optional;
+
+ /**
+ * Creates a plain object from an Optional message. Also converts values to other types if specified.
+ * @param message Optional
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.TypeProto.Optional, options?: $protobuf.IConversionOptions):
+ {[k: string]: any};
+
+ /**
+ * Converts this Optional to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for Optional
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** Properties of a SparseTensor. */
+ interface ISparseTensor {
+ /** SparseTensor elemType */
+ elemType?: (number|null);
+
+ /** SparseTensor shape */
+ shape?: (onnx.ITensorShapeProto|null);
+ }
+
+ /** Represents a SparseTensor. */
+ class SparseTensor implements ISparseTensor {
+ /**
+ * Constructs a new SparseTensor.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.TypeProto.ISparseTensor);
+
+ /** SparseTensor elemType. */
+ public elemType: number;
+
+ /** SparseTensor shape. */
+ public shape?: (onnx.ITensorShapeProto|null);
+
+ /**
+ * Creates a new SparseTensor instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns SparseTensor instance
+ */
+ public static create(properties?: onnx.TypeProto.ISparseTensor): onnx.TypeProto.SparseTensor;
+
+ /**
+ * Encodes the specified SparseTensor message. Does not implicitly {@link
+ * onnx.TypeProto.SparseTensor.verify|verify} messages.
+ * @param message SparseTensor message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.TypeProto.ISparseTensor, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified SparseTensor message, length delimited. Does not implicitly {@link
+ * onnx.TypeProto.SparseTensor.verify|verify} messages.
+ * @param message SparseTensor message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.TypeProto.ISparseTensor, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a SparseTensor message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns SparseTensor
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.TypeProto.SparseTensor;
+
+ /**
+ * Decodes a SparseTensor message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns SparseTensor
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.TypeProto.SparseTensor;
+
+ /**
+ * Verifies a SparseTensor message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a SparseTensor message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns SparseTensor
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.TypeProto.SparseTensor;
+
+ /**
+ * Creates a plain object from a SparseTensor message. Also converts values to other types if specified.
+ * @param message SparseTensor
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.TypeProto.SparseTensor, options?: $protobuf.IConversionOptions):
+ {[k: string]: any};
+
+ /**
+ * Converts this SparseTensor to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for SparseTensor
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+ }
+
+ /** Properties of an OperatorSetIdProto. */
+ interface IOperatorSetIdProto {
+ /** OperatorSetIdProto domain */
+ domain?: (string|null);
+
+ /** OperatorSetIdProto version */
+ version?: (number|Long|null);
+ }
+
+ /** Represents an OperatorSetIdProto. */
+ class OperatorSetIdProto implements IOperatorSetIdProto {
+ /**
+ * Constructs a new OperatorSetIdProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.IOperatorSetIdProto);
+
+ /** OperatorSetIdProto domain. */
+ public domain: string;
+
+ /** OperatorSetIdProto version. */
+ public version: (number|Long);
+
+ /**
+ * Creates a new OperatorSetIdProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns OperatorSetIdProto instance
+ */
+ public static create(properties?: onnx.IOperatorSetIdProto): onnx.OperatorSetIdProto;
+
+ /**
+ * Encodes the specified OperatorSetIdProto message. Does not implicitly {@link
+ * onnx.OperatorSetIdProto.verify|verify} messages.
+ * @param message OperatorSetIdProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.IOperatorSetIdProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified OperatorSetIdProto message, length delimited. Does not implicitly {@link
+ * onnx.OperatorSetIdProto.verify|verify} messages.
+ * @param message OperatorSetIdProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.IOperatorSetIdProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes an OperatorSetIdProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns OperatorSetIdProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.OperatorSetIdProto;
+
+ /**
+ * Decodes an OperatorSetIdProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns OperatorSetIdProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.OperatorSetIdProto;
+
+ /**
+ * Verifies an OperatorSetIdProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates an OperatorSetIdProto message from a plain object. Also converts values to their respective internal
+ * types.
+ * @param object Plain object
+ * @returns OperatorSetIdProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.OperatorSetIdProto;
+
+ /**
+ * Creates a plain object from an OperatorSetIdProto message. Also converts values to other types if specified.
+ * @param message OperatorSetIdProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.OperatorSetIdProto, options?: $protobuf.IConversionOptions):
+ {[k: string]: any};
+
+ /**
+ * Converts this OperatorSetIdProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for OperatorSetIdProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+
+ /** OperatorStatus enum. */
+ enum OperatorStatus { EXPERIMENTAL = 0, STABLE = 1 }
+
+ /** Properties of a FunctionProto. */
+ interface IFunctionProto {
+ /** FunctionProto name */
+ name?: (string|null);
+
+ /** FunctionProto input */
+ input?: (string[]|null);
+
+ /** FunctionProto output */
+ output?: (string[]|null);
+
+ /** FunctionProto attribute */
+ attribute?: (string[]|null);
+
+ /** FunctionProto attributeProto */
+ attributeProto?: (onnx.IAttributeProto[]|null);
+
+ /** FunctionProto node */
+ node?: (onnx.INodeProto[]|null);
+
+ /** FunctionProto docString */
+ docString?: (string|null);
+
+ /** FunctionProto opsetImport */
+ opsetImport?: (onnx.IOperatorSetIdProto[]|null);
+
+ /** FunctionProto domain */
+ domain?: (string|null);
+ }
+
+ /** Represents a FunctionProto. */
+ class FunctionProto implements IFunctionProto {
+ /**
+ * Constructs a new FunctionProto.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: onnx.IFunctionProto);
+
+ /** FunctionProto name. */
+ public name: string;
+
+ /** FunctionProto input. */
+ public input: string[];
+
+ /** FunctionProto output. */
+ public output: string[];
+
+ /** FunctionProto attribute. */
+ public attribute: string[];
+
+ /** FunctionProto attributeProto. */
+ public attributeProto: onnx.IAttributeProto[];
+
+ /** FunctionProto node. */
+ public node: onnx.INodeProto[];
+
+ /** FunctionProto docString. */
+ public docString: string;
+
+ /** FunctionProto opsetImport. */
+ public opsetImport: onnx.IOperatorSetIdProto[];
+
+ /** FunctionProto domain. */
+ public domain: string;
+
+ /**
+ * Creates a new FunctionProto instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns FunctionProto instance
+ */
+ public static create(properties?: onnx.IFunctionProto): onnx.FunctionProto;
+
+ /**
+ * Encodes the specified FunctionProto message. Does not implicitly {@link onnx.FunctionProto.verify|verify}
+ * messages.
+ * @param message FunctionProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: onnx.IFunctionProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified FunctionProto message, length delimited. Does not implicitly {@link
+ * onnx.FunctionProto.verify|verify} messages.
+ * @param message FunctionProto message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: onnx.IFunctionProto, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a FunctionProto message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns FunctionProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): onnx.FunctionProto;
+
+ /**
+ * Decodes a FunctionProto message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns FunctionProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): onnx.FunctionProto;
+
+ /**
+ * Verifies a FunctionProto message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: {[k: string]: any}): (string|null);
+
+ /**
+ * Creates a FunctionProto message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns FunctionProto
+ */
+ public static fromObject(object: {[k: string]: any}): onnx.FunctionProto;
+
+ /**
+ * Creates a plain object from a FunctionProto message. Also converts values to other types if specified.
+ * @param message FunctionProto
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: onnx.FunctionProto, options?: $protobuf.IConversionOptions): {[k: string]: any};
+
+ /**
+ * Converts this FunctionProto to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): {[k: string]: any};
+
+ /**
+ * Gets the default type url for FunctionProto
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+}
diff --git a/js/node/test/ort-schema/protobuf/onnx.js b/js/node/test/ort-schema/protobuf/onnx.js
new file mode 100644
index 0000000000000..681855132d4e8
--- /dev/null
+++ b/js/node/test/ort-schema/protobuf/onnx.js
@@ -0,0 +1,7658 @@
+/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
+"use strict";
+
+var $protobuf = require("protobufjs/minimal");
+
+// Common aliases
+var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
+
+// Exported root namespace
+var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
+
+$root.onnx = (function() {
+
+ /**
+ * Namespace onnx.
+ * @exports onnx
+ * @namespace
+ */
+ var onnx = {};
+
+ /**
+ * Version enum.
+ * @name onnx.Version
+ * @enum {number}
+ * @property {number} _START_VERSION=0 _START_VERSION value
+ * @property {number} IR_VERSION_2017_10_10=1 IR_VERSION_2017_10_10 value
+ * @property {number} IR_VERSION_2017_10_30=2 IR_VERSION_2017_10_30 value
+ * @property {number} IR_VERSION_2017_11_3=3 IR_VERSION_2017_11_3 value
+ * @property {number} IR_VERSION_2019_1_22=4 IR_VERSION_2019_1_22 value
+ * @property {number} IR_VERSION_2019_3_18=5 IR_VERSION_2019_3_18 value
+ * @property {number} IR_VERSION_2019_9_19=6 IR_VERSION_2019_9_19 value
+ * @property {number} IR_VERSION_2020_5_8=7 IR_VERSION_2020_5_8 value
+ * @property {number} IR_VERSION_2021_7_30=8 IR_VERSION_2021_7_30 value
+ * @property {number} IR_VERSION=9 IR_VERSION value
+ */
+ onnx.Version = (function() {
+ var valuesById = {}, values = Object.create(valuesById);
+ values[valuesById[0] = "_START_VERSION"] = 0;
+ values[valuesById[1] = "IR_VERSION_2017_10_10"] = 1;
+ values[valuesById[2] = "IR_VERSION_2017_10_30"] = 2;
+ values[valuesById[3] = "IR_VERSION_2017_11_3"] = 3;
+ values[valuesById[4] = "IR_VERSION_2019_1_22"] = 4;
+ values[valuesById[5] = "IR_VERSION_2019_3_18"] = 5;
+ values[valuesById[6] = "IR_VERSION_2019_9_19"] = 6;
+ values[valuesById[7] = "IR_VERSION_2020_5_8"] = 7;
+ values[valuesById[8] = "IR_VERSION_2021_7_30"] = 8;
+ values[valuesById[9] = "IR_VERSION"] = 9;
+ return values;
+ })();
+
+ onnx.AttributeProto = (function() {
+
+ /**
+ * Properties of an AttributeProto.
+ * @memberof onnx
+ * @interface IAttributeProto
+ * @property {string|null} [name] AttributeProto name
+ * @property {string|null} [refAttrName] AttributeProto refAttrName
+ * @property {string|null} [docString] AttributeProto docString
+ * @property {onnx.AttributeProto.AttributeType|null} [type] AttributeProto type
+ * @property {number|null} [f] AttributeProto f
+ * @property {number|Long|null} [i] AttributeProto i
+ * @property {Uint8Array|null} [s] AttributeProto s
+ * @property {onnx.ITensorProto|null} [t] AttributeProto t
+ * @property {onnx.IGraphProto|null} [g] AttributeProto g
+ * @property {onnx.ISparseTensorProto|null} [sparseTensor] AttributeProto sparseTensor
+ * @property {onnx.ITypeProto|null} [tp] AttributeProto tp
+ * @property {Array.|null} [floats] AttributeProto floats
+ * @property {Array.|null} [ints] AttributeProto ints
+ * @property {Array.|null} [strings] AttributeProto strings
+ * @property {Array.|null} [tensors] AttributeProto tensors
+ * @property {Array.|null} [graphs] AttributeProto graphs
+ * @property {Array.|null} [sparseTensors] AttributeProto sparseTensors
+ * @property {Array.|null} [typeProtos] AttributeProto typeProtos
+ */
+
+ /**
+ * Constructs a new AttributeProto.
+ * @memberof onnx
+ * @classdesc Represents an AttributeProto.
+ * @implements IAttributeProto
+ * @constructor
+ * @param {onnx.IAttributeProto=} [properties] Properties to set
+ */
+ function AttributeProto(properties) {
+ this.floats = [];
+ this.ints = [];
+ this.strings = [];
+ this.tensors = [];
+ this.graphs = [];
+ this.sparseTensors = [];
+ this.typeProtos = [];
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * AttributeProto name.
+ * @member {string} name
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.name = "";
+
+ /**
+ * AttributeProto refAttrName.
+ * @member {string} refAttrName
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.refAttrName = "";
+
+ /**
+ * AttributeProto docString.
+ * @member {string} docString
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.docString = "";
+
+ /**
+ * AttributeProto type.
+ * @member {onnx.AttributeProto.AttributeType} type
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.type = 0;
+
+ /**
+ * AttributeProto f.
+ * @member {number} f
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.f = 0;
+
+ /**
+ * AttributeProto i.
+ * @member {number|Long} i
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.i = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
+
+ /**
+ * AttributeProto s.
+ * @member {Uint8Array} s
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.s = $util.newBuffer([]);
+
+ /**
+ * AttributeProto t.
+ * @member {onnx.ITensorProto|null|undefined} t
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.t = null;
+
+ /**
+ * AttributeProto g.
+ * @member {onnx.IGraphProto|null|undefined} g
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.g = null;
+
+ /**
+ * AttributeProto sparseTensor.
+ * @member {onnx.ISparseTensorProto|null|undefined} sparseTensor
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.sparseTensor = null;
+
+ /**
+ * AttributeProto tp.
+ * @member {onnx.ITypeProto|null|undefined} tp
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.tp = null;
+
+ /**
+ * AttributeProto floats.
+ * @member {Array.} floats
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.floats = $util.emptyArray;
+
+ /**
+ * AttributeProto ints.
+ * @member {Array.} ints
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.ints = $util.emptyArray;
+
+ /**
+ * AttributeProto strings.
+ * @member {Array.} strings
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.strings = $util.emptyArray;
+
+ /**
+ * AttributeProto tensors.
+ * @member {Array.} tensors
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.tensors = $util.emptyArray;
+
+ /**
+ * AttributeProto graphs.
+ * @member {Array.} graphs
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.graphs = $util.emptyArray;
+
+ /**
+ * AttributeProto sparseTensors.
+ * @member {Array.} sparseTensors
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.sparseTensors = $util.emptyArray;
+
+ /**
+ * AttributeProto typeProtos.
+ * @member {Array.} typeProtos
+ * @memberof onnx.AttributeProto
+ * @instance
+ */
+ AttributeProto.prototype.typeProtos = $util.emptyArray;
+
+ /**
+ * Creates a new AttributeProto instance using the specified properties.
+ * @function create
+ * @memberof onnx.AttributeProto
+ * @static
+ * @param {onnx.IAttributeProto=} [properties] Properties to set
+ * @returns {onnx.AttributeProto} AttributeProto instance
+ */
+ AttributeProto.create = function create(properties) {
+ return new AttributeProto(properties);
+ };
+
+ /**
+ * Encodes the specified AttributeProto message. Does not implicitly {@link onnx.AttributeProto.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.AttributeProto
+ * @static
+ * @param {onnx.IAttributeProto} message AttributeProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ AttributeProto.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.name != null && Object.hasOwnProperty.call(message, "name"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.name);
+ if (message.f != null && Object.hasOwnProperty.call(message, "f"))
+ writer.uint32(/* id 2, wireType 5 =*/21).float(message.f);
+ if (message.i != null && Object.hasOwnProperty.call(message, "i"))
+ writer.uint32(/* id 3, wireType 0 =*/24).int64(message.i);
+ if (message.s != null && Object.hasOwnProperty.call(message, "s"))
+ writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.s);
+ if (message.t != null && Object.hasOwnProperty.call(message, "t"))
+ $root.onnx.TensorProto.encode(message.t, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim();
+ if (message.g != null && Object.hasOwnProperty.call(message, "g"))
+ $root.onnx.GraphProto.encode(message.g, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim();
+ if (message.floats != null && message.floats.length) {
+ writer.uint32(/* id 7, wireType 2 =*/58).fork();
+ for (var i = 0; i < message.floats.length; ++i)
+ writer.float(message.floats[i]);
+ writer.ldelim();
+ }
+ if (message.ints != null && message.ints.length) {
+ writer.uint32(/* id 8, wireType 2 =*/66).fork();
+ for (var i = 0; i < message.ints.length; ++i)
+ writer.int64(message.ints[i]);
+ writer.ldelim();
+ }
+ if (message.strings != null && message.strings.length)
+ for (var i = 0; i < message.strings.length; ++i)
+ writer.uint32(/* id 9, wireType 2 =*/74).bytes(message.strings[i]);
+ if (message.tensors != null && message.tensors.length)
+ for (var i = 0; i < message.tensors.length; ++i)
+ $root.onnx.TensorProto.encode(message.tensors[i], writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim();
+ if (message.graphs != null && message.graphs.length)
+ for (var i = 0; i < message.graphs.length; ++i)
+ $root.onnx.GraphProto.encode(message.graphs[i], writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim();
+ if (message.docString != null && Object.hasOwnProperty.call(message, "docString"))
+ writer.uint32(/* id 13, wireType 2 =*/106).string(message.docString);
+ if (message.tp != null && Object.hasOwnProperty.call(message, "tp"))
+ $root.onnx.TypeProto.encode(message.tp, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim();
+ if (message.typeProtos != null && message.typeProtos.length)
+ for (var i = 0; i < message.typeProtos.length; ++i)
+ $root.onnx.TypeProto.encode(message.typeProtos[i], writer.uint32(/* id 15, wireType 2 =*/122).fork()).ldelim();
+ if (message.type != null && Object.hasOwnProperty.call(message, "type"))
+ writer.uint32(/* id 20, wireType 0 =*/160).int32(message.type);
+ if (message.refAttrName != null && Object.hasOwnProperty.call(message, "refAttrName"))
+ writer.uint32(/* id 21, wireType 2 =*/170).string(message.refAttrName);
+ if (message.sparseTensor != null && Object.hasOwnProperty.call(message, "sparseTensor"))
+ $root.onnx.SparseTensorProto.encode(message.sparseTensor, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim();
+ if (message.sparseTensors != null && message.sparseTensors.length)
+ for (var i = 0; i < message.sparseTensors.length; ++i)
+ $root.onnx.SparseTensorProto.encode(message.sparseTensors[i], writer.uint32(/* id 23, wireType 2 =*/186).fork()).ldelim();
+ return writer;
+ };
+
+ /**
+ * Encodes the specified AttributeProto message, length delimited. Does not implicitly {@link onnx.AttributeProto.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.AttributeProto
+ * @static
+ * @param {onnx.IAttributeProto} message AttributeProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ AttributeProto.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes an AttributeProto message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.AttributeProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.AttributeProto} AttributeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ AttributeProto.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.AttributeProto();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.name = reader.string();
+ break;
+ }
+ case 21: {
+ message.refAttrName = reader.string();
+ break;
+ }
+ case 13: {
+ message.docString = reader.string();
+ break;
+ }
+ case 20: {
+ message.type = reader.int32();
+ break;
+ }
+ case 2: {
+ message.f = reader.float();
+ break;
+ }
+ case 3: {
+ message.i = reader.int64();
+ break;
+ }
+ case 4: {
+ message.s = reader.bytes();
+ break;
+ }
+ case 5: {
+ message.t = $root.onnx.TensorProto.decode(reader, reader.uint32());
+ break;
+ }
+ case 6: {
+ message.g = $root.onnx.GraphProto.decode(reader, reader.uint32());
+ break;
+ }
+ case 22: {
+ message.sparseTensor = $root.onnx.SparseTensorProto.decode(reader, reader.uint32());
+ break;
+ }
+ case 14: {
+ message.tp = $root.onnx.TypeProto.decode(reader, reader.uint32());
+ break;
+ }
+ case 7: {
+ if (!(message.floats && message.floats.length))
+ message.floats = [];
+ if ((tag & 7) === 2) {
+ var end2 = reader.uint32() + reader.pos;
+ while (reader.pos < end2)
+ message.floats.push(reader.float());
+ } else
+ message.floats.push(reader.float());
+ break;
+ }
+ case 8: {
+ if (!(message.ints && message.ints.length))
+ message.ints = [];
+ if ((tag & 7) === 2) {
+ var end2 = reader.uint32() + reader.pos;
+ while (reader.pos < end2)
+ message.ints.push(reader.int64());
+ } else
+ message.ints.push(reader.int64());
+ break;
+ }
+ case 9: {
+ if (!(message.strings && message.strings.length))
+ message.strings = [];
+ message.strings.push(reader.bytes());
+ break;
+ }
+ case 10: {
+ if (!(message.tensors && message.tensors.length))
+ message.tensors = [];
+ message.tensors.push($root.onnx.TensorProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 11: {
+ if (!(message.graphs && message.graphs.length))
+ message.graphs = [];
+ message.graphs.push($root.onnx.GraphProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 23: {
+ if (!(message.sparseTensors && message.sparseTensors.length))
+ message.sparseTensors = [];
+ message.sparseTensors.push($root.onnx.SparseTensorProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 15: {
+ if (!(message.typeProtos && message.typeProtos.length))
+ message.typeProtos = [];
+ message.typeProtos.push($root.onnx.TypeProto.decode(reader, reader.uint32()));
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes an AttributeProto message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.AttributeProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.AttributeProto} AttributeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ AttributeProto.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies an AttributeProto message.
+ * @function verify
+ * @memberof onnx.AttributeProto
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ AttributeProto.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.name != null && message.hasOwnProperty("name"))
+ if (!$util.isString(message.name))
+ return "name: string expected";
+ if (message.refAttrName != null && message.hasOwnProperty("refAttrName"))
+ if (!$util.isString(message.refAttrName))
+ return "refAttrName: string expected";
+ if (message.docString != null && message.hasOwnProperty("docString"))
+ if (!$util.isString(message.docString))
+ return "docString: string expected";
+ if (message.type != null && message.hasOwnProperty("type"))
+ switch (message.type) {
+ default:
+ return "type: enum value expected";
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 11:
+ case 13:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ case 10:
+ case 12:
+ case 14:
+ break;
+ }
+ if (message.f != null && message.hasOwnProperty("f"))
+ if (typeof message.f !== "number")
+ return "f: number expected";
+ if (message.i != null && message.hasOwnProperty("i"))
+ if (!$util.isInteger(message.i) && !(message.i && $util.isInteger(message.i.low) && $util.isInteger(message.i.high)))
+ return "i: integer|Long expected";
+ if (message.s != null && message.hasOwnProperty("s"))
+ if (!(message.s && typeof message.s.length === "number" || $util.isString(message.s)))
+ return "s: buffer expected";
+ if (message.t != null && message.hasOwnProperty("t")) {
+ var error = $root.onnx.TensorProto.verify(message.t);
+ if (error)
+ return "t." + error;
+ }
+ if (message.g != null && message.hasOwnProperty("g")) {
+ var error = $root.onnx.GraphProto.verify(message.g);
+ if (error)
+ return "g." + error;
+ }
+ if (message.sparseTensor != null && message.hasOwnProperty("sparseTensor")) {
+ var error = $root.onnx.SparseTensorProto.verify(message.sparseTensor);
+ if (error)
+ return "sparseTensor." + error;
+ }
+ if (message.tp != null && message.hasOwnProperty("tp")) {
+ var error = $root.onnx.TypeProto.verify(message.tp);
+ if (error)
+ return "tp." + error;
+ }
+ if (message.floats != null && message.hasOwnProperty("floats")) {
+ if (!Array.isArray(message.floats))
+ return "floats: array expected";
+ for (var i = 0; i < message.floats.length; ++i)
+ if (typeof message.floats[i] !== "number")
+ return "floats: number[] expected";
+ }
+ if (message.ints != null && message.hasOwnProperty("ints")) {
+ if (!Array.isArray(message.ints))
+ return "ints: array expected";
+ for (var i = 0; i < message.ints.length; ++i)
+ if (!$util.isInteger(message.ints[i]) && !(message.ints[i] && $util.isInteger(message.ints[i].low) && $util.isInteger(message.ints[i].high)))
+ return "ints: integer|Long[] expected";
+ }
+ if (message.strings != null && message.hasOwnProperty("strings")) {
+ if (!Array.isArray(message.strings))
+ return "strings: array expected";
+ for (var i = 0; i < message.strings.length; ++i)
+ if (!(message.strings[i] && typeof message.strings[i].length === "number" || $util.isString(message.strings[i])))
+ return "strings: buffer[] expected";
+ }
+ if (message.tensors != null && message.hasOwnProperty("tensors")) {
+ if (!Array.isArray(message.tensors))
+ return "tensors: array expected";
+ for (var i = 0; i < message.tensors.length; ++i) {
+ var error = $root.onnx.TensorProto.verify(message.tensors[i]);
+ if (error)
+ return "tensors." + error;
+ }
+ }
+ if (message.graphs != null && message.hasOwnProperty("graphs")) {
+ if (!Array.isArray(message.graphs))
+ return "graphs: array expected";
+ for (var i = 0; i < message.graphs.length; ++i) {
+ var error = $root.onnx.GraphProto.verify(message.graphs[i]);
+ if (error)
+ return "graphs." + error;
+ }
+ }
+ if (message.sparseTensors != null && message.hasOwnProperty("sparseTensors")) {
+ if (!Array.isArray(message.sparseTensors))
+ return "sparseTensors: array expected";
+ for (var i = 0; i < message.sparseTensors.length; ++i) {
+ var error = $root.onnx.SparseTensorProto.verify(message.sparseTensors[i]);
+ if (error)
+ return "sparseTensors." + error;
+ }
+ }
+ if (message.typeProtos != null && message.hasOwnProperty("typeProtos")) {
+ if (!Array.isArray(message.typeProtos))
+ return "typeProtos: array expected";
+ for (var i = 0; i < message.typeProtos.length; ++i) {
+ var error = $root.onnx.TypeProto.verify(message.typeProtos[i]);
+ if (error)
+ return "typeProtos." + error;
+ }
+ }
+ return null;
+ };
+
+ /**
+ * Creates an AttributeProto message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.AttributeProto
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.AttributeProto} AttributeProto
+ */
+ AttributeProto.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.AttributeProto)
+ return object;
+ var message = new $root.onnx.AttributeProto();
+ if (object.name != null)
+ message.name = String(object.name);
+ if (object.refAttrName != null)
+ message.refAttrName = String(object.refAttrName);
+ if (object.docString != null)
+ message.docString = String(object.docString);
+ switch (object.type) {
+ default:
+ if (typeof object.type === "number") {
+ message.type = object.type;
+ break;
+ }
+ break;
+ case "UNDEFINED":
+ case 0:
+ message.type = 0;
+ break;
+ case "FLOAT":
+ case 1:
+ message.type = 1;
+ break;
+ case "INT":
+ case 2:
+ message.type = 2;
+ break;
+ case "STRING":
+ case 3:
+ message.type = 3;
+ break;
+ case "TENSOR":
+ case 4:
+ message.type = 4;
+ break;
+ case "GRAPH":
+ case 5:
+ message.type = 5;
+ break;
+ case "SPARSE_TENSOR":
+ case 11:
+ message.type = 11;
+ break;
+ case "TYPE_PROTO":
+ case 13:
+ message.type = 13;
+ break;
+ case "FLOATS":
+ case 6:
+ message.type = 6;
+ break;
+ case "INTS":
+ case 7:
+ message.type = 7;
+ break;
+ case "STRINGS":
+ case 8:
+ message.type = 8;
+ break;
+ case "TENSORS":
+ case 9:
+ message.type = 9;
+ break;
+ case "GRAPHS":
+ case 10:
+ message.type = 10;
+ break;
+ case "SPARSE_TENSORS":
+ case 12:
+ message.type = 12;
+ break;
+ case "TYPE_PROTOS":
+ case 14:
+ message.type = 14;
+ break;
+ }
+ if (object.f != null)
+ message.f = Number(object.f);
+ if (object.i != null)
+ if ($util.Long)
+ (message.i = $util.Long.fromValue(object.i)).unsigned = false;
+ else if (typeof object.i === "string")
+ message.i = parseInt(object.i, 10);
+ else if (typeof object.i === "number")
+ message.i = object.i;
+ else if (typeof object.i === "object")
+ message.i = new $util.LongBits(object.i.low >>> 0, object.i.high >>> 0).toNumber();
+ if (object.s != null)
+ if (typeof object.s === "string")
+ $util.base64.decode(object.s, message.s = $util.newBuffer($util.base64.length(object.s)), 0);
+ else if (object.s.length >= 0)
+ message.s = object.s;
+ if (object.t != null) {
+ if (typeof object.t !== "object")
+ throw TypeError(".onnx.AttributeProto.t: object expected");
+ message.t = $root.onnx.TensorProto.fromObject(object.t);
+ }
+ if (object.g != null) {
+ if (typeof object.g !== "object")
+ throw TypeError(".onnx.AttributeProto.g: object expected");
+ message.g = $root.onnx.GraphProto.fromObject(object.g);
+ }
+ if (object.sparseTensor != null) {
+ if (typeof object.sparseTensor !== "object")
+ throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");
+ message.sparseTensor = $root.onnx.SparseTensorProto.fromObject(object.sparseTensor);
+ }
+ if (object.tp != null) {
+ if (typeof object.tp !== "object")
+ throw TypeError(".onnx.AttributeProto.tp: object expected");
+ message.tp = $root.onnx.TypeProto.fromObject(object.tp);
+ }
+ if (object.floats) {
+ if (!Array.isArray(object.floats))
+ throw TypeError(".onnx.AttributeProto.floats: array expected");
+ message.floats = [];
+ for (var i = 0; i < object.floats.length; ++i)
+ message.floats[i] = Number(object.floats[i]);
+ }
+ if (object.ints) {
+ if (!Array.isArray(object.ints))
+ throw TypeError(".onnx.AttributeProto.ints: array expected");
+ message.ints = [];
+ for (var i = 0; i < object.ints.length; ++i)
+ if ($util.Long)
+ (message.ints[i] = $util.Long.fromValue(object.ints[i])).unsigned = false;
+ else if (typeof object.ints[i] === "string")
+ message.ints[i] = parseInt(object.ints[i], 10);
+ else if (typeof object.ints[i] === "number")
+ message.ints[i] = object.ints[i];
+ else if (typeof object.ints[i] === "object")
+ message.ints[i] = new $util.LongBits(object.ints[i].low >>> 0, object.ints[i].high >>> 0).toNumber();
+ }
+ if (object.strings) {
+ if (!Array.isArray(object.strings))
+ throw TypeError(".onnx.AttributeProto.strings: array expected");
+ message.strings = [];
+ for (var i = 0; i < object.strings.length; ++i)
+ if (typeof object.strings[i] === "string")
+ $util.base64.decode(object.strings[i], message.strings[i] = $util.newBuffer($util.base64.length(object.strings[i])), 0);
+ else if (object.strings[i].length >= 0)
+ message.strings[i] = object.strings[i];
+ }
+ if (object.tensors) {
+ if (!Array.isArray(object.tensors))
+ throw TypeError(".onnx.AttributeProto.tensors: array expected");
+ message.tensors = [];
+ for (var i = 0; i < object.tensors.length; ++i) {
+ if (typeof object.tensors[i] !== "object")
+ throw TypeError(".onnx.AttributeProto.tensors: object expected");
+ message.tensors[i] = $root.onnx.TensorProto.fromObject(object.tensors[i]);
+ }
+ }
+ if (object.graphs) {
+ if (!Array.isArray(object.graphs))
+ throw TypeError(".onnx.AttributeProto.graphs: array expected");
+ message.graphs = [];
+ for (var i = 0; i < object.graphs.length; ++i) {
+ if (typeof object.graphs[i] !== "object")
+ throw TypeError(".onnx.AttributeProto.graphs: object expected");
+ message.graphs[i] = $root.onnx.GraphProto.fromObject(object.graphs[i]);
+ }
+ }
+ if (object.sparseTensors) {
+ if (!Array.isArray(object.sparseTensors))
+ throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");
+ message.sparseTensors = [];
+ for (var i = 0; i < object.sparseTensors.length; ++i) {
+ if (typeof object.sparseTensors[i] !== "object")
+ throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");
+ message.sparseTensors[i] = $root.onnx.SparseTensorProto.fromObject(object.sparseTensors[i]);
+ }
+ }
+ if (object.typeProtos) {
+ if (!Array.isArray(object.typeProtos))
+ throw TypeError(".onnx.AttributeProto.typeProtos: array expected");
+ message.typeProtos = [];
+ for (var i = 0; i < object.typeProtos.length; ++i) {
+ if (typeof object.typeProtos[i] !== "object")
+ throw TypeError(".onnx.AttributeProto.typeProtos: object expected");
+ message.typeProtos[i] = $root.onnx.TypeProto.fromObject(object.typeProtos[i]);
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Creates a plain object from an AttributeProto message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.AttributeProto
+ * @static
+ * @param {onnx.AttributeProto} message AttributeProto
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ AttributeProto.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.arrays || options.defaults) {
+ object.floats = [];
+ object.ints = [];
+ object.strings = [];
+ object.tensors = [];
+ object.graphs = [];
+ object.typeProtos = [];
+ object.sparseTensors = [];
+ }
+ if (options.defaults) {
+ object.name = "";
+ object.f = 0;
+ if ($util.Long) {
+ var long = new $util.Long(0, 0, false);
+ object.i = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
+ } else
+ object.i = options.longs === String ? "0" : 0;
+ if (options.bytes === String)
+ object.s = "";
+ else {
+ object.s = [];
+ if (options.bytes !== Array)
+ object.s = $util.newBuffer(object.s);
+ }
+ object.t = null;
+ object.g = null;
+ object.docString = "";
+ object.tp = null;
+ object.type = options.enums === String ? "UNDEFINED" : 0;
+ object.refAttrName = "";
+ object.sparseTensor = null;
+ }
+ if (message.name != null && message.hasOwnProperty("name"))
+ object.name = message.name;
+ if (message.f != null && message.hasOwnProperty("f"))
+ object.f = options.json && !isFinite(message.f) ? String(message.f) : message.f;
+ if (message.i != null && message.hasOwnProperty("i"))
+ if (typeof message.i === "number")
+ object.i = options.longs === String ? String(message.i) : message.i;
+ else
+ object.i = options.longs === String ? $util.Long.prototype.toString.call(message.i) : options.longs === Number ? new $util.LongBits(message.i.low >>> 0, message.i.high >>> 0).toNumber() : message.i;
+ if (message.s != null && message.hasOwnProperty("s"))
+ object.s = options.bytes === String ? $util.base64.encode(message.s, 0, message.s.length) : options.bytes === Array ? Array.prototype.slice.call(message.s) : message.s;
+ if (message.t != null && message.hasOwnProperty("t"))
+ object.t = $root.onnx.TensorProto.toObject(message.t, options);
+ if (message.g != null && message.hasOwnProperty("g"))
+ object.g = $root.onnx.GraphProto.toObject(message.g, options);
+ if (message.floats && message.floats.length) {
+ object.floats = [];
+ for (var j = 0; j < message.floats.length; ++j)
+ object.floats[j] = options.json && !isFinite(message.floats[j]) ? String(message.floats[j]) : message.floats[j];
+ }
+ if (message.ints && message.ints.length) {
+ object.ints = [];
+ for (var j = 0; j < message.ints.length; ++j)
+ if (typeof message.ints[j] === "number")
+ object.ints[j] = options.longs === String ? String(message.ints[j]) : message.ints[j];
+ else
+ object.ints[j] = options.longs === String ? $util.Long.prototype.toString.call(message.ints[j]) : options.longs === Number ? new $util.LongBits(message.ints[j].low >>> 0, message.ints[j].high >>> 0).toNumber() : message.ints[j];
+ }
+ if (message.strings && message.strings.length) {
+ object.strings = [];
+ for (var j = 0; j < message.strings.length; ++j)
+ object.strings[j] = options.bytes === String ? $util.base64.encode(message.strings[j], 0, message.strings[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.strings[j]) : message.strings[j];
+ }
+ if (message.tensors && message.tensors.length) {
+ object.tensors = [];
+ for (var j = 0; j < message.tensors.length; ++j)
+ object.tensors[j] = $root.onnx.TensorProto.toObject(message.tensors[j], options);
+ }
+ if (message.graphs && message.graphs.length) {
+ object.graphs = [];
+ for (var j = 0; j < message.graphs.length; ++j)
+ object.graphs[j] = $root.onnx.GraphProto.toObject(message.graphs[j], options);
+ }
+ if (message.docString != null && message.hasOwnProperty("docString"))
+ object.docString = message.docString;
+ if (message.tp != null && message.hasOwnProperty("tp"))
+ object.tp = $root.onnx.TypeProto.toObject(message.tp, options);
+ if (message.typeProtos && message.typeProtos.length) {
+ object.typeProtos = [];
+ for (var j = 0; j < message.typeProtos.length; ++j)
+ object.typeProtos[j] = $root.onnx.TypeProto.toObject(message.typeProtos[j], options);
+ }
+ if (message.type != null && message.hasOwnProperty("type"))
+ object.type = options.enums === String ? $root.onnx.AttributeProto.AttributeType[message.type] === undefined ? message.type : $root.onnx.AttributeProto.AttributeType[message.type] : message.type;
+ if (message.refAttrName != null && message.hasOwnProperty("refAttrName"))
+ object.refAttrName = message.refAttrName;
+ if (message.sparseTensor != null && message.hasOwnProperty("sparseTensor"))
+ object.sparseTensor = $root.onnx.SparseTensorProto.toObject(message.sparseTensor, options);
+ if (message.sparseTensors && message.sparseTensors.length) {
+ object.sparseTensors = [];
+ for (var j = 0; j < message.sparseTensors.length; ++j)
+ object.sparseTensors[j] = $root.onnx.SparseTensorProto.toObject(message.sparseTensors[j], options);
+ }
+ return object;
+ };
+
+ /**
+ * Converts this AttributeProto to JSON.
+ * @function toJSON
+ * @memberof onnx.AttributeProto
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ AttributeProto.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for AttributeProto
+ * @function getTypeUrl
+ * @memberof onnx.AttributeProto
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ AttributeProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.AttributeProto";
+ };
+
+ /**
+ * AttributeType enum.
+ * @name onnx.AttributeProto.AttributeType
+ * @enum {number}
+ * @property {number} UNDEFINED=0 UNDEFINED value
+ * @property {number} FLOAT=1 FLOAT value
+ * @property {number} INT=2 INT value
+ * @property {number} STRING=3 STRING value
+ * @property {number} TENSOR=4 TENSOR value
+ * @property {number} GRAPH=5 GRAPH value
+ * @property {number} SPARSE_TENSOR=11 SPARSE_TENSOR value
+ * @property {number} TYPE_PROTO=13 TYPE_PROTO value
+ * @property {number} FLOATS=6 FLOATS value
+ * @property {number} INTS=7 INTS value
+ * @property {number} STRINGS=8 STRINGS value
+ * @property {number} TENSORS=9 TENSORS value
+ * @property {number} GRAPHS=10 GRAPHS value
+ * @property {number} SPARSE_TENSORS=12 SPARSE_TENSORS value
+ * @property {number} TYPE_PROTOS=14 TYPE_PROTOS value
+ */
+ AttributeProto.AttributeType = (function() {
+ var valuesById = {}, values = Object.create(valuesById);
+ values[valuesById[0] = "UNDEFINED"] = 0;
+ values[valuesById[1] = "FLOAT"] = 1;
+ values[valuesById[2] = "INT"] = 2;
+ values[valuesById[3] = "STRING"] = 3;
+ values[valuesById[4] = "TENSOR"] = 4;
+ values[valuesById[5] = "GRAPH"] = 5;
+ values[valuesById[11] = "SPARSE_TENSOR"] = 11;
+ values[valuesById[13] = "TYPE_PROTO"] = 13;
+ values[valuesById[6] = "FLOATS"] = 6;
+ values[valuesById[7] = "INTS"] = 7;
+ values[valuesById[8] = "STRINGS"] = 8;
+ values[valuesById[9] = "TENSORS"] = 9;
+ values[valuesById[10] = "GRAPHS"] = 10;
+ values[valuesById[12] = "SPARSE_TENSORS"] = 12;
+ values[valuesById[14] = "TYPE_PROTOS"] = 14;
+ return values;
+ })();
+
+ return AttributeProto;
+ })();
+
+ onnx.ValueInfoProto = (function() {
+
+ /**
+ * Properties of a ValueInfoProto.
+ * @memberof onnx
+ * @interface IValueInfoProto
+ * @property {string|null} [name] ValueInfoProto name
+ * @property {onnx.ITypeProto|null} [type] ValueInfoProto type
+ * @property {string|null} [docString] ValueInfoProto docString
+ */
+
+ /**
+ * Constructs a new ValueInfoProto.
+ * @memberof onnx
+ * @classdesc Represents a ValueInfoProto.
+ * @implements IValueInfoProto
+ * @constructor
+ * @param {onnx.IValueInfoProto=} [properties] Properties to set
+ */
+ function ValueInfoProto(properties) {
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * ValueInfoProto name.
+ * @member {string} name
+ * @memberof onnx.ValueInfoProto
+ * @instance
+ */
+ ValueInfoProto.prototype.name = "";
+
+ /**
+ * ValueInfoProto type.
+ * @member {onnx.ITypeProto|null|undefined} type
+ * @memberof onnx.ValueInfoProto
+ * @instance
+ */
+ ValueInfoProto.prototype.type = null;
+
+ /**
+ * ValueInfoProto docString.
+ * @member {string} docString
+ * @memberof onnx.ValueInfoProto
+ * @instance
+ */
+ ValueInfoProto.prototype.docString = "";
+
+ /**
+ * Creates a new ValueInfoProto instance using the specified properties.
+ * @function create
+ * @memberof onnx.ValueInfoProto
+ * @static
+ * @param {onnx.IValueInfoProto=} [properties] Properties to set
+ * @returns {onnx.ValueInfoProto} ValueInfoProto instance
+ */
+ ValueInfoProto.create = function create(properties) {
+ return new ValueInfoProto(properties);
+ };
+
+ /**
+ * Encodes the specified ValueInfoProto message. Does not implicitly {@link onnx.ValueInfoProto.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.ValueInfoProto
+ * @static
+ * @param {onnx.IValueInfoProto} message ValueInfoProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ ValueInfoProto.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.name != null && Object.hasOwnProperty.call(message, "name"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.name);
+ if (message.type != null && Object.hasOwnProperty.call(message, "type"))
+ $root.onnx.TypeProto.encode(message.type, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
+ if (message.docString != null && Object.hasOwnProperty.call(message, "docString"))
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.docString);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified ValueInfoProto message, length delimited. Does not implicitly {@link onnx.ValueInfoProto.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.ValueInfoProto
+ * @static
+ * @param {onnx.IValueInfoProto} message ValueInfoProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ ValueInfoProto.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a ValueInfoProto message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.ValueInfoProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.ValueInfoProto} ValueInfoProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ ValueInfoProto.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.ValueInfoProto();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.name = reader.string();
+ break;
+ }
+ case 2: {
+ message.type = $root.onnx.TypeProto.decode(reader, reader.uint32());
+ break;
+ }
+ case 3: {
+ message.docString = reader.string();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a ValueInfoProto message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.ValueInfoProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.ValueInfoProto} ValueInfoProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ ValueInfoProto.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a ValueInfoProto message.
+ * @function verify
+ * @memberof onnx.ValueInfoProto
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ ValueInfoProto.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.name != null && message.hasOwnProperty("name"))
+ if (!$util.isString(message.name))
+ return "name: string expected";
+ if (message.type != null && message.hasOwnProperty("type")) {
+ var error = $root.onnx.TypeProto.verify(message.type);
+ if (error)
+ return "type." + error;
+ }
+ if (message.docString != null && message.hasOwnProperty("docString"))
+ if (!$util.isString(message.docString))
+ return "docString: string expected";
+ return null;
+ };
+
+ /**
+ * Creates a ValueInfoProto message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.ValueInfoProto
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.ValueInfoProto} ValueInfoProto
+ */
+ ValueInfoProto.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.ValueInfoProto)
+ return object;
+ var message = new $root.onnx.ValueInfoProto();
+ if (object.name != null)
+ message.name = String(object.name);
+ if (object.type != null) {
+ if (typeof object.type !== "object")
+ throw TypeError(".onnx.ValueInfoProto.type: object expected");
+ message.type = $root.onnx.TypeProto.fromObject(object.type);
+ }
+ if (object.docString != null)
+ message.docString = String(object.docString);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a ValueInfoProto message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.ValueInfoProto
+ * @static
+ * @param {onnx.ValueInfoProto} message ValueInfoProto
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ ValueInfoProto.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.defaults) {
+ object.name = "";
+ object.type = null;
+ object.docString = "";
+ }
+ if (message.name != null && message.hasOwnProperty("name"))
+ object.name = message.name;
+ if (message.type != null && message.hasOwnProperty("type"))
+ object.type = $root.onnx.TypeProto.toObject(message.type, options);
+ if (message.docString != null && message.hasOwnProperty("docString"))
+ object.docString = message.docString;
+ return object;
+ };
+
+ /**
+ * Converts this ValueInfoProto to JSON.
+ * @function toJSON
+ * @memberof onnx.ValueInfoProto
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ ValueInfoProto.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for ValueInfoProto
+ * @function getTypeUrl
+ * @memberof onnx.ValueInfoProto
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ ValueInfoProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.ValueInfoProto";
+ };
+
+ return ValueInfoProto;
+ })();
+
+ onnx.NodeProto = (function() {
+
+ /**
+ * Properties of a NodeProto.
+ * @memberof onnx
+ * @interface INodeProto
+ * @property {Array.|null} [input] NodeProto input
+ * @property {Array.|null} [output] NodeProto output
+ * @property {string|null} [name] NodeProto name
+ * @property {string|null} [opType] NodeProto opType
+ * @property {string|null} [domain] NodeProto domain
+ * @property {Array.|null} [attribute] NodeProto attribute
+ * @property {string|null} [docString] NodeProto docString
+ */
+
+ /**
+ * Constructs a new NodeProto.
+ * @memberof onnx
+ * @classdesc Represents a NodeProto.
+ * @implements INodeProto
+ * @constructor
+ * @param {onnx.INodeProto=} [properties] Properties to set
+ */
+ function NodeProto(properties) {
+ this.input = [];
+ this.output = [];
+ this.attribute = [];
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * NodeProto input.
+ * @member {Array.} input
+ * @memberof onnx.NodeProto
+ * @instance
+ */
+ NodeProto.prototype.input = $util.emptyArray;
+
+ /**
+ * NodeProto output.
+ * @member {Array.} output
+ * @memberof onnx.NodeProto
+ * @instance
+ */
+ NodeProto.prototype.output = $util.emptyArray;
+
+ /**
+ * NodeProto name.
+ * @member {string} name
+ * @memberof onnx.NodeProto
+ * @instance
+ */
+ NodeProto.prototype.name = "";
+
+ /**
+ * NodeProto opType.
+ * @member {string} opType
+ * @memberof onnx.NodeProto
+ * @instance
+ */
+ NodeProto.prototype.opType = "";
+
+ /**
+ * NodeProto domain.
+ * @member {string} domain
+ * @memberof onnx.NodeProto
+ * @instance
+ */
+ NodeProto.prototype.domain = "";
+
+ /**
+ * NodeProto attribute.
+ * @member {Array.} attribute
+ * @memberof onnx.NodeProto
+ * @instance
+ */
+ NodeProto.prototype.attribute = $util.emptyArray;
+
+ /**
+ * NodeProto docString.
+ * @member {string} docString
+ * @memberof onnx.NodeProto
+ * @instance
+ */
+ NodeProto.prototype.docString = "";
+
+ /**
+ * Creates a new NodeProto instance using the specified properties.
+ * @function create
+ * @memberof onnx.NodeProto
+ * @static
+ * @param {onnx.INodeProto=} [properties] Properties to set
+ * @returns {onnx.NodeProto} NodeProto instance
+ */
+ NodeProto.create = function create(properties) {
+ return new NodeProto(properties);
+ };
+
+ /**
+ * Encodes the specified NodeProto message. Does not implicitly {@link onnx.NodeProto.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.NodeProto
+ * @static
+ * @param {onnx.INodeProto} message NodeProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ NodeProto.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.input != null && message.input.length)
+ for (var i = 0; i < message.input.length; ++i)
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.input[i]);
+ if (message.output != null && message.output.length)
+ for (var i = 0; i < message.output.length; ++i)
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.output[i]);
+ if (message.name != null && Object.hasOwnProperty.call(message, "name"))
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.name);
+ if (message.opType != null && Object.hasOwnProperty.call(message, "opType"))
+ writer.uint32(/* id 4, wireType 2 =*/34).string(message.opType);
+ if (message.attribute != null && message.attribute.length)
+ for (var i = 0; i < message.attribute.length; ++i)
+ $root.onnx.AttributeProto.encode(message.attribute[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim();
+ if (message.docString != null && Object.hasOwnProperty.call(message, "docString"))
+ writer.uint32(/* id 6, wireType 2 =*/50).string(message.docString);
+ if (message.domain != null && Object.hasOwnProperty.call(message, "domain"))
+ writer.uint32(/* id 7, wireType 2 =*/58).string(message.domain);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified NodeProto message, length delimited. Does not implicitly {@link onnx.NodeProto.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.NodeProto
+ * @static
+ * @param {onnx.INodeProto} message NodeProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ NodeProto.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a NodeProto message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.NodeProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.NodeProto} NodeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ NodeProto.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.NodeProto();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ if (!(message.input && message.input.length))
+ message.input = [];
+ message.input.push(reader.string());
+ break;
+ }
+ case 2: {
+ if (!(message.output && message.output.length))
+ message.output = [];
+ message.output.push(reader.string());
+ break;
+ }
+ case 3: {
+ message.name = reader.string();
+ break;
+ }
+ case 4: {
+ message.opType = reader.string();
+ break;
+ }
+ case 7: {
+ message.domain = reader.string();
+ break;
+ }
+ case 5: {
+ if (!(message.attribute && message.attribute.length))
+ message.attribute = [];
+ message.attribute.push($root.onnx.AttributeProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 6: {
+ message.docString = reader.string();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a NodeProto message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.NodeProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.NodeProto} NodeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ NodeProto.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a NodeProto message.
+ * @function verify
+ * @memberof onnx.NodeProto
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ NodeProto.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.input != null && message.hasOwnProperty("input")) {
+ if (!Array.isArray(message.input))
+ return "input: array expected";
+ for (var i = 0; i < message.input.length; ++i)
+ if (!$util.isString(message.input[i]))
+ return "input: string[] expected";
+ }
+ if (message.output != null && message.hasOwnProperty("output")) {
+ if (!Array.isArray(message.output))
+ return "output: array expected";
+ for (var i = 0; i < message.output.length; ++i)
+ if (!$util.isString(message.output[i]))
+ return "output: string[] expected";
+ }
+ if (message.name != null && message.hasOwnProperty("name"))
+ if (!$util.isString(message.name))
+ return "name: string expected";
+ if (message.opType != null && message.hasOwnProperty("opType"))
+ if (!$util.isString(message.opType))
+ return "opType: string expected";
+ if (message.domain != null && message.hasOwnProperty("domain"))
+ if (!$util.isString(message.domain))
+ return "domain: string expected";
+ if (message.attribute != null && message.hasOwnProperty("attribute")) {
+ if (!Array.isArray(message.attribute))
+ return "attribute: array expected";
+ for (var i = 0; i < message.attribute.length; ++i) {
+ var error = $root.onnx.AttributeProto.verify(message.attribute[i]);
+ if (error)
+ return "attribute." + error;
+ }
+ }
+ if (message.docString != null && message.hasOwnProperty("docString"))
+ if (!$util.isString(message.docString))
+ return "docString: string expected";
+ return null;
+ };
+
+ /**
+ * Creates a NodeProto message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.NodeProto
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.NodeProto} NodeProto
+ */
+ NodeProto.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.NodeProto)
+ return object;
+ var message = new $root.onnx.NodeProto();
+ if (object.input) {
+ if (!Array.isArray(object.input))
+ throw TypeError(".onnx.NodeProto.input: array expected");
+ message.input = [];
+ for (var i = 0; i < object.input.length; ++i)
+ message.input[i] = String(object.input[i]);
+ }
+ if (object.output) {
+ if (!Array.isArray(object.output))
+ throw TypeError(".onnx.NodeProto.output: array expected");
+ message.output = [];
+ for (var i = 0; i < object.output.length; ++i)
+ message.output[i] = String(object.output[i]);
+ }
+ if (object.name != null)
+ message.name = String(object.name);
+ if (object.opType != null)
+ message.opType = String(object.opType);
+ if (object.domain != null)
+ message.domain = String(object.domain);
+ if (object.attribute) {
+ if (!Array.isArray(object.attribute))
+ throw TypeError(".onnx.NodeProto.attribute: array expected");
+ message.attribute = [];
+ for (var i = 0; i < object.attribute.length; ++i) {
+ if (typeof object.attribute[i] !== "object")
+ throw TypeError(".onnx.NodeProto.attribute: object expected");
+ message.attribute[i] = $root.onnx.AttributeProto.fromObject(object.attribute[i]);
+ }
+ }
+ if (object.docString != null)
+ message.docString = String(object.docString);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a NodeProto message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.NodeProto
+ * @static
+ * @param {onnx.NodeProto} message NodeProto
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ NodeProto.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.arrays || options.defaults) {
+ object.input = [];
+ object.output = [];
+ object.attribute = [];
+ }
+ if (options.defaults) {
+ object.name = "";
+ object.opType = "";
+ object.docString = "";
+ object.domain = "";
+ }
+ if (message.input && message.input.length) {
+ object.input = [];
+ for (var j = 0; j < message.input.length; ++j)
+ object.input[j] = message.input[j];
+ }
+ if (message.output && message.output.length) {
+ object.output = [];
+ for (var j = 0; j < message.output.length; ++j)
+ object.output[j] = message.output[j];
+ }
+ if (message.name != null && message.hasOwnProperty("name"))
+ object.name = message.name;
+ if (message.opType != null && message.hasOwnProperty("opType"))
+ object.opType = message.opType;
+ if (message.attribute && message.attribute.length) {
+ object.attribute = [];
+ for (var j = 0; j < message.attribute.length; ++j)
+ object.attribute[j] = $root.onnx.AttributeProto.toObject(message.attribute[j], options);
+ }
+ if (message.docString != null && message.hasOwnProperty("docString"))
+ object.docString = message.docString;
+ if (message.domain != null && message.hasOwnProperty("domain"))
+ object.domain = message.domain;
+ return object;
+ };
+
+ /**
+ * Converts this NodeProto to JSON.
+ * @function toJSON
+ * @memberof onnx.NodeProto
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ NodeProto.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for NodeProto
+ * @function getTypeUrl
+ * @memberof onnx.NodeProto
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ NodeProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.NodeProto";
+ };
+
+ return NodeProto;
+ })();
+
+ onnx.TrainingInfoProto = (function() {
+
+ /**
+ * Properties of a TrainingInfoProto.
+ * @memberof onnx
+ * @interface ITrainingInfoProto
+ * @property {onnx.IGraphProto|null} [initialization] TrainingInfoProto initialization
+ * @property {onnx.IGraphProto|null} [algorithm] TrainingInfoProto algorithm
+ * @property {Array.|null} [initializationBinding] TrainingInfoProto initializationBinding
+ * @property {Array.|null} [updateBinding] TrainingInfoProto updateBinding
+ */
+
+ /**
+ * Constructs a new TrainingInfoProto.
+ * @memberof onnx
+ * @classdesc Represents a TrainingInfoProto.
+ * @implements ITrainingInfoProto
+ * @constructor
+ * @param {onnx.ITrainingInfoProto=} [properties] Properties to set
+ */
+ function TrainingInfoProto(properties) {
+ this.initializationBinding = [];
+ this.updateBinding = [];
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * TrainingInfoProto initialization.
+ * @member {onnx.IGraphProto|null|undefined} initialization
+ * @memberof onnx.TrainingInfoProto
+ * @instance
+ */
+ TrainingInfoProto.prototype.initialization = null;
+
+ /**
+ * TrainingInfoProto algorithm.
+ * @member {onnx.IGraphProto|null|undefined} algorithm
+ * @memberof onnx.TrainingInfoProto
+ * @instance
+ */
+ TrainingInfoProto.prototype.algorithm = null;
+
+ /**
+ * TrainingInfoProto initializationBinding.
+ * @member {Array.} initializationBinding
+ * @memberof onnx.TrainingInfoProto
+ * @instance
+ */
+ TrainingInfoProto.prototype.initializationBinding = $util.emptyArray;
+
+ /**
+ * TrainingInfoProto updateBinding.
+ * @member {Array.} updateBinding
+ * @memberof onnx.TrainingInfoProto
+ * @instance
+ */
+ TrainingInfoProto.prototype.updateBinding = $util.emptyArray;
+
+ /**
+ * Creates a new TrainingInfoProto instance using the specified properties.
+ * @function create
+ * @memberof onnx.TrainingInfoProto
+ * @static
+ * @param {onnx.ITrainingInfoProto=} [properties] Properties to set
+ * @returns {onnx.TrainingInfoProto} TrainingInfoProto instance
+ */
+ TrainingInfoProto.create = function create(properties) {
+ return new TrainingInfoProto(properties);
+ };
+
+ /**
+ * Encodes the specified TrainingInfoProto message. Does not implicitly {@link onnx.TrainingInfoProto.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.TrainingInfoProto
+ * @static
+ * @param {onnx.ITrainingInfoProto} message TrainingInfoProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ TrainingInfoProto.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.initialization != null && Object.hasOwnProperty.call(message, "initialization"))
+ $root.onnx.GraphProto.encode(message.initialization, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
+ if (message.algorithm != null && Object.hasOwnProperty.call(message, "algorithm"))
+ $root.onnx.GraphProto.encode(message.algorithm, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
+ if (message.initializationBinding != null && message.initializationBinding.length)
+ for (var i = 0; i < message.initializationBinding.length; ++i)
+ $root.onnx.StringStringEntryProto.encode(message.initializationBinding[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
+ if (message.updateBinding != null && message.updateBinding.length)
+ for (var i = 0; i < message.updateBinding.length; ++i)
+ $root.onnx.StringStringEntryProto.encode(message.updateBinding[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
+ return writer;
+ };
+
+ /**
+ * Encodes the specified TrainingInfoProto message, length delimited. Does not implicitly {@link onnx.TrainingInfoProto.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.TrainingInfoProto
+ * @static
+ * @param {onnx.ITrainingInfoProto} message TrainingInfoProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ TrainingInfoProto.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a TrainingInfoProto message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.TrainingInfoProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.TrainingInfoProto} TrainingInfoProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ TrainingInfoProto.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.TrainingInfoProto();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.initialization = $root.onnx.GraphProto.decode(reader, reader.uint32());
+ break;
+ }
+ case 2: {
+ message.algorithm = $root.onnx.GraphProto.decode(reader, reader.uint32());
+ break;
+ }
+ case 3: {
+ if (!(message.initializationBinding && message.initializationBinding.length))
+ message.initializationBinding = [];
+ message.initializationBinding.push($root.onnx.StringStringEntryProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 4: {
+ if (!(message.updateBinding && message.updateBinding.length))
+ message.updateBinding = [];
+ message.updateBinding.push($root.onnx.StringStringEntryProto.decode(reader, reader.uint32()));
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a TrainingInfoProto message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.TrainingInfoProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.TrainingInfoProto} TrainingInfoProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ TrainingInfoProto.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a TrainingInfoProto message.
+ * @function verify
+ * @memberof onnx.TrainingInfoProto
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ TrainingInfoProto.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.initialization != null && message.hasOwnProperty("initialization")) {
+ var error = $root.onnx.GraphProto.verify(message.initialization);
+ if (error)
+ return "initialization." + error;
+ }
+ if (message.algorithm != null && message.hasOwnProperty("algorithm")) {
+ var error = $root.onnx.GraphProto.verify(message.algorithm);
+ if (error)
+ return "algorithm." + error;
+ }
+ if (message.initializationBinding != null && message.hasOwnProperty("initializationBinding")) {
+ if (!Array.isArray(message.initializationBinding))
+ return "initializationBinding: array expected";
+ for (var i = 0; i < message.initializationBinding.length; ++i) {
+ var error = $root.onnx.StringStringEntryProto.verify(message.initializationBinding[i]);
+ if (error)
+ return "initializationBinding." + error;
+ }
+ }
+ if (message.updateBinding != null && message.hasOwnProperty("updateBinding")) {
+ if (!Array.isArray(message.updateBinding))
+ return "updateBinding: array expected";
+ for (var i = 0; i < message.updateBinding.length; ++i) {
+ var error = $root.onnx.StringStringEntryProto.verify(message.updateBinding[i]);
+ if (error)
+ return "updateBinding." + error;
+ }
+ }
+ return null;
+ };
+
+ /**
+ * Creates a TrainingInfoProto message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.TrainingInfoProto
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.TrainingInfoProto} TrainingInfoProto
+ */
+ TrainingInfoProto.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.TrainingInfoProto)
+ return object;
+ var message = new $root.onnx.TrainingInfoProto();
+ if (object.initialization != null) {
+ if (typeof object.initialization !== "object")
+ throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");
+ message.initialization = $root.onnx.GraphProto.fromObject(object.initialization);
+ }
+ if (object.algorithm != null) {
+ if (typeof object.algorithm !== "object")
+ throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");
+ message.algorithm = $root.onnx.GraphProto.fromObject(object.algorithm);
+ }
+ if (object.initializationBinding) {
+ if (!Array.isArray(object.initializationBinding))
+ throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");
+ message.initializationBinding = [];
+ for (var i = 0; i < object.initializationBinding.length; ++i) {
+ if (typeof object.initializationBinding[i] !== "object")
+ throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");
+ message.initializationBinding[i] = $root.onnx.StringStringEntryProto.fromObject(object.initializationBinding[i]);
+ }
+ }
+ if (object.updateBinding) {
+ if (!Array.isArray(object.updateBinding))
+ throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");
+ message.updateBinding = [];
+ for (var i = 0; i < object.updateBinding.length; ++i) {
+ if (typeof object.updateBinding[i] !== "object")
+ throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");
+ message.updateBinding[i] = $root.onnx.StringStringEntryProto.fromObject(object.updateBinding[i]);
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a TrainingInfoProto message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.TrainingInfoProto
+ * @static
+ * @param {onnx.TrainingInfoProto} message TrainingInfoProto
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ TrainingInfoProto.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.arrays || options.defaults) {
+ object.initializationBinding = [];
+ object.updateBinding = [];
+ }
+ if (options.defaults) {
+ object.initialization = null;
+ object.algorithm = null;
+ }
+ if (message.initialization != null && message.hasOwnProperty("initialization"))
+ object.initialization = $root.onnx.GraphProto.toObject(message.initialization, options);
+ if (message.algorithm != null && message.hasOwnProperty("algorithm"))
+ object.algorithm = $root.onnx.GraphProto.toObject(message.algorithm, options);
+ if (message.initializationBinding && message.initializationBinding.length) {
+ object.initializationBinding = [];
+ for (var j = 0; j < message.initializationBinding.length; ++j)
+ object.initializationBinding[j] = $root.onnx.StringStringEntryProto.toObject(message.initializationBinding[j], options);
+ }
+ if (message.updateBinding && message.updateBinding.length) {
+ object.updateBinding = [];
+ for (var j = 0; j < message.updateBinding.length; ++j)
+ object.updateBinding[j] = $root.onnx.StringStringEntryProto.toObject(message.updateBinding[j], options);
+ }
+ return object;
+ };
+
+ /**
+ * Converts this TrainingInfoProto to JSON.
+ * @function toJSON
+ * @memberof onnx.TrainingInfoProto
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ TrainingInfoProto.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for TrainingInfoProto
+ * @function getTypeUrl
+ * @memberof onnx.TrainingInfoProto
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ TrainingInfoProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.TrainingInfoProto";
+ };
+
+ return TrainingInfoProto;
+ })();
+
+ onnx.ModelProto = (function() {
+
+ /**
+ * Properties of a ModelProto.
+ * @memberof onnx
+ * @interface IModelProto
+ * @property {number|Long|null} [irVersion] ModelProto irVersion
+ * @property {Array.|null} [opsetImport] ModelProto opsetImport
+ * @property {string|null} [producerName] ModelProto producerName
+ * @property {string|null} [producerVersion] ModelProto producerVersion
+ * @property {string|null} [domain] ModelProto domain
+ * @property {number|Long|null} [modelVersion] ModelProto modelVersion
+ * @property {string|null} [docString] ModelProto docString
+ * @property {onnx.IGraphProto|null} [graph] ModelProto graph
+ * @property {Array.|null} [metadataProps] ModelProto metadataProps
+ * @property {Array.|null} [trainingInfo] ModelProto trainingInfo
+ * @property {Array.|null} [functions] ModelProto functions
+ */
+
+ /**
+ * Constructs a new ModelProto.
+ * @memberof onnx
+ * @classdesc Represents a ModelProto.
+ * @implements IModelProto
+ * @constructor
+ * @param {onnx.IModelProto=} [properties] Properties to set
+ */
+ function ModelProto(properties) {
+ this.opsetImport = [];
+ this.metadataProps = [];
+ this.trainingInfo = [];
+ this.functions = [];
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * ModelProto irVersion.
+ * @member {number|Long} irVersion
+ * @memberof onnx.ModelProto
+ * @instance
+ */
+ ModelProto.prototype.irVersion = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
+
+ /**
+ * ModelProto opsetImport.
+ * @member {Array.} opsetImport
+ * @memberof onnx.ModelProto
+ * @instance
+ */
+ ModelProto.prototype.opsetImport = $util.emptyArray;
+
+ /**
+ * ModelProto producerName.
+ * @member {string} producerName
+ * @memberof onnx.ModelProto
+ * @instance
+ */
+ ModelProto.prototype.producerName = "";
+
+ /**
+ * ModelProto producerVersion.
+ * @member {string} producerVersion
+ * @memberof onnx.ModelProto
+ * @instance
+ */
+ ModelProto.prototype.producerVersion = "";
+
+ /**
+ * ModelProto domain.
+ * @member {string} domain
+ * @memberof onnx.ModelProto
+ * @instance
+ */
+ ModelProto.prototype.domain = "";
+
+ /**
+ * ModelProto modelVersion.
+ * @member {number|Long} modelVersion
+ * @memberof onnx.ModelProto
+ * @instance
+ */
+ ModelProto.prototype.modelVersion = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
+
+ /**
+ * ModelProto docString.
+ * @member {string} docString
+ * @memberof onnx.ModelProto
+ * @instance
+ */
+ ModelProto.prototype.docString = "";
+
+ /**
+ * ModelProto graph.
+ * @member {onnx.IGraphProto|null|undefined} graph
+ * @memberof onnx.ModelProto
+ * @instance
+ */
+ ModelProto.prototype.graph = null;
+
+ /**
+ * ModelProto metadataProps.
+ * @member {Array.} metadataProps
+ * @memberof onnx.ModelProto
+ * @instance
+ */
+ ModelProto.prototype.metadataProps = $util.emptyArray;
+
+ /**
+ * ModelProto trainingInfo.
+ * @member {Array.} trainingInfo
+ * @memberof onnx.ModelProto
+ * @instance
+ */
+ ModelProto.prototype.trainingInfo = $util.emptyArray;
+
+ /**
+ * ModelProto functions.
+ * @member {Array.} functions
+ * @memberof onnx.ModelProto
+ * @instance
+ */
+ ModelProto.prototype.functions = $util.emptyArray;
+
+ /**
+ * Creates a new ModelProto instance using the specified properties.
+ * @function create
+ * @memberof onnx.ModelProto
+ * @static
+ * @param {onnx.IModelProto=} [properties] Properties to set
+ * @returns {onnx.ModelProto} ModelProto instance
+ */
+ ModelProto.create = function create(properties) {
+ return new ModelProto(properties);
+ };
+
+ /**
+ * Encodes the specified ModelProto message. Does not implicitly {@link onnx.ModelProto.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.ModelProto
+ * @static
+ * @param {onnx.IModelProto} message ModelProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ ModelProto.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.irVersion != null && Object.hasOwnProperty.call(message, "irVersion"))
+ writer.uint32(/* id 1, wireType 0 =*/8).int64(message.irVersion);
+ if (message.producerName != null && Object.hasOwnProperty.call(message, "producerName"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.producerName);
+ if (message.producerVersion != null && Object.hasOwnProperty.call(message, "producerVersion"))
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.producerVersion);
+ if (message.domain != null && Object.hasOwnProperty.call(message, "domain"))
+ writer.uint32(/* id 4, wireType 2 =*/34).string(message.domain);
+ if (message.modelVersion != null && Object.hasOwnProperty.call(message, "modelVersion"))
+ writer.uint32(/* id 5, wireType 0 =*/40).int64(message.modelVersion);
+ if (message.docString != null && Object.hasOwnProperty.call(message, "docString"))
+ writer.uint32(/* id 6, wireType 2 =*/50).string(message.docString);
+ if (message.graph != null && Object.hasOwnProperty.call(message, "graph"))
+ $root.onnx.GraphProto.encode(message.graph, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim();
+ if (message.opsetImport != null && message.opsetImport.length)
+ for (var i = 0; i < message.opsetImport.length; ++i)
+ $root.onnx.OperatorSetIdProto.encode(message.opsetImport[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim();
+ if (message.metadataProps != null && message.metadataProps.length)
+ for (var i = 0; i < message.metadataProps.length; ++i)
+ $root.onnx.StringStringEntryProto.encode(message.metadataProps[i], writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim();
+ if (message.trainingInfo != null && message.trainingInfo.length)
+ for (var i = 0; i < message.trainingInfo.length; ++i)
+ $root.onnx.TrainingInfoProto.encode(message.trainingInfo[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim();
+ if (message.functions != null && message.functions.length)
+ for (var i = 0; i < message.functions.length; ++i)
+ $root.onnx.FunctionProto.encode(message.functions[i], writer.uint32(/* id 25, wireType 2 =*/202).fork()).ldelim();
+ return writer;
+ };
+
+ /**
+ * Encodes the specified ModelProto message, length delimited. Does not implicitly {@link onnx.ModelProto.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.ModelProto
+ * @static
+ * @param {onnx.IModelProto} message ModelProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ ModelProto.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a ModelProto message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.ModelProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.ModelProto} ModelProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ ModelProto.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.ModelProto();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.irVersion = reader.int64();
+ break;
+ }
+ case 8: {
+ if (!(message.opsetImport && message.opsetImport.length))
+ message.opsetImport = [];
+ message.opsetImport.push($root.onnx.OperatorSetIdProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 2: {
+ message.producerName = reader.string();
+ break;
+ }
+ case 3: {
+ message.producerVersion = reader.string();
+ break;
+ }
+ case 4: {
+ message.domain = reader.string();
+ break;
+ }
+ case 5: {
+ message.modelVersion = reader.int64();
+ break;
+ }
+ case 6: {
+ message.docString = reader.string();
+ break;
+ }
+ case 7: {
+ message.graph = $root.onnx.GraphProto.decode(reader, reader.uint32());
+ break;
+ }
+ case 14: {
+ if (!(message.metadataProps && message.metadataProps.length))
+ message.metadataProps = [];
+ message.metadataProps.push($root.onnx.StringStringEntryProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 20: {
+ if (!(message.trainingInfo && message.trainingInfo.length))
+ message.trainingInfo = [];
+ message.trainingInfo.push($root.onnx.TrainingInfoProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 25: {
+ if (!(message.functions && message.functions.length))
+ message.functions = [];
+ message.functions.push($root.onnx.FunctionProto.decode(reader, reader.uint32()));
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a ModelProto message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.ModelProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.ModelProto} ModelProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ ModelProto.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a ModelProto message.
+ * @function verify
+ * @memberof onnx.ModelProto
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ ModelProto.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.irVersion != null && message.hasOwnProperty("irVersion"))
+ if (!$util.isInteger(message.irVersion) && !(message.irVersion && $util.isInteger(message.irVersion.low) && $util.isInteger(message.irVersion.high)))
+ return "irVersion: integer|Long expected";
+ if (message.opsetImport != null && message.hasOwnProperty("opsetImport")) {
+ if (!Array.isArray(message.opsetImport))
+ return "opsetImport: array expected";
+ for (var i = 0; i < message.opsetImport.length; ++i) {
+ var error = $root.onnx.OperatorSetIdProto.verify(message.opsetImport[i]);
+ if (error)
+ return "opsetImport." + error;
+ }
+ }
+ if (message.producerName != null && message.hasOwnProperty("producerName"))
+ if (!$util.isString(message.producerName))
+ return "producerName: string expected";
+ if (message.producerVersion != null && message.hasOwnProperty("producerVersion"))
+ if (!$util.isString(message.producerVersion))
+ return "producerVersion: string expected";
+ if (message.domain != null && message.hasOwnProperty("domain"))
+ if (!$util.isString(message.domain))
+ return "domain: string expected";
+ if (message.modelVersion != null && message.hasOwnProperty("modelVersion"))
+ if (!$util.isInteger(message.modelVersion) && !(message.modelVersion && $util.isInteger(message.modelVersion.low) && $util.isInteger(message.modelVersion.high)))
+ return "modelVersion: integer|Long expected";
+ if (message.docString != null && message.hasOwnProperty("docString"))
+ if (!$util.isString(message.docString))
+ return "docString: string expected";
+ if (message.graph != null && message.hasOwnProperty("graph")) {
+ var error = $root.onnx.GraphProto.verify(message.graph);
+ if (error)
+ return "graph." + error;
+ }
+ if (message.metadataProps != null && message.hasOwnProperty("metadataProps")) {
+ if (!Array.isArray(message.metadataProps))
+ return "metadataProps: array expected";
+ for (var i = 0; i < message.metadataProps.length; ++i) {
+ var error = $root.onnx.StringStringEntryProto.verify(message.metadataProps[i]);
+ if (error)
+ return "metadataProps." + error;
+ }
+ }
+ if (message.trainingInfo != null && message.hasOwnProperty("trainingInfo")) {
+ if (!Array.isArray(message.trainingInfo))
+ return "trainingInfo: array expected";
+ for (var i = 0; i < message.trainingInfo.length; ++i) {
+ var error = $root.onnx.TrainingInfoProto.verify(message.trainingInfo[i]);
+ if (error)
+ return "trainingInfo." + error;
+ }
+ }
+ if (message.functions != null && message.hasOwnProperty("functions")) {
+ if (!Array.isArray(message.functions))
+ return "functions: array expected";
+ for (var i = 0; i < message.functions.length; ++i) {
+ var error = $root.onnx.FunctionProto.verify(message.functions[i]);
+ if (error)
+ return "functions." + error;
+ }
+ }
+ return null;
+ };
+
+ /**
+ * Creates a ModelProto message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.ModelProto
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.ModelProto} ModelProto
+ */
+ ModelProto.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.ModelProto)
+ return object;
+ var message = new $root.onnx.ModelProto();
+ if (object.irVersion != null)
+ if ($util.Long)
+ (message.irVersion = $util.Long.fromValue(object.irVersion)).unsigned = false;
+ else if (typeof object.irVersion === "string")
+ message.irVersion = parseInt(object.irVersion, 10);
+ else if (typeof object.irVersion === "number")
+ message.irVersion = object.irVersion;
+ else if (typeof object.irVersion === "object")
+ message.irVersion = new $util.LongBits(object.irVersion.low >>> 0, object.irVersion.high >>> 0).toNumber();
+ if (object.opsetImport) {
+ if (!Array.isArray(object.opsetImport))
+ throw TypeError(".onnx.ModelProto.opsetImport: array expected");
+ message.opsetImport = [];
+ for (var i = 0; i < object.opsetImport.length; ++i) {
+ if (typeof object.opsetImport[i] !== "object")
+ throw TypeError(".onnx.ModelProto.opsetImport: object expected");
+ message.opsetImport[i] = $root.onnx.OperatorSetIdProto.fromObject(object.opsetImport[i]);
+ }
+ }
+ if (object.producerName != null)
+ message.producerName = String(object.producerName);
+ if (object.producerVersion != null)
+ message.producerVersion = String(object.producerVersion);
+ if (object.domain != null)
+ message.domain = String(object.domain);
+ if (object.modelVersion != null)
+ if ($util.Long)
+ (message.modelVersion = $util.Long.fromValue(object.modelVersion)).unsigned = false;
+ else if (typeof object.modelVersion === "string")
+ message.modelVersion = parseInt(object.modelVersion, 10);
+ else if (typeof object.modelVersion === "number")
+ message.modelVersion = object.modelVersion;
+ else if (typeof object.modelVersion === "object")
+ message.modelVersion = new $util.LongBits(object.modelVersion.low >>> 0, object.modelVersion.high >>> 0).toNumber();
+ if (object.docString != null)
+ message.docString = String(object.docString);
+ if (object.graph != null) {
+ if (typeof object.graph !== "object")
+ throw TypeError(".onnx.ModelProto.graph: object expected");
+ message.graph = $root.onnx.GraphProto.fromObject(object.graph);
+ }
+ if (object.metadataProps) {
+ if (!Array.isArray(object.metadataProps))
+ throw TypeError(".onnx.ModelProto.metadataProps: array expected");
+ message.metadataProps = [];
+ for (var i = 0; i < object.metadataProps.length; ++i) {
+ if (typeof object.metadataProps[i] !== "object")
+ throw TypeError(".onnx.ModelProto.metadataProps: object expected");
+ message.metadataProps[i] = $root.onnx.StringStringEntryProto.fromObject(object.metadataProps[i]);
+ }
+ }
+ if (object.trainingInfo) {
+ if (!Array.isArray(object.trainingInfo))
+ throw TypeError(".onnx.ModelProto.trainingInfo: array expected");
+ message.trainingInfo = [];
+ for (var i = 0; i < object.trainingInfo.length; ++i) {
+ if (typeof object.trainingInfo[i] !== "object")
+ throw TypeError(".onnx.ModelProto.trainingInfo: object expected");
+ message.trainingInfo[i] = $root.onnx.TrainingInfoProto.fromObject(object.trainingInfo[i]);
+ }
+ }
+ if (object.functions) {
+ if (!Array.isArray(object.functions))
+ throw TypeError(".onnx.ModelProto.functions: array expected");
+ message.functions = [];
+ for (var i = 0; i < object.functions.length; ++i) {
+ if (typeof object.functions[i] !== "object")
+ throw TypeError(".onnx.ModelProto.functions: object expected");
+ message.functions[i] = $root.onnx.FunctionProto.fromObject(object.functions[i]);
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a ModelProto message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.ModelProto
+ * @static
+ * @param {onnx.ModelProto} message ModelProto
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ ModelProto.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.arrays || options.defaults) {
+ object.opsetImport = [];
+ object.metadataProps = [];
+ object.trainingInfo = [];
+ object.functions = [];
+ }
+ if (options.defaults) {
+ if ($util.Long) {
+ var long = new $util.Long(0, 0, false);
+ object.irVersion = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
+ } else
+ object.irVersion = options.longs === String ? "0" : 0;
+ object.producerName = "";
+ object.producerVersion = "";
+ object.domain = "";
+ if ($util.Long) {
+ var long = new $util.Long(0, 0, false);
+ object.modelVersion = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
+ } else
+ object.modelVersion = options.longs === String ? "0" : 0;
+ object.docString = "";
+ object.graph = null;
+ }
+ if (message.irVersion != null && message.hasOwnProperty("irVersion"))
+ if (typeof message.irVersion === "number")
+ object.irVersion = options.longs === String ? String(message.irVersion) : message.irVersion;
+ else
+ object.irVersion = options.longs === String ? $util.Long.prototype.toString.call(message.irVersion) : options.longs === Number ? new $util.LongBits(message.irVersion.low >>> 0, message.irVersion.high >>> 0).toNumber() : message.irVersion;
+ if (message.producerName != null && message.hasOwnProperty("producerName"))
+ object.producerName = message.producerName;
+ if (message.producerVersion != null && message.hasOwnProperty("producerVersion"))
+ object.producerVersion = message.producerVersion;
+ if (message.domain != null && message.hasOwnProperty("domain"))
+ object.domain = message.domain;
+ if (message.modelVersion != null && message.hasOwnProperty("modelVersion"))
+ if (typeof message.modelVersion === "number")
+ object.modelVersion = options.longs === String ? String(message.modelVersion) : message.modelVersion;
+ else
+ object.modelVersion = options.longs === String ? $util.Long.prototype.toString.call(message.modelVersion) : options.longs === Number ? new $util.LongBits(message.modelVersion.low >>> 0, message.modelVersion.high >>> 0).toNumber() : message.modelVersion;
+ if (message.docString != null && message.hasOwnProperty("docString"))
+ object.docString = message.docString;
+ if (message.graph != null && message.hasOwnProperty("graph"))
+ object.graph = $root.onnx.GraphProto.toObject(message.graph, options);
+ if (message.opsetImport && message.opsetImport.length) {
+ object.opsetImport = [];
+ for (var j = 0; j < message.opsetImport.length; ++j)
+ object.opsetImport[j] = $root.onnx.OperatorSetIdProto.toObject(message.opsetImport[j], options);
+ }
+ if (message.metadataProps && message.metadataProps.length) {
+ object.metadataProps = [];
+ for (var j = 0; j < message.metadataProps.length; ++j)
+ object.metadataProps[j] = $root.onnx.StringStringEntryProto.toObject(message.metadataProps[j], options);
+ }
+ if (message.trainingInfo && message.trainingInfo.length) {
+ object.trainingInfo = [];
+ for (var j = 0; j < message.trainingInfo.length; ++j)
+ object.trainingInfo[j] = $root.onnx.TrainingInfoProto.toObject(message.trainingInfo[j], options);
+ }
+ if (message.functions && message.functions.length) {
+ object.functions = [];
+ for (var j = 0; j < message.functions.length; ++j)
+ object.functions[j] = $root.onnx.FunctionProto.toObject(message.functions[j], options);
+ }
+ return object;
+ };
+
+ /**
+ * Converts this ModelProto to JSON.
+ * @function toJSON
+ * @memberof onnx.ModelProto
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ ModelProto.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for ModelProto
+ * @function getTypeUrl
+ * @memberof onnx.ModelProto
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ ModelProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.ModelProto";
+ };
+
+ return ModelProto;
+ })();
+
+ onnx.StringStringEntryProto = (function() {
+
+ /**
+ * Properties of a StringStringEntryProto.
+ * @memberof onnx
+ * @interface IStringStringEntryProto
+ * @property {string|null} [key] StringStringEntryProto key
+ * @property {string|null} [value] StringStringEntryProto value
+ */
+
+ /**
+ * Constructs a new StringStringEntryProto.
+ * @memberof onnx
+ * @classdesc Represents a StringStringEntryProto.
+ * @implements IStringStringEntryProto
+ * @constructor
+ * @param {onnx.IStringStringEntryProto=} [properties] Properties to set
+ */
+ function StringStringEntryProto(properties) {
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * StringStringEntryProto key.
+ * @member {string} key
+ * @memberof onnx.StringStringEntryProto
+ * @instance
+ */
+ StringStringEntryProto.prototype.key = "";
+
+ /**
+ * StringStringEntryProto value.
+ * @member {string} value
+ * @memberof onnx.StringStringEntryProto
+ * @instance
+ */
+ StringStringEntryProto.prototype.value = "";
+
+ /**
+ * Creates a new StringStringEntryProto instance using the specified properties.
+ * @function create
+ * @memberof onnx.StringStringEntryProto
+ * @static
+ * @param {onnx.IStringStringEntryProto=} [properties] Properties to set
+ * @returns {onnx.StringStringEntryProto} StringStringEntryProto instance
+ */
+ StringStringEntryProto.create = function create(properties) {
+ return new StringStringEntryProto(properties);
+ };
+
+ /**
+ * Encodes the specified StringStringEntryProto message. Does not implicitly {@link onnx.StringStringEntryProto.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.StringStringEntryProto
+ * @static
+ * @param {onnx.IStringStringEntryProto} message StringStringEntryProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ StringStringEntryProto.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.key != null && Object.hasOwnProperty.call(message, "key"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.key);
+ if (message.value != null && Object.hasOwnProperty.call(message, "value"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.value);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified StringStringEntryProto message, length delimited. Does not implicitly {@link onnx.StringStringEntryProto.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.StringStringEntryProto
+ * @static
+ * @param {onnx.IStringStringEntryProto} message StringStringEntryProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ StringStringEntryProto.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a StringStringEntryProto message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.StringStringEntryProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.StringStringEntryProto} StringStringEntryProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ StringStringEntryProto.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.StringStringEntryProto();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.key = reader.string();
+ break;
+ }
+ case 2: {
+ message.value = reader.string();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a StringStringEntryProto message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.StringStringEntryProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.StringStringEntryProto} StringStringEntryProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ StringStringEntryProto.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a StringStringEntryProto message.
+ * @function verify
+ * @memberof onnx.StringStringEntryProto
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ StringStringEntryProto.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.key != null && message.hasOwnProperty("key"))
+ if (!$util.isString(message.key))
+ return "key: string expected";
+ if (message.value != null && message.hasOwnProperty("value"))
+ if (!$util.isString(message.value))
+ return "value: string expected";
+ return null;
+ };
+
+ /**
+ * Creates a StringStringEntryProto message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.StringStringEntryProto
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.StringStringEntryProto} StringStringEntryProto
+ */
+ StringStringEntryProto.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.StringStringEntryProto)
+ return object;
+ var message = new $root.onnx.StringStringEntryProto();
+ if (object.key != null)
+ message.key = String(object.key);
+ if (object.value != null)
+ message.value = String(object.value);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a StringStringEntryProto message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.StringStringEntryProto
+ * @static
+ * @param {onnx.StringStringEntryProto} message StringStringEntryProto
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ StringStringEntryProto.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.defaults) {
+ object.key = "";
+ object.value = "";
+ }
+ if (message.key != null && message.hasOwnProperty("key"))
+ object.key = message.key;
+ if (message.value != null && message.hasOwnProperty("value"))
+ object.value = message.value;
+ return object;
+ };
+
+ /**
+ * Converts this StringStringEntryProto to JSON.
+ * @function toJSON
+ * @memberof onnx.StringStringEntryProto
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ StringStringEntryProto.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for StringStringEntryProto
+ * @function getTypeUrl
+ * @memberof onnx.StringStringEntryProto
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ StringStringEntryProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.StringStringEntryProto";
+ };
+
+ return StringStringEntryProto;
+ })();
+
+ onnx.TensorAnnotation = (function() {
+
+ /**
+ * Properties of a TensorAnnotation.
+ * @memberof onnx
+ * @interface ITensorAnnotation
+ * @property {string|null} [tensorName] TensorAnnotation tensorName
+ * @property {Array.|null} [quantParameterTensorNames] TensorAnnotation quantParameterTensorNames
+ */
+
+ /**
+ * Constructs a new TensorAnnotation.
+ * @memberof onnx
+ * @classdesc Represents a TensorAnnotation.
+ * @implements ITensorAnnotation
+ * @constructor
+ * @param {onnx.ITensorAnnotation=} [properties] Properties to set
+ */
+ function TensorAnnotation(properties) {
+ this.quantParameterTensorNames = [];
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * TensorAnnotation tensorName.
+ * @member {string} tensorName
+ * @memberof onnx.TensorAnnotation
+ * @instance
+ */
+ TensorAnnotation.prototype.tensorName = "";
+
+ /**
+ * TensorAnnotation quantParameterTensorNames.
+ * @member {Array.} quantParameterTensorNames
+ * @memberof onnx.TensorAnnotation
+ * @instance
+ */
+ TensorAnnotation.prototype.quantParameterTensorNames = $util.emptyArray;
+
+ /**
+ * Creates a new TensorAnnotation instance using the specified properties.
+ * @function create
+ * @memberof onnx.TensorAnnotation
+ * @static
+ * @param {onnx.ITensorAnnotation=} [properties] Properties to set
+ * @returns {onnx.TensorAnnotation} TensorAnnotation instance
+ */
+ TensorAnnotation.create = function create(properties) {
+ return new TensorAnnotation(properties);
+ };
+
+ /**
+ * Encodes the specified TensorAnnotation message. Does not implicitly {@link onnx.TensorAnnotation.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.TensorAnnotation
+ * @static
+ * @param {onnx.ITensorAnnotation} message TensorAnnotation message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ TensorAnnotation.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.tensorName != null && Object.hasOwnProperty.call(message, "tensorName"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.tensorName);
+ if (message.quantParameterTensorNames != null && message.quantParameterTensorNames.length)
+ for (var i = 0; i < message.quantParameterTensorNames.length; ++i)
+ $root.onnx.StringStringEntryProto.encode(message.quantParameterTensorNames[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
+ return writer;
+ };
+
+ /**
+ * Encodes the specified TensorAnnotation message, length delimited. Does not implicitly {@link onnx.TensorAnnotation.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.TensorAnnotation
+ * @static
+ * @param {onnx.ITensorAnnotation} message TensorAnnotation message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ TensorAnnotation.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a TensorAnnotation message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.TensorAnnotation
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.TensorAnnotation} TensorAnnotation
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ TensorAnnotation.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.TensorAnnotation();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.tensorName = reader.string();
+ break;
+ }
+ case 2: {
+ if (!(message.quantParameterTensorNames && message.quantParameterTensorNames.length))
+ message.quantParameterTensorNames = [];
+ message.quantParameterTensorNames.push($root.onnx.StringStringEntryProto.decode(reader, reader.uint32()));
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a TensorAnnotation message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.TensorAnnotation
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.TensorAnnotation} TensorAnnotation
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ TensorAnnotation.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a TensorAnnotation message.
+ * @function verify
+ * @memberof onnx.TensorAnnotation
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ TensorAnnotation.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.tensorName != null && message.hasOwnProperty("tensorName"))
+ if (!$util.isString(message.tensorName))
+ return "tensorName: string expected";
+ if (message.quantParameterTensorNames != null && message.hasOwnProperty("quantParameterTensorNames")) {
+ if (!Array.isArray(message.quantParameterTensorNames))
+ return "quantParameterTensorNames: array expected";
+ for (var i = 0; i < message.quantParameterTensorNames.length; ++i) {
+ var error = $root.onnx.StringStringEntryProto.verify(message.quantParameterTensorNames[i]);
+ if (error)
+ return "quantParameterTensorNames." + error;
+ }
+ }
+ return null;
+ };
+
+ /**
+ * Creates a TensorAnnotation message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.TensorAnnotation
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.TensorAnnotation} TensorAnnotation
+ */
+ TensorAnnotation.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.TensorAnnotation)
+ return object;
+ var message = new $root.onnx.TensorAnnotation();
+ if (object.tensorName != null)
+ message.tensorName = String(object.tensorName);
+ if (object.quantParameterTensorNames) {
+ if (!Array.isArray(object.quantParameterTensorNames))
+ throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");
+ message.quantParameterTensorNames = [];
+ for (var i = 0; i < object.quantParameterTensorNames.length; ++i) {
+ if (typeof object.quantParameterTensorNames[i] !== "object")
+ throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");
+ message.quantParameterTensorNames[i] = $root.onnx.StringStringEntryProto.fromObject(object.quantParameterTensorNames[i]);
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a TensorAnnotation message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.TensorAnnotation
+ * @static
+ * @param {onnx.TensorAnnotation} message TensorAnnotation
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ TensorAnnotation.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.arrays || options.defaults)
+ object.quantParameterTensorNames = [];
+ if (options.defaults)
+ object.tensorName = "";
+ if (message.tensorName != null && message.hasOwnProperty("tensorName"))
+ object.tensorName = message.tensorName;
+ if (message.quantParameterTensorNames && message.quantParameterTensorNames.length) {
+ object.quantParameterTensorNames = [];
+ for (var j = 0; j < message.quantParameterTensorNames.length; ++j)
+ object.quantParameterTensorNames[j] = $root.onnx.StringStringEntryProto.toObject(message.quantParameterTensorNames[j], options);
+ }
+ return object;
+ };
+
+ /**
+ * Converts this TensorAnnotation to JSON.
+ * @function toJSON
+ * @memberof onnx.TensorAnnotation
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ TensorAnnotation.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for TensorAnnotation
+ * @function getTypeUrl
+ * @memberof onnx.TensorAnnotation
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ TensorAnnotation.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.TensorAnnotation";
+ };
+
+ return TensorAnnotation;
+ })();
+
+ onnx.GraphProto = (function() {
+
+ /**
+ * Properties of a GraphProto.
+ * @memberof onnx
+ * @interface IGraphProto
+ * @property {Array.|null} [node] GraphProto node
+ * @property {string|null} [name] GraphProto name
+ * @property {Array.|null} [initializer] GraphProto initializer
+ * @property {Array.|null} [sparseInitializer] GraphProto sparseInitializer
+ * @property {string|null} [docString] GraphProto docString
+ * @property {Array.|null} [input] GraphProto input
+ * @property {Array.|null} [output] GraphProto output
+ * @property {Array.|null} [valueInfo] GraphProto valueInfo
+ * @property {Array.|null} [quantizationAnnotation] GraphProto quantizationAnnotation
+ */
+
+ /**
+ * Constructs a new GraphProto.
+ * @memberof onnx
+ * @classdesc Represents a GraphProto.
+ * @implements IGraphProto
+ * @constructor
+ * @param {onnx.IGraphProto=} [properties] Properties to set
+ */
+ function GraphProto(properties) {
+ this.node = [];
+ this.initializer = [];
+ this.sparseInitializer = [];
+ this.input = [];
+ this.output = [];
+ this.valueInfo = [];
+ this.quantizationAnnotation = [];
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * GraphProto node.
+ * @member {Array.} node
+ * @memberof onnx.GraphProto
+ * @instance
+ */
+ GraphProto.prototype.node = $util.emptyArray;
+
+ /**
+ * GraphProto name.
+ * @member {string} name
+ * @memberof onnx.GraphProto
+ * @instance
+ */
+ GraphProto.prototype.name = "";
+
+ /**
+ * GraphProto initializer.
+ * @member {Array.} initializer
+ * @memberof onnx.GraphProto
+ * @instance
+ */
+ GraphProto.prototype.initializer = $util.emptyArray;
+
+ /**
+ * GraphProto sparseInitializer.
+ * @member {Array.} sparseInitializer
+ * @memberof onnx.GraphProto
+ * @instance
+ */
+ GraphProto.prototype.sparseInitializer = $util.emptyArray;
+
+ /**
+ * GraphProto docString.
+ * @member {string} docString
+ * @memberof onnx.GraphProto
+ * @instance
+ */
+ GraphProto.prototype.docString = "";
+
+ /**
+ * GraphProto input.
+ * @member {Array.} input
+ * @memberof onnx.GraphProto
+ * @instance
+ */
+ GraphProto.prototype.input = $util.emptyArray;
+
+ /**
+ * GraphProto output.
+ * @member {Array.} output
+ * @memberof onnx.GraphProto
+ * @instance
+ */
+ GraphProto.prototype.output = $util.emptyArray;
+
+ /**
+ * GraphProto valueInfo.
+ * @member {Array.} valueInfo
+ * @memberof onnx.GraphProto
+ * @instance
+ */
+ GraphProto.prototype.valueInfo = $util.emptyArray;
+
+ /**
+ * GraphProto quantizationAnnotation.
+ * @member {Array.} quantizationAnnotation
+ * @memberof onnx.GraphProto
+ * @instance
+ */
+ GraphProto.prototype.quantizationAnnotation = $util.emptyArray;
+
+ /**
+ * Creates a new GraphProto instance using the specified properties.
+ * @function create
+ * @memberof onnx.GraphProto
+ * @static
+ * @param {onnx.IGraphProto=} [properties] Properties to set
+ * @returns {onnx.GraphProto} GraphProto instance
+ */
+ GraphProto.create = function create(properties) {
+ return new GraphProto(properties);
+ };
+
+ /**
+ * Encodes the specified GraphProto message. Does not implicitly {@link onnx.GraphProto.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.GraphProto
+ * @static
+ * @param {onnx.IGraphProto} message GraphProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ GraphProto.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.node != null && message.node.length)
+ for (var i = 0; i < message.node.length; ++i)
+ $root.onnx.NodeProto.encode(message.node[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
+ if (message.name != null && Object.hasOwnProperty.call(message, "name"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.name);
+ if (message.initializer != null && message.initializer.length)
+ for (var i = 0; i < message.initializer.length; ++i)
+ $root.onnx.TensorProto.encode(message.initializer[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim();
+ if (message.docString != null && Object.hasOwnProperty.call(message, "docString"))
+ writer.uint32(/* id 10, wireType 2 =*/82).string(message.docString);
+ if (message.input != null && message.input.length)
+ for (var i = 0; i < message.input.length; ++i)
+ $root.onnx.ValueInfoProto.encode(message.input[i], writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim();
+ if (message.output != null && message.output.length)
+ for (var i = 0; i < message.output.length; ++i)
+ $root.onnx.ValueInfoProto.encode(message.output[i], writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim();
+ if (message.valueInfo != null && message.valueInfo.length)
+ for (var i = 0; i < message.valueInfo.length; ++i)
+ $root.onnx.ValueInfoProto.encode(message.valueInfo[i], writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim();
+ if (message.quantizationAnnotation != null && message.quantizationAnnotation.length)
+ for (var i = 0; i < message.quantizationAnnotation.length; ++i)
+ $root.onnx.TensorAnnotation.encode(message.quantizationAnnotation[i], writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim();
+ if (message.sparseInitializer != null && message.sparseInitializer.length)
+ for (var i = 0; i < message.sparseInitializer.length; ++i)
+ $root.onnx.SparseTensorProto.encode(message.sparseInitializer[i], writer.uint32(/* id 15, wireType 2 =*/122).fork()).ldelim();
+ return writer;
+ };
+
+ /**
+ * Encodes the specified GraphProto message, length delimited. Does not implicitly {@link onnx.GraphProto.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.GraphProto
+ * @static
+ * @param {onnx.IGraphProto} message GraphProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ GraphProto.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a GraphProto message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.GraphProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.GraphProto} GraphProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ GraphProto.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.GraphProto();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ if (!(message.node && message.node.length))
+ message.node = [];
+ message.node.push($root.onnx.NodeProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 2: {
+ message.name = reader.string();
+ break;
+ }
+ case 5: {
+ if (!(message.initializer && message.initializer.length))
+ message.initializer = [];
+ message.initializer.push($root.onnx.TensorProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 15: {
+ if (!(message.sparseInitializer && message.sparseInitializer.length))
+ message.sparseInitializer = [];
+ message.sparseInitializer.push($root.onnx.SparseTensorProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 10: {
+ message.docString = reader.string();
+ break;
+ }
+ case 11: {
+ if (!(message.input && message.input.length))
+ message.input = [];
+ message.input.push($root.onnx.ValueInfoProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 12: {
+ if (!(message.output && message.output.length))
+ message.output = [];
+ message.output.push($root.onnx.ValueInfoProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 13: {
+ if (!(message.valueInfo && message.valueInfo.length))
+ message.valueInfo = [];
+ message.valueInfo.push($root.onnx.ValueInfoProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 14: {
+ if (!(message.quantizationAnnotation && message.quantizationAnnotation.length))
+ message.quantizationAnnotation = [];
+ message.quantizationAnnotation.push($root.onnx.TensorAnnotation.decode(reader, reader.uint32()));
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a GraphProto message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.GraphProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.GraphProto} GraphProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ GraphProto.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a GraphProto message.
+ * @function verify
+ * @memberof onnx.GraphProto
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ GraphProto.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.node != null && message.hasOwnProperty("node")) {
+ if (!Array.isArray(message.node))
+ return "node: array expected";
+ for (var i = 0; i < message.node.length; ++i) {
+ var error = $root.onnx.NodeProto.verify(message.node[i]);
+ if (error)
+ return "node." + error;
+ }
+ }
+ if (message.name != null && message.hasOwnProperty("name"))
+ if (!$util.isString(message.name))
+ return "name: string expected";
+ if (message.initializer != null && message.hasOwnProperty("initializer")) {
+ if (!Array.isArray(message.initializer))
+ return "initializer: array expected";
+ for (var i = 0; i < message.initializer.length; ++i) {
+ var error = $root.onnx.TensorProto.verify(message.initializer[i]);
+ if (error)
+ return "initializer." + error;
+ }
+ }
+ if (message.sparseInitializer != null && message.hasOwnProperty("sparseInitializer")) {
+ if (!Array.isArray(message.sparseInitializer))
+ return "sparseInitializer: array expected";
+ for (var i = 0; i < message.sparseInitializer.length; ++i) {
+ var error = $root.onnx.SparseTensorProto.verify(message.sparseInitializer[i]);
+ if (error)
+ return "sparseInitializer." + error;
+ }
+ }
+ if (message.docString != null && message.hasOwnProperty("docString"))
+ if (!$util.isString(message.docString))
+ return "docString: string expected";
+ if (message.input != null && message.hasOwnProperty("input")) {
+ if (!Array.isArray(message.input))
+ return "input: array expected";
+ for (var i = 0; i < message.input.length; ++i) {
+ var error = $root.onnx.ValueInfoProto.verify(message.input[i]);
+ if (error)
+ return "input." + error;
+ }
+ }
+ if (message.output != null && message.hasOwnProperty("output")) {
+ if (!Array.isArray(message.output))
+ return "output: array expected";
+ for (var i = 0; i < message.output.length; ++i) {
+ var error = $root.onnx.ValueInfoProto.verify(message.output[i]);
+ if (error)
+ return "output." + error;
+ }
+ }
+ if (message.valueInfo != null && message.hasOwnProperty("valueInfo")) {
+ if (!Array.isArray(message.valueInfo))
+ return "valueInfo: array expected";
+ for (var i = 0; i < message.valueInfo.length; ++i) {
+ var error = $root.onnx.ValueInfoProto.verify(message.valueInfo[i]);
+ if (error)
+ return "valueInfo." + error;
+ }
+ }
+ if (message.quantizationAnnotation != null && message.hasOwnProperty("quantizationAnnotation")) {
+ if (!Array.isArray(message.quantizationAnnotation))
+ return "quantizationAnnotation: array expected";
+ for (var i = 0; i < message.quantizationAnnotation.length; ++i) {
+ var error = $root.onnx.TensorAnnotation.verify(message.quantizationAnnotation[i]);
+ if (error)
+ return "quantizationAnnotation." + error;
+ }
+ }
+ return null;
+ };
+
+ /**
+ * Creates a GraphProto message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.GraphProto
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.GraphProto} GraphProto
+ */
+ GraphProto.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.GraphProto)
+ return object;
+ var message = new $root.onnx.GraphProto();
+ if (object.node) {
+ if (!Array.isArray(object.node))
+ throw TypeError(".onnx.GraphProto.node: array expected");
+ message.node = [];
+ for (var i = 0; i < object.node.length; ++i) {
+ if (typeof object.node[i] !== "object")
+ throw TypeError(".onnx.GraphProto.node: object expected");
+ message.node[i] = $root.onnx.NodeProto.fromObject(object.node[i]);
+ }
+ }
+ if (object.name != null)
+ message.name = String(object.name);
+ if (object.initializer) {
+ if (!Array.isArray(object.initializer))
+ throw TypeError(".onnx.GraphProto.initializer: array expected");
+ message.initializer = [];
+ for (var i = 0; i < object.initializer.length; ++i) {
+ if (typeof object.initializer[i] !== "object")
+ throw TypeError(".onnx.GraphProto.initializer: object expected");
+ message.initializer[i] = $root.onnx.TensorProto.fromObject(object.initializer[i]);
+ }
+ }
+ if (object.sparseInitializer) {
+ if (!Array.isArray(object.sparseInitializer))
+ throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");
+ message.sparseInitializer = [];
+ for (var i = 0; i < object.sparseInitializer.length; ++i) {
+ if (typeof object.sparseInitializer[i] !== "object")
+ throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");
+ message.sparseInitializer[i] = $root.onnx.SparseTensorProto.fromObject(object.sparseInitializer[i]);
+ }
+ }
+ if (object.docString != null)
+ message.docString = String(object.docString);
+ if (object.input) {
+ if (!Array.isArray(object.input))
+ throw TypeError(".onnx.GraphProto.input: array expected");
+ message.input = [];
+ for (var i = 0; i < object.input.length; ++i) {
+ if (typeof object.input[i] !== "object")
+ throw TypeError(".onnx.GraphProto.input: object expected");
+ message.input[i] = $root.onnx.ValueInfoProto.fromObject(object.input[i]);
+ }
+ }
+ if (object.output) {
+ if (!Array.isArray(object.output))
+ throw TypeError(".onnx.GraphProto.output: array expected");
+ message.output = [];
+ for (var i = 0; i < object.output.length; ++i) {
+ if (typeof object.output[i] !== "object")
+ throw TypeError(".onnx.GraphProto.output: object expected");
+ message.output[i] = $root.onnx.ValueInfoProto.fromObject(object.output[i]);
+ }
+ }
+ if (object.valueInfo) {
+ if (!Array.isArray(object.valueInfo))
+ throw TypeError(".onnx.GraphProto.valueInfo: array expected");
+ message.valueInfo = [];
+ for (var i = 0; i < object.valueInfo.length; ++i) {
+ if (typeof object.valueInfo[i] !== "object")
+ throw TypeError(".onnx.GraphProto.valueInfo: object expected");
+ message.valueInfo[i] = $root.onnx.ValueInfoProto.fromObject(object.valueInfo[i]);
+ }
+ }
+ if (object.quantizationAnnotation) {
+ if (!Array.isArray(object.quantizationAnnotation))
+ throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");
+ message.quantizationAnnotation = [];
+ for (var i = 0; i < object.quantizationAnnotation.length; ++i) {
+ if (typeof object.quantizationAnnotation[i] !== "object")
+ throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");
+ message.quantizationAnnotation[i] = $root.onnx.TensorAnnotation.fromObject(object.quantizationAnnotation[i]);
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a GraphProto message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.GraphProto
+ * @static
+ * @param {onnx.GraphProto} message GraphProto
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ GraphProto.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.arrays || options.defaults) {
+ object.node = [];
+ object.initializer = [];
+ object.input = [];
+ object.output = [];
+ object.valueInfo = [];
+ object.quantizationAnnotation = [];
+ object.sparseInitializer = [];
+ }
+ if (options.defaults) {
+ object.name = "";
+ object.docString = "";
+ }
+ if (message.node && message.node.length) {
+ object.node = [];
+ for (var j = 0; j < message.node.length; ++j)
+ object.node[j] = $root.onnx.NodeProto.toObject(message.node[j], options);
+ }
+ if (message.name != null && message.hasOwnProperty("name"))
+ object.name = message.name;
+ if (message.initializer && message.initializer.length) {
+ object.initializer = [];
+ for (var j = 0; j < message.initializer.length; ++j)
+ object.initializer[j] = $root.onnx.TensorProto.toObject(message.initializer[j], options);
+ }
+ if (message.docString != null && message.hasOwnProperty("docString"))
+ object.docString = message.docString;
+ if (message.input && message.input.length) {
+ object.input = [];
+ for (var j = 0; j < message.input.length; ++j)
+ object.input[j] = $root.onnx.ValueInfoProto.toObject(message.input[j], options);
+ }
+ if (message.output && message.output.length) {
+ object.output = [];
+ for (var j = 0; j < message.output.length; ++j)
+ object.output[j] = $root.onnx.ValueInfoProto.toObject(message.output[j], options);
+ }
+ if (message.valueInfo && message.valueInfo.length) {
+ object.valueInfo = [];
+ for (var j = 0; j < message.valueInfo.length; ++j)
+ object.valueInfo[j] = $root.onnx.ValueInfoProto.toObject(message.valueInfo[j], options);
+ }
+ if (message.quantizationAnnotation && message.quantizationAnnotation.length) {
+ object.quantizationAnnotation = [];
+ for (var j = 0; j < message.quantizationAnnotation.length; ++j)
+ object.quantizationAnnotation[j] = $root.onnx.TensorAnnotation.toObject(message.quantizationAnnotation[j], options);
+ }
+ if (message.sparseInitializer && message.sparseInitializer.length) {
+ object.sparseInitializer = [];
+ for (var j = 0; j < message.sparseInitializer.length; ++j)
+ object.sparseInitializer[j] = $root.onnx.SparseTensorProto.toObject(message.sparseInitializer[j], options);
+ }
+ return object;
+ };
+
+ /**
+ * Converts this GraphProto to JSON.
+ * @function toJSON
+ * @memberof onnx.GraphProto
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ GraphProto.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for GraphProto
+ * @function getTypeUrl
+ * @memberof onnx.GraphProto
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ GraphProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.GraphProto";
+ };
+
+ return GraphProto;
+ })();
+
+ onnx.TensorProto = (function() {
+
+ /**
+ * Properties of a TensorProto.
+ * @memberof onnx
+ * @interface ITensorProto
+ * @property {Array.|null} [dims] TensorProto dims
+ * @property {number|null} [dataType] TensorProto dataType
+ * @property {onnx.TensorProto.ISegment|null} [segment] TensorProto segment
+ * @property {Array.|null} [floatData] TensorProto floatData
+ * @property {Array.|null} [int32Data] TensorProto int32Data
+ * @property {Array.|null} [stringData] TensorProto stringData
+ * @property {Array.|null} [int64Data] TensorProto int64Data
+ * @property {string|null} [name] TensorProto name
+ * @property {string|null} [docString] TensorProto docString
+ * @property {Uint8Array|null} [rawData] TensorProto rawData
+ * @property {Array.|null} [externalData] TensorProto externalData
+ * @property {onnx.TensorProto.DataLocation|null} [dataLocation] TensorProto dataLocation
+ * @property {Array.|null} [doubleData] TensorProto doubleData
+ * @property {Array.|null} [uint64Data] TensorProto uint64Data
+ */
+
+ /**
+ * Constructs a new TensorProto.
+ * @memberof onnx
+ * @classdesc Represents a TensorProto.
+ * @implements ITensorProto
+ * @constructor
+ * @param {onnx.ITensorProto=} [properties] Properties to set
+ */
+ function TensorProto(properties) {
+ this.dims = [];
+ this.floatData = [];
+ this.int32Data = [];
+ this.stringData = [];
+ this.int64Data = [];
+ this.externalData = [];
+ this.doubleData = [];
+ this.uint64Data = [];
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * TensorProto dims.
+ * @member {Array.} dims
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.dims = $util.emptyArray;
+
+ /**
+ * TensorProto dataType.
+ * @member {number} dataType
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.dataType = 0;
+
+ /**
+ * TensorProto segment.
+ * @member {onnx.TensorProto.ISegment|null|undefined} segment
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.segment = null;
+
+ /**
+ * TensorProto floatData.
+ * @member {Array.} floatData
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.floatData = $util.emptyArray;
+
+ /**
+ * TensorProto int32Data.
+ * @member {Array.} int32Data
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.int32Data = $util.emptyArray;
+
+ /**
+ * TensorProto stringData.
+ * @member {Array.} stringData
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.stringData = $util.emptyArray;
+
+ /**
+ * TensorProto int64Data.
+ * @member {Array.} int64Data
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.int64Data = $util.emptyArray;
+
+ /**
+ * TensorProto name.
+ * @member {string} name
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.name = "";
+
+ /**
+ * TensorProto docString.
+ * @member {string} docString
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.docString = "";
+
+ /**
+ * TensorProto rawData.
+ * @member {Uint8Array} rawData
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.rawData = $util.newBuffer([]);
+
+ /**
+ * TensorProto externalData.
+ * @member {Array.} externalData
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.externalData = $util.emptyArray;
+
+ /**
+ * TensorProto dataLocation.
+ * @member {onnx.TensorProto.DataLocation} dataLocation
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.dataLocation = 0;
+
+ /**
+ * TensorProto doubleData.
+ * @member {Array.} doubleData
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.doubleData = $util.emptyArray;
+
+ /**
+ * TensorProto uint64Data.
+ * @member {Array.} uint64Data
+ * @memberof onnx.TensorProto
+ * @instance
+ */
+ TensorProto.prototype.uint64Data = $util.emptyArray;
+
+ /**
+ * Creates a new TensorProto instance using the specified properties.
+ * @function create
+ * @memberof onnx.TensorProto
+ * @static
+ * @param {onnx.ITensorProto=} [properties] Properties to set
+ * @returns {onnx.TensorProto} TensorProto instance
+ */
+ TensorProto.create = function create(properties) {
+ return new TensorProto(properties);
+ };
+
+ /**
+ * Encodes the specified TensorProto message. Does not implicitly {@link onnx.TensorProto.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.TensorProto
+ * @static
+ * @param {onnx.ITensorProto} message TensorProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ TensorProto.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.dims != null && message.dims.length) {
+ writer.uint32(/* id 1, wireType 2 =*/10).fork();
+ for (var i = 0; i < message.dims.length; ++i)
+ writer.int64(message.dims[i]);
+ writer.ldelim();
+ }
+ if (message.dataType != null && Object.hasOwnProperty.call(message, "dataType"))
+ writer.uint32(/* id 2, wireType 0 =*/16).int32(message.dataType);
+ if (message.segment != null && Object.hasOwnProperty.call(message, "segment"))
+ $root.onnx.TensorProto.Segment.encode(message.segment, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
+ if (message.floatData != null && message.floatData.length) {
+ writer.uint32(/* id 4, wireType 2 =*/34).fork();
+ for (var i = 0; i < message.floatData.length; ++i)
+ writer.float(message.floatData[i]);
+ writer.ldelim();
+ }
+ if (message.int32Data != null && message.int32Data.length) {
+ writer.uint32(/* id 5, wireType 2 =*/42).fork();
+ for (var i = 0; i < message.int32Data.length; ++i)
+ writer.int32(message.int32Data[i]);
+ writer.ldelim();
+ }
+ if (message.stringData != null && message.stringData.length)
+ for (var i = 0; i < message.stringData.length; ++i)
+ writer.uint32(/* id 6, wireType 2 =*/50).bytes(message.stringData[i]);
+ if (message.int64Data != null && message.int64Data.length) {
+ writer.uint32(/* id 7, wireType 2 =*/58).fork();
+ for (var i = 0; i < message.int64Data.length; ++i)
+ writer.int64(message.int64Data[i]);
+ writer.ldelim();
+ }
+ if (message.name != null && Object.hasOwnProperty.call(message, "name"))
+ writer.uint32(/* id 8, wireType 2 =*/66).string(message.name);
+ if (message.rawData != null && Object.hasOwnProperty.call(message, "rawData"))
+ writer.uint32(/* id 9, wireType 2 =*/74).bytes(message.rawData);
+ if (message.doubleData != null && message.doubleData.length) {
+ writer.uint32(/* id 10, wireType 2 =*/82).fork();
+ for (var i = 0; i < message.doubleData.length; ++i)
+ writer.double(message.doubleData[i]);
+ writer.ldelim();
+ }
+ if (message.uint64Data != null && message.uint64Data.length) {
+ writer.uint32(/* id 11, wireType 2 =*/90).fork();
+ for (var i = 0; i < message.uint64Data.length; ++i)
+ writer.uint64(message.uint64Data[i]);
+ writer.ldelim();
+ }
+ if (message.docString != null && Object.hasOwnProperty.call(message, "docString"))
+ writer.uint32(/* id 12, wireType 2 =*/98).string(message.docString);
+ if (message.externalData != null && message.externalData.length)
+ for (var i = 0; i < message.externalData.length; ++i)
+ $root.onnx.StringStringEntryProto.encode(message.externalData[i], writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim();
+ if (message.dataLocation != null && Object.hasOwnProperty.call(message, "dataLocation"))
+ writer.uint32(/* id 14, wireType 0 =*/112).int32(message.dataLocation);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified TensorProto message, length delimited. Does not implicitly {@link onnx.TensorProto.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.TensorProto
+ * @static
+ * @param {onnx.ITensorProto} message TensorProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ TensorProto.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a TensorProto message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.TensorProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.TensorProto} TensorProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ TensorProto.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.TensorProto();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ if (!(message.dims && message.dims.length))
+ message.dims = [];
+ if ((tag & 7) === 2) {
+ var end2 = reader.uint32() + reader.pos;
+ while (reader.pos < end2)
+ message.dims.push(reader.int64());
+ } else
+ message.dims.push(reader.int64());
+ break;
+ }
+ case 2: {
+ message.dataType = reader.int32();
+ break;
+ }
+ case 3: {
+ message.segment = $root.onnx.TensorProto.Segment.decode(reader, reader.uint32());
+ break;
+ }
+ case 4: {
+ if (!(message.floatData && message.floatData.length))
+ message.floatData = [];
+ if ((tag & 7) === 2) {
+ var end2 = reader.uint32() + reader.pos;
+ while (reader.pos < end2)
+ message.floatData.push(reader.float());
+ } else
+ message.floatData.push(reader.float());
+ break;
+ }
+ case 5: {
+ if (!(message.int32Data && message.int32Data.length))
+ message.int32Data = [];
+ if ((tag & 7) === 2) {
+ var end2 = reader.uint32() + reader.pos;
+ while (reader.pos < end2)
+ message.int32Data.push(reader.int32());
+ } else
+ message.int32Data.push(reader.int32());
+ break;
+ }
+ case 6: {
+ if (!(message.stringData && message.stringData.length))
+ message.stringData = [];
+ message.stringData.push(reader.bytes());
+ break;
+ }
+ case 7: {
+ if (!(message.int64Data && message.int64Data.length))
+ message.int64Data = [];
+ if ((tag & 7) === 2) {
+ var end2 = reader.uint32() + reader.pos;
+ while (reader.pos < end2)
+ message.int64Data.push(reader.int64());
+ } else
+ message.int64Data.push(reader.int64());
+ break;
+ }
+ case 8: {
+ message.name = reader.string();
+ break;
+ }
+ case 12: {
+ message.docString = reader.string();
+ break;
+ }
+ case 9: {
+ message.rawData = reader.bytes();
+ break;
+ }
+ case 13: {
+ if (!(message.externalData && message.externalData.length))
+ message.externalData = [];
+ message.externalData.push($root.onnx.StringStringEntryProto.decode(reader, reader.uint32()));
+ break;
+ }
+ case 14: {
+ message.dataLocation = reader.int32();
+ break;
+ }
+ case 10: {
+ if (!(message.doubleData && message.doubleData.length))
+ message.doubleData = [];
+ if ((tag & 7) === 2) {
+ var end2 = reader.uint32() + reader.pos;
+ while (reader.pos < end2)
+ message.doubleData.push(reader.double());
+ } else
+ message.doubleData.push(reader.double());
+ break;
+ }
+ case 11: {
+ if (!(message.uint64Data && message.uint64Data.length))
+ message.uint64Data = [];
+ if ((tag & 7) === 2) {
+ var end2 = reader.uint32() + reader.pos;
+ while (reader.pos < end2)
+ message.uint64Data.push(reader.uint64());
+ } else
+ message.uint64Data.push(reader.uint64());
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a TensorProto message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.TensorProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.TensorProto} TensorProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ TensorProto.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a TensorProto message.
+ * @function verify
+ * @memberof onnx.TensorProto
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ TensorProto.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.dims != null && message.hasOwnProperty("dims")) {
+ if (!Array.isArray(message.dims))
+ return "dims: array expected";
+ for (var i = 0; i < message.dims.length; ++i)
+ if (!$util.isInteger(message.dims[i]) && !(message.dims[i] && $util.isInteger(message.dims[i].low) && $util.isInteger(message.dims[i].high)))
+ return "dims: integer|Long[] expected";
+ }
+ if (message.dataType != null && message.hasOwnProperty("dataType"))
+ if (!$util.isInteger(message.dataType))
+ return "dataType: integer expected";
+ if (message.segment != null && message.hasOwnProperty("segment")) {
+ var error = $root.onnx.TensorProto.Segment.verify(message.segment);
+ if (error)
+ return "segment." + error;
+ }
+ if (message.floatData != null && message.hasOwnProperty("floatData")) {
+ if (!Array.isArray(message.floatData))
+ return "floatData: array expected";
+ for (var i = 0; i < message.floatData.length; ++i)
+ if (typeof message.floatData[i] !== "number")
+ return "floatData: number[] expected";
+ }
+ if (message.int32Data != null && message.hasOwnProperty("int32Data")) {
+ if (!Array.isArray(message.int32Data))
+ return "int32Data: array expected";
+ for (var i = 0; i < message.int32Data.length; ++i)
+ if (!$util.isInteger(message.int32Data[i]))
+ return "int32Data: integer[] expected";
+ }
+ if (message.stringData != null && message.hasOwnProperty("stringData")) {
+ if (!Array.isArray(message.stringData))
+ return "stringData: array expected";
+ for (var i = 0; i < message.stringData.length; ++i)
+ if (!(message.stringData[i] && typeof message.stringData[i].length === "number" || $util.isString(message.stringData[i])))
+ return "stringData: buffer[] expected";
+ }
+ if (message.int64Data != null && message.hasOwnProperty("int64Data")) {
+ if (!Array.isArray(message.int64Data))
+ return "int64Data: array expected";
+ for (var i = 0; i < message.int64Data.length; ++i)
+ if (!$util.isInteger(message.int64Data[i]) && !(message.int64Data[i] && $util.isInteger(message.int64Data[i].low) && $util.isInteger(message.int64Data[i].high)))
+ return "int64Data: integer|Long[] expected";
+ }
+ if (message.name != null && message.hasOwnProperty("name"))
+ if (!$util.isString(message.name))
+ return "name: string expected";
+ if (message.docString != null && message.hasOwnProperty("docString"))
+ if (!$util.isString(message.docString))
+ return "docString: string expected";
+ if (message.rawData != null && message.hasOwnProperty("rawData"))
+ if (!(message.rawData && typeof message.rawData.length === "number" || $util.isString(message.rawData)))
+ return "rawData: buffer expected";
+ if (message.externalData != null && message.hasOwnProperty("externalData")) {
+ if (!Array.isArray(message.externalData))
+ return "externalData: array expected";
+ for (var i = 0; i < message.externalData.length; ++i) {
+ var error = $root.onnx.StringStringEntryProto.verify(message.externalData[i]);
+ if (error)
+ return "externalData." + error;
+ }
+ }
+ if (message.dataLocation != null && message.hasOwnProperty("dataLocation"))
+ switch (message.dataLocation) {
+ default:
+ return "dataLocation: enum value expected";
+ case 0:
+ case 1:
+ break;
+ }
+ if (message.doubleData != null && message.hasOwnProperty("doubleData")) {
+ if (!Array.isArray(message.doubleData))
+ return "doubleData: array expected";
+ for (var i = 0; i < message.doubleData.length; ++i)
+ if (typeof message.doubleData[i] !== "number")
+ return "doubleData: number[] expected";
+ }
+ if (message.uint64Data != null && message.hasOwnProperty("uint64Data")) {
+ if (!Array.isArray(message.uint64Data))
+ return "uint64Data: array expected";
+ for (var i = 0; i < message.uint64Data.length; ++i)
+ if (!$util.isInteger(message.uint64Data[i]) && !(message.uint64Data[i] && $util.isInteger(message.uint64Data[i].low) && $util.isInteger(message.uint64Data[i].high)))
+ return "uint64Data: integer|Long[] expected";
+ }
+ return null;
+ };
+
+ /**
+ * Creates a TensorProto message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.TensorProto
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.TensorProto} TensorProto
+ */
+ TensorProto.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.TensorProto)
+ return object;
+ var message = new $root.onnx.TensorProto();
+ if (object.dims) {
+ if (!Array.isArray(object.dims))
+ throw TypeError(".onnx.TensorProto.dims: array expected");
+ message.dims = [];
+ for (var i = 0; i < object.dims.length; ++i)
+ if ($util.Long)
+ (message.dims[i] = $util.Long.fromValue(object.dims[i])).unsigned = false;
+ else if (typeof object.dims[i] === "string")
+ message.dims[i] = parseInt(object.dims[i], 10);
+ else if (typeof object.dims[i] === "number")
+ message.dims[i] = object.dims[i];
+ else if (typeof object.dims[i] === "object")
+ message.dims[i] = new $util.LongBits(object.dims[i].low >>> 0, object.dims[i].high >>> 0).toNumber();
+ }
+ if (object.dataType != null)
+ message.dataType = object.dataType | 0;
+ if (object.segment != null) {
+ if (typeof object.segment !== "object")
+ throw TypeError(".onnx.TensorProto.segment: object expected");
+ message.segment = $root.onnx.TensorProto.Segment.fromObject(object.segment);
+ }
+ if (object.floatData) {
+ if (!Array.isArray(object.floatData))
+ throw TypeError(".onnx.TensorProto.floatData: array expected");
+ message.floatData = [];
+ for (var i = 0; i < object.floatData.length; ++i)
+ message.floatData[i] = Number(object.floatData[i]);
+ }
+ if (object.int32Data) {
+ if (!Array.isArray(object.int32Data))
+ throw TypeError(".onnx.TensorProto.int32Data: array expected");
+ message.int32Data = [];
+ for (var i = 0; i < object.int32Data.length; ++i)
+ message.int32Data[i] = object.int32Data[i] | 0;
+ }
+ if (object.stringData) {
+ if (!Array.isArray(object.stringData))
+ throw TypeError(".onnx.TensorProto.stringData: array expected");
+ message.stringData = [];
+ for (var i = 0; i < object.stringData.length; ++i)
+ if (typeof object.stringData[i] === "string")
+ $util.base64.decode(object.stringData[i], message.stringData[i] = $util.newBuffer($util.base64.length(object.stringData[i])), 0);
+ else if (object.stringData[i].length >= 0)
+ message.stringData[i] = object.stringData[i];
+ }
+ if (object.int64Data) {
+ if (!Array.isArray(object.int64Data))
+ throw TypeError(".onnx.TensorProto.int64Data: array expected");
+ message.int64Data = [];
+ for (var i = 0; i < object.int64Data.length; ++i)
+ if ($util.Long)
+ (message.int64Data[i] = $util.Long.fromValue(object.int64Data[i])).unsigned = false;
+ else if (typeof object.int64Data[i] === "string")
+ message.int64Data[i] = parseInt(object.int64Data[i], 10);
+ else if (typeof object.int64Data[i] === "number")
+ message.int64Data[i] = object.int64Data[i];
+ else if (typeof object.int64Data[i] === "object")
+ message.int64Data[i] = new $util.LongBits(object.int64Data[i].low >>> 0, object.int64Data[i].high >>> 0).toNumber();
+ }
+ if (object.name != null)
+ message.name = String(object.name);
+ if (object.docString != null)
+ message.docString = String(object.docString);
+ if (object.rawData != null)
+ if (typeof object.rawData === "string")
+ $util.base64.decode(object.rawData, message.rawData = $util.newBuffer($util.base64.length(object.rawData)), 0);
+ else if (object.rawData.length >= 0)
+ message.rawData = object.rawData;
+ if (object.externalData) {
+ if (!Array.isArray(object.externalData))
+ throw TypeError(".onnx.TensorProto.externalData: array expected");
+ message.externalData = [];
+ for (var i = 0; i < object.externalData.length; ++i) {
+ if (typeof object.externalData[i] !== "object")
+ throw TypeError(".onnx.TensorProto.externalData: object expected");
+ message.externalData[i] = $root.onnx.StringStringEntryProto.fromObject(object.externalData[i]);
+ }
+ }
+ switch (object.dataLocation) {
+ default:
+ if (typeof object.dataLocation === "number") {
+ message.dataLocation = object.dataLocation;
+ break;
+ }
+ break;
+ case "DEFAULT":
+ case 0:
+ message.dataLocation = 0;
+ break;
+ case "EXTERNAL":
+ case 1:
+ message.dataLocation = 1;
+ break;
+ }
+ if (object.doubleData) {
+ if (!Array.isArray(object.doubleData))
+ throw TypeError(".onnx.TensorProto.doubleData: array expected");
+ message.doubleData = [];
+ for (var i = 0; i < object.doubleData.length; ++i)
+ message.doubleData[i] = Number(object.doubleData[i]);
+ }
+ if (object.uint64Data) {
+ if (!Array.isArray(object.uint64Data))
+ throw TypeError(".onnx.TensorProto.uint64Data: array expected");
+ message.uint64Data = [];
+ for (var i = 0; i < object.uint64Data.length; ++i)
+ if ($util.Long)
+ (message.uint64Data[i] = $util.Long.fromValue(object.uint64Data[i])).unsigned = true;
+ else if (typeof object.uint64Data[i] === "string")
+ message.uint64Data[i] = parseInt(object.uint64Data[i], 10);
+ else if (typeof object.uint64Data[i] === "number")
+ message.uint64Data[i] = object.uint64Data[i];
+ else if (typeof object.uint64Data[i] === "object")
+ message.uint64Data[i] = new $util.LongBits(object.uint64Data[i].low >>> 0, object.uint64Data[i].high >>> 0).toNumber(true);
+ }
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a TensorProto message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.TensorProto
+ * @static
+ * @param {onnx.TensorProto} message TensorProto
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ TensorProto.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.arrays || options.defaults) {
+ object.dims = [];
+ object.floatData = [];
+ object.int32Data = [];
+ object.stringData = [];
+ object.int64Data = [];
+ object.doubleData = [];
+ object.uint64Data = [];
+ object.externalData = [];
+ }
+ if (options.defaults) {
+ object.dataType = 0;
+ object.segment = null;
+ object.name = "";
+ if (options.bytes === String)
+ object.rawData = "";
+ else {
+ object.rawData = [];
+ if (options.bytes !== Array)
+ object.rawData = $util.newBuffer(object.rawData);
+ }
+ object.docString = "";
+ object.dataLocation = options.enums === String ? "DEFAULT" : 0;
+ }
+ if (message.dims && message.dims.length) {
+ object.dims = [];
+ for (var j = 0; j < message.dims.length; ++j)
+ if (typeof message.dims[j] === "number")
+ object.dims[j] = options.longs === String ? String(message.dims[j]) : message.dims[j];
+ else
+ object.dims[j] = options.longs === String ? $util.Long.prototype.toString.call(message.dims[j]) : options.longs === Number ? new $util.LongBits(message.dims[j].low >>> 0, message.dims[j].high >>> 0).toNumber() : message.dims[j];
+ }
+ if (message.dataType != null && message.hasOwnProperty("dataType"))
+ object.dataType = message.dataType;
+ if (message.segment != null && message.hasOwnProperty("segment"))
+ object.segment = $root.onnx.TensorProto.Segment.toObject(message.segment, options);
+ if (message.floatData && message.floatData.length) {
+ object.floatData = [];
+ for (var j = 0; j < message.floatData.length; ++j)
+ object.floatData[j] = options.json && !isFinite(message.floatData[j]) ? String(message.floatData[j]) : message.floatData[j];
+ }
+ if (message.int32Data && message.int32Data.length) {
+ object.int32Data = [];
+ for (var j = 0; j < message.int32Data.length; ++j)
+ object.int32Data[j] = message.int32Data[j];
+ }
+ if (message.stringData && message.stringData.length) {
+ object.stringData = [];
+ for (var j = 0; j < message.stringData.length; ++j)
+ object.stringData[j] = options.bytes === String ? $util.base64.encode(message.stringData[j], 0, message.stringData[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.stringData[j]) : message.stringData[j];
+ }
+ if (message.int64Data && message.int64Data.length) {
+ object.int64Data = [];
+ for (var j = 0; j < message.int64Data.length; ++j)
+ if (typeof message.int64Data[j] === "number")
+ object.int64Data[j] = options.longs === String ? String(message.int64Data[j]) : message.int64Data[j];
+ else
+ object.int64Data[j] = options.longs === String ? $util.Long.prototype.toString.call(message.int64Data[j]) : options.longs === Number ? new $util.LongBits(message.int64Data[j].low >>> 0, message.int64Data[j].high >>> 0).toNumber() : message.int64Data[j];
+ }
+ if (message.name != null && message.hasOwnProperty("name"))
+ object.name = message.name;
+ if (message.rawData != null && message.hasOwnProperty("rawData"))
+ object.rawData = options.bytes === String ? $util.base64.encode(message.rawData, 0, message.rawData.length) : options.bytes === Array ? Array.prototype.slice.call(message.rawData) : message.rawData;
+ if (message.doubleData && message.doubleData.length) {
+ object.doubleData = [];
+ for (var j = 0; j < message.doubleData.length; ++j)
+ object.doubleData[j] = options.json && !isFinite(message.doubleData[j]) ? String(message.doubleData[j]) : message.doubleData[j];
+ }
+ if (message.uint64Data && message.uint64Data.length) {
+ object.uint64Data = [];
+ for (var j = 0; j < message.uint64Data.length; ++j)
+ if (typeof message.uint64Data[j] === "number")
+ object.uint64Data[j] = options.longs === String ? String(message.uint64Data[j]) : message.uint64Data[j];
+ else
+ object.uint64Data[j] = options.longs === String ? $util.Long.prototype.toString.call(message.uint64Data[j]) : options.longs === Number ? new $util.LongBits(message.uint64Data[j].low >>> 0, message.uint64Data[j].high >>> 0).toNumber(true) : message.uint64Data[j];
+ }
+ if (message.docString != null && message.hasOwnProperty("docString"))
+ object.docString = message.docString;
+ if (message.externalData && message.externalData.length) {
+ object.externalData = [];
+ for (var j = 0; j < message.externalData.length; ++j)
+ object.externalData[j] = $root.onnx.StringStringEntryProto.toObject(message.externalData[j], options);
+ }
+ if (message.dataLocation != null && message.hasOwnProperty("dataLocation"))
+ object.dataLocation = options.enums === String ? $root.onnx.TensorProto.DataLocation[message.dataLocation] === undefined ? message.dataLocation : $root.onnx.TensorProto.DataLocation[message.dataLocation] : message.dataLocation;
+ return object;
+ };
+
+ /**
+ * Converts this TensorProto to JSON.
+ * @function toJSON
+ * @memberof onnx.TensorProto
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ TensorProto.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for TensorProto
+ * @function getTypeUrl
+ * @memberof onnx.TensorProto
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ TensorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.TensorProto";
+ };
+
+ /**
+ * DataType enum.
+ * @name onnx.TensorProto.DataType
+ * @enum {number}
+ * @property {number} UNDEFINED=0 UNDEFINED value
+ * @property {number} FLOAT=1 FLOAT value
+ * @property {number} UINT8=2 UINT8 value
+ * @property {number} INT8=3 INT8 value
+ * @property {number} UINT16=4 UINT16 value
+ * @property {number} INT16=5 INT16 value
+ * @property {number} INT32=6 INT32 value
+ * @property {number} INT64=7 INT64 value
+ * @property {number} STRING=8 STRING value
+ * @property {number} BOOL=9 BOOL value
+ * @property {number} FLOAT16=10 FLOAT16 value
+ * @property {number} DOUBLE=11 DOUBLE value
+ * @property {number} UINT32=12 UINT32 value
+ * @property {number} UINT64=13 UINT64 value
+ * @property {number} COMPLEX64=14 COMPLEX64 value
+ * @property {number} COMPLEX128=15 COMPLEX128 value
+ * @property {number} BFLOAT16=16 BFLOAT16 value
+ * @property {number} FLOAT8E4M3FN=17 FLOAT8E4M3FN value
+ * @property {number} FLOAT8E4M3FNUZ=18 FLOAT8E4M3FNUZ value
+ * @property {number} FLOAT8E5M2=19 FLOAT8E5M2 value
+ * @property {number} FLOAT8E5M2FNUZ=20 FLOAT8E5M2FNUZ value
+ */
+ TensorProto.DataType = (function() {
+ var valuesById = {}, values = Object.create(valuesById);
+ values[valuesById[0] = "UNDEFINED"] = 0;
+ values[valuesById[1] = "FLOAT"] = 1;
+ values[valuesById[2] = "UINT8"] = 2;
+ values[valuesById[3] = "INT8"] = 3;
+ values[valuesById[4] = "UINT16"] = 4;
+ values[valuesById[5] = "INT16"] = 5;
+ values[valuesById[6] = "INT32"] = 6;
+ values[valuesById[7] = "INT64"] = 7;
+ values[valuesById[8] = "STRING"] = 8;
+ values[valuesById[9] = "BOOL"] = 9;
+ values[valuesById[10] = "FLOAT16"] = 10;
+ values[valuesById[11] = "DOUBLE"] = 11;
+ values[valuesById[12] = "UINT32"] = 12;
+ values[valuesById[13] = "UINT64"] = 13;
+ values[valuesById[14] = "COMPLEX64"] = 14;
+ values[valuesById[15] = "COMPLEX128"] = 15;
+ values[valuesById[16] = "BFLOAT16"] = 16;
+ values[valuesById[17] = "FLOAT8E4M3FN"] = 17;
+ values[valuesById[18] = "FLOAT8E4M3FNUZ"] = 18;
+ values[valuesById[19] = "FLOAT8E5M2"] = 19;
+ values[valuesById[20] = "FLOAT8E5M2FNUZ"] = 20;
+ return values;
+ })();
+
+ TensorProto.Segment = (function() {
+
+ /**
+ * Properties of a Segment.
+ * @memberof onnx.TensorProto
+ * @interface ISegment
+ * @property {number|Long|null} [begin] Segment begin
+ * @property {number|Long|null} [end] Segment end
+ */
+
+ /**
+ * Constructs a new Segment.
+ * @memberof onnx.TensorProto
+ * @classdesc Represents a Segment.
+ * @implements ISegment
+ * @constructor
+ * @param {onnx.TensorProto.ISegment=} [properties] Properties to set
+ */
+ function Segment(properties) {
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * Segment begin.
+ * @member {number|Long} begin
+ * @memberof onnx.TensorProto.Segment
+ * @instance
+ */
+ Segment.prototype.begin = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
+
+ /**
+ * Segment end.
+ * @member {number|Long} end
+ * @memberof onnx.TensorProto.Segment
+ * @instance
+ */
+ Segment.prototype.end = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
+
+ /**
+ * Creates a new Segment instance using the specified properties.
+ * @function create
+ * @memberof onnx.TensorProto.Segment
+ * @static
+ * @param {onnx.TensorProto.ISegment=} [properties] Properties to set
+ * @returns {onnx.TensorProto.Segment} Segment instance
+ */
+ Segment.create = function create(properties) {
+ return new Segment(properties);
+ };
+
+ /**
+ * Encodes the specified Segment message. Does not implicitly {@link onnx.TensorProto.Segment.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.TensorProto.Segment
+ * @static
+ * @param {onnx.TensorProto.ISegment} message Segment message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ Segment.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.begin != null && Object.hasOwnProperty.call(message, "begin"))
+ writer.uint32(/* id 1, wireType 0 =*/8).int64(message.begin);
+ if (message.end != null && Object.hasOwnProperty.call(message, "end"))
+ writer.uint32(/* id 2, wireType 0 =*/16).int64(message.end);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified Segment message, length delimited. Does not implicitly {@link onnx.TensorProto.Segment.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.TensorProto.Segment
+ * @static
+ * @param {onnx.TensorProto.ISegment} message Segment message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ Segment.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a Segment message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.TensorProto.Segment
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.TensorProto.Segment} Segment
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ Segment.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.TensorProto.Segment();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.begin = reader.int64();
+ break;
+ }
+ case 2: {
+ message.end = reader.int64();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a Segment message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.TensorProto.Segment
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.TensorProto.Segment} Segment
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ Segment.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a Segment message.
+ * @function verify
+ * @memberof onnx.TensorProto.Segment
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ Segment.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.begin != null && message.hasOwnProperty("begin"))
+ if (!$util.isInteger(message.begin) && !(message.begin && $util.isInteger(message.begin.low) && $util.isInteger(message.begin.high)))
+ return "begin: integer|Long expected";
+ if (message.end != null && message.hasOwnProperty("end"))
+ if (!$util.isInteger(message.end) && !(message.end && $util.isInteger(message.end.low) && $util.isInteger(message.end.high)))
+ return "end: integer|Long expected";
+ return null;
+ };
+
+ /**
+ * Creates a Segment message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.TensorProto.Segment
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.TensorProto.Segment} Segment
+ */
+ Segment.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.TensorProto.Segment)
+ return object;
+ var message = new $root.onnx.TensorProto.Segment();
+ if (object.begin != null)
+ if ($util.Long)
+ (message.begin = $util.Long.fromValue(object.begin)).unsigned = false;
+ else if (typeof object.begin === "string")
+ message.begin = parseInt(object.begin, 10);
+ else if (typeof object.begin === "number")
+ message.begin = object.begin;
+ else if (typeof object.begin === "object")
+ message.begin = new $util.LongBits(object.begin.low >>> 0, object.begin.high >>> 0).toNumber();
+ if (object.end != null)
+ if ($util.Long)
+ (message.end = $util.Long.fromValue(object.end)).unsigned = false;
+ else if (typeof object.end === "string")
+ message.end = parseInt(object.end, 10);
+ else if (typeof object.end === "number")
+ message.end = object.end;
+ else if (typeof object.end === "object")
+ message.end = new $util.LongBits(object.end.low >>> 0, object.end.high >>> 0).toNumber();
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a Segment message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.TensorProto.Segment
+ * @static
+ * @param {onnx.TensorProto.Segment} message Segment
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ Segment.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.defaults) {
+ if ($util.Long) {
+ var long = new $util.Long(0, 0, false);
+ object.begin = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
+ } else
+ object.begin = options.longs === String ? "0" : 0;
+ if ($util.Long) {
+ var long = new $util.Long(0, 0, false);
+ object.end = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
+ } else
+ object.end = options.longs === String ? "0" : 0;
+ }
+ if (message.begin != null && message.hasOwnProperty("begin"))
+ if (typeof message.begin === "number")
+ object.begin = options.longs === String ? String(message.begin) : message.begin;
+ else
+ object.begin = options.longs === String ? $util.Long.prototype.toString.call(message.begin) : options.longs === Number ? new $util.LongBits(message.begin.low >>> 0, message.begin.high >>> 0).toNumber() : message.begin;
+ if (message.end != null && message.hasOwnProperty("end"))
+ if (typeof message.end === "number")
+ object.end = options.longs === String ? String(message.end) : message.end;
+ else
+ object.end = options.longs === String ? $util.Long.prototype.toString.call(message.end) : options.longs === Number ? new $util.LongBits(message.end.low >>> 0, message.end.high >>> 0).toNumber() : message.end;
+ return object;
+ };
+
+ /**
+ * Converts this Segment to JSON.
+ * @function toJSON
+ * @memberof onnx.TensorProto.Segment
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ Segment.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for Segment
+ * @function getTypeUrl
+ * @memberof onnx.TensorProto.Segment
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ Segment.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.TensorProto.Segment";
+ };
+
+ return Segment;
+ })();
+
+ /**
+ * DataLocation enum.
+ * @name onnx.TensorProto.DataLocation
+ * @enum {number}
+ * @property {number} DEFAULT=0 DEFAULT value
+ * @property {number} EXTERNAL=1 EXTERNAL value
+ */
+ TensorProto.DataLocation = (function() {
+ var valuesById = {}, values = Object.create(valuesById);
+ values[valuesById[0] = "DEFAULT"] = 0;
+ values[valuesById[1] = "EXTERNAL"] = 1;
+ return values;
+ })();
+
+ return TensorProto;
+ })();
+
+ onnx.SparseTensorProto = (function() {
+
+ /**
+ * Properties of a SparseTensorProto.
+ * @memberof onnx
+ * @interface ISparseTensorProto
+ * @property {onnx.ITensorProto|null} [values] SparseTensorProto values
+ * @property {onnx.ITensorProto|null} [indices] SparseTensorProto indices
+ * @property {Array.|null} [dims] SparseTensorProto dims
+ */
+
+ /**
+ * Constructs a new SparseTensorProto.
+ * @memberof onnx
+ * @classdesc Represents a SparseTensorProto.
+ * @implements ISparseTensorProto
+ * @constructor
+ * @param {onnx.ISparseTensorProto=} [properties] Properties to set
+ */
+ function SparseTensorProto(properties) {
+ this.dims = [];
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * SparseTensorProto values.
+ * @member {onnx.ITensorProto|null|undefined} values
+ * @memberof onnx.SparseTensorProto
+ * @instance
+ */
+ SparseTensorProto.prototype.values = null;
+
+ /**
+ * SparseTensorProto indices.
+ * @member {onnx.ITensorProto|null|undefined} indices
+ * @memberof onnx.SparseTensorProto
+ * @instance
+ */
+ SparseTensorProto.prototype.indices = null;
+
+ /**
+ * SparseTensorProto dims.
+ * @member {Array.} dims
+ * @memberof onnx.SparseTensorProto
+ * @instance
+ */
+ SparseTensorProto.prototype.dims = $util.emptyArray;
+
+ /**
+ * Creates a new SparseTensorProto instance using the specified properties.
+ * @function create
+ * @memberof onnx.SparseTensorProto
+ * @static
+ * @param {onnx.ISparseTensorProto=} [properties] Properties to set
+ * @returns {onnx.SparseTensorProto} SparseTensorProto instance
+ */
+ SparseTensorProto.create = function create(properties) {
+ return new SparseTensorProto(properties);
+ };
+
+ /**
+ * Encodes the specified SparseTensorProto message. Does not implicitly {@link onnx.SparseTensorProto.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.SparseTensorProto
+ * @static
+ * @param {onnx.ISparseTensorProto} message SparseTensorProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ SparseTensorProto.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.values != null && Object.hasOwnProperty.call(message, "values"))
+ $root.onnx.TensorProto.encode(message.values, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
+ if (message.indices != null && Object.hasOwnProperty.call(message, "indices"))
+ $root.onnx.TensorProto.encode(message.indices, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
+ if (message.dims != null && message.dims.length) {
+ writer.uint32(/* id 3, wireType 2 =*/26).fork();
+ for (var i = 0; i < message.dims.length; ++i)
+ writer.int64(message.dims[i]);
+ writer.ldelim();
+ }
+ return writer;
+ };
+
+ /**
+ * Encodes the specified SparseTensorProto message, length delimited. Does not implicitly {@link onnx.SparseTensorProto.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.SparseTensorProto
+ * @static
+ * @param {onnx.ISparseTensorProto} message SparseTensorProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ SparseTensorProto.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a SparseTensorProto message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.SparseTensorProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.SparseTensorProto} SparseTensorProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ SparseTensorProto.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.SparseTensorProto();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.values = $root.onnx.TensorProto.decode(reader, reader.uint32());
+ break;
+ }
+ case 2: {
+ message.indices = $root.onnx.TensorProto.decode(reader, reader.uint32());
+ break;
+ }
+ case 3: {
+ if (!(message.dims && message.dims.length))
+ message.dims = [];
+ if ((tag & 7) === 2) {
+ var end2 = reader.uint32() + reader.pos;
+ while (reader.pos < end2)
+ message.dims.push(reader.int64());
+ } else
+ message.dims.push(reader.int64());
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a SparseTensorProto message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.SparseTensorProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.SparseTensorProto} SparseTensorProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ SparseTensorProto.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a SparseTensorProto message.
+ * @function verify
+ * @memberof onnx.SparseTensorProto
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ SparseTensorProto.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.values != null && message.hasOwnProperty("values")) {
+ var error = $root.onnx.TensorProto.verify(message.values);
+ if (error)
+ return "values." + error;
+ }
+ if (message.indices != null && message.hasOwnProperty("indices")) {
+ var error = $root.onnx.TensorProto.verify(message.indices);
+ if (error)
+ return "indices." + error;
+ }
+ if (message.dims != null && message.hasOwnProperty("dims")) {
+ if (!Array.isArray(message.dims))
+ return "dims: array expected";
+ for (var i = 0; i < message.dims.length; ++i)
+ if (!$util.isInteger(message.dims[i]) && !(message.dims[i] && $util.isInteger(message.dims[i].low) && $util.isInteger(message.dims[i].high)))
+ return "dims: integer|Long[] expected";
+ }
+ return null;
+ };
+
+ /**
+ * Creates a SparseTensorProto message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.SparseTensorProto
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.SparseTensorProto} SparseTensorProto
+ */
+ SparseTensorProto.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.SparseTensorProto)
+ return object;
+ var message = new $root.onnx.SparseTensorProto();
+ if (object.values != null) {
+ if (typeof object.values !== "object")
+ throw TypeError(".onnx.SparseTensorProto.values: object expected");
+ message.values = $root.onnx.TensorProto.fromObject(object.values);
+ }
+ if (object.indices != null) {
+ if (typeof object.indices !== "object")
+ throw TypeError(".onnx.SparseTensorProto.indices: object expected");
+ message.indices = $root.onnx.TensorProto.fromObject(object.indices);
+ }
+ if (object.dims) {
+ if (!Array.isArray(object.dims))
+ throw TypeError(".onnx.SparseTensorProto.dims: array expected");
+ message.dims = [];
+ for (var i = 0; i < object.dims.length; ++i)
+ if ($util.Long)
+ (message.dims[i] = $util.Long.fromValue(object.dims[i])).unsigned = false;
+ else if (typeof object.dims[i] === "string")
+ message.dims[i] = parseInt(object.dims[i], 10);
+ else if (typeof object.dims[i] === "number")
+ message.dims[i] = object.dims[i];
+ else if (typeof object.dims[i] === "object")
+ message.dims[i] = new $util.LongBits(object.dims[i].low >>> 0, object.dims[i].high >>> 0).toNumber();
+ }
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a SparseTensorProto message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.SparseTensorProto
+ * @static
+ * @param {onnx.SparseTensorProto} message SparseTensorProto
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ SparseTensorProto.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.arrays || options.defaults)
+ object.dims = [];
+ if (options.defaults) {
+ object.values = null;
+ object.indices = null;
+ }
+ if (message.values != null && message.hasOwnProperty("values"))
+ object.values = $root.onnx.TensorProto.toObject(message.values, options);
+ if (message.indices != null && message.hasOwnProperty("indices"))
+ object.indices = $root.onnx.TensorProto.toObject(message.indices, options);
+ if (message.dims && message.dims.length) {
+ object.dims = [];
+ for (var j = 0; j < message.dims.length; ++j)
+ if (typeof message.dims[j] === "number")
+ object.dims[j] = options.longs === String ? String(message.dims[j]) : message.dims[j];
+ else
+ object.dims[j] = options.longs === String ? $util.Long.prototype.toString.call(message.dims[j]) : options.longs === Number ? new $util.LongBits(message.dims[j].low >>> 0, message.dims[j].high >>> 0).toNumber() : message.dims[j];
+ }
+ return object;
+ };
+
+ /**
+ * Converts this SparseTensorProto to JSON.
+ * @function toJSON
+ * @memberof onnx.SparseTensorProto
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ SparseTensorProto.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for SparseTensorProto
+ * @function getTypeUrl
+ * @memberof onnx.SparseTensorProto
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ SparseTensorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.SparseTensorProto";
+ };
+
+ return SparseTensorProto;
+ })();
+
+ onnx.TensorShapeProto = (function() {
+
+ /**
+ * Properties of a TensorShapeProto.
+ * @memberof onnx
+ * @interface ITensorShapeProto
+ * @property {Array.|null} [dim] TensorShapeProto dim
+ */
+
+ /**
+ * Constructs a new TensorShapeProto.
+ * @memberof onnx
+ * @classdesc Represents a TensorShapeProto.
+ * @implements ITensorShapeProto
+ * @constructor
+ * @param {onnx.ITensorShapeProto=} [properties] Properties to set
+ */
+ function TensorShapeProto(properties) {
+ this.dim = [];
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * TensorShapeProto dim.
+ * @member {Array.} dim
+ * @memberof onnx.TensorShapeProto
+ * @instance
+ */
+ TensorShapeProto.prototype.dim = $util.emptyArray;
+
+ /**
+ * Creates a new TensorShapeProto instance using the specified properties.
+ * @function create
+ * @memberof onnx.TensorShapeProto
+ * @static
+ * @param {onnx.ITensorShapeProto=} [properties] Properties to set
+ * @returns {onnx.TensorShapeProto} TensorShapeProto instance
+ */
+ TensorShapeProto.create = function create(properties) {
+ return new TensorShapeProto(properties);
+ };
+
+ /**
+ * Encodes the specified TensorShapeProto message. Does not implicitly {@link onnx.TensorShapeProto.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.TensorShapeProto
+ * @static
+ * @param {onnx.ITensorShapeProto} message TensorShapeProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ TensorShapeProto.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.dim != null && message.dim.length)
+ for (var i = 0; i < message.dim.length; ++i)
+ $root.onnx.TensorShapeProto.Dimension.encode(message.dim[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
+ return writer;
+ };
+
+ /**
+ * Encodes the specified TensorShapeProto message, length delimited. Does not implicitly {@link onnx.TensorShapeProto.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.TensorShapeProto
+ * @static
+ * @param {onnx.ITensorShapeProto} message TensorShapeProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ TensorShapeProto.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a TensorShapeProto message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.TensorShapeProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.TensorShapeProto} TensorShapeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ TensorShapeProto.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.TensorShapeProto();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ if (!(message.dim && message.dim.length))
+ message.dim = [];
+ message.dim.push($root.onnx.TensorShapeProto.Dimension.decode(reader, reader.uint32()));
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a TensorShapeProto message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.TensorShapeProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.TensorShapeProto} TensorShapeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ TensorShapeProto.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a TensorShapeProto message.
+ * @function verify
+ * @memberof onnx.TensorShapeProto
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ TensorShapeProto.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.dim != null && message.hasOwnProperty("dim")) {
+ if (!Array.isArray(message.dim))
+ return "dim: array expected";
+ for (var i = 0; i < message.dim.length; ++i) {
+ var error = $root.onnx.TensorShapeProto.Dimension.verify(message.dim[i]);
+ if (error)
+ return "dim." + error;
+ }
+ }
+ return null;
+ };
+
+ /**
+ * Creates a TensorShapeProto message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.TensorShapeProto
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.TensorShapeProto} TensorShapeProto
+ */
+ TensorShapeProto.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.TensorShapeProto)
+ return object;
+ var message = new $root.onnx.TensorShapeProto();
+ if (object.dim) {
+ if (!Array.isArray(object.dim))
+ throw TypeError(".onnx.TensorShapeProto.dim: array expected");
+ message.dim = [];
+ for (var i = 0; i < object.dim.length; ++i) {
+ if (typeof object.dim[i] !== "object")
+ throw TypeError(".onnx.TensorShapeProto.dim: object expected");
+ message.dim[i] = $root.onnx.TensorShapeProto.Dimension.fromObject(object.dim[i]);
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a TensorShapeProto message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.TensorShapeProto
+ * @static
+ * @param {onnx.TensorShapeProto} message TensorShapeProto
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ TensorShapeProto.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.arrays || options.defaults)
+ object.dim = [];
+ if (message.dim && message.dim.length) {
+ object.dim = [];
+ for (var j = 0; j < message.dim.length; ++j)
+ object.dim[j] = $root.onnx.TensorShapeProto.Dimension.toObject(message.dim[j], options);
+ }
+ return object;
+ };
+
+ /**
+ * Converts this TensorShapeProto to JSON.
+ * @function toJSON
+ * @memberof onnx.TensorShapeProto
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ TensorShapeProto.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for TensorShapeProto
+ * @function getTypeUrl
+ * @memberof onnx.TensorShapeProto
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ TensorShapeProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.TensorShapeProto";
+ };
+
+ TensorShapeProto.Dimension = (function() {
+
+ /**
+ * Properties of a Dimension.
+ * @memberof onnx.TensorShapeProto
+ * @interface IDimension
+ * @property {number|Long|null} [dimValue] Dimension dimValue
+ * @property {string|null} [dimParam] Dimension dimParam
+ * @property {string|null} [denotation] Dimension denotation
+ */
+
+ /**
+ * Constructs a new Dimension.
+ * @memberof onnx.TensorShapeProto
+ * @classdesc Represents a Dimension.
+ * @implements IDimension
+ * @constructor
+ * @param {onnx.TensorShapeProto.IDimension=} [properties] Properties to set
+ */
+ function Dimension(properties) {
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * Dimension dimValue.
+ * @member {number|Long|null|undefined} dimValue
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @instance
+ */
+ Dimension.prototype.dimValue = null;
+
+ /**
+ * Dimension dimParam.
+ * @member {string|null|undefined} dimParam
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @instance
+ */
+ Dimension.prototype.dimParam = null;
+
+ /**
+ * Dimension denotation.
+ * @member {string} denotation
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @instance
+ */
+ Dimension.prototype.denotation = "";
+
+ // OneOf field names bound to virtual getters and setters
+ var $oneOfFields;
+
+ /**
+ * Dimension value.
+ * @member {"dimValue"|"dimParam"|undefined} value
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @instance
+ */
+ Object.defineProperty(Dimension.prototype, "value", {
+ get: $util.oneOfGetter($oneOfFields = ["dimValue", "dimParam"]),
+ set: $util.oneOfSetter($oneOfFields)
+ });
+
+ /**
+ * Creates a new Dimension instance using the specified properties.
+ * @function create
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @static
+ * @param {onnx.TensorShapeProto.IDimension=} [properties] Properties to set
+ * @returns {onnx.TensorShapeProto.Dimension} Dimension instance
+ */
+ Dimension.create = function create(properties) {
+ return new Dimension(properties);
+ };
+
+ /**
+ * Encodes the specified Dimension message. Does not implicitly {@link onnx.TensorShapeProto.Dimension.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @static
+ * @param {onnx.TensorShapeProto.IDimension} message Dimension message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ Dimension.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.dimValue != null && Object.hasOwnProperty.call(message, "dimValue"))
+ writer.uint32(/* id 1, wireType 0 =*/8).int64(message.dimValue);
+ if (message.dimParam != null && Object.hasOwnProperty.call(message, "dimParam"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.dimParam);
+ if (message.denotation != null && Object.hasOwnProperty.call(message, "denotation"))
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.denotation);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified Dimension message, length delimited. Does not implicitly {@link onnx.TensorShapeProto.Dimension.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @static
+ * @param {onnx.TensorShapeProto.IDimension} message Dimension message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ Dimension.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a Dimension message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.TensorShapeProto.Dimension} Dimension
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ Dimension.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.TensorShapeProto.Dimension();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.dimValue = reader.int64();
+ break;
+ }
+ case 2: {
+ message.dimParam = reader.string();
+ break;
+ }
+ case 3: {
+ message.denotation = reader.string();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a Dimension message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.TensorShapeProto.Dimension} Dimension
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ Dimension.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a Dimension message.
+ * @function verify
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ Dimension.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ var properties = {};
+ if (message.dimValue != null && message.hasOwnProperty("dimValue")) {
+ properties.value = 1;
+ if (!$util.isInteger(message.dimValue) && !(message.dimValue && $util.isInteger(message.dimValue.low) && $util.isInteger(message.dimValue.high)))
+ return "dimValue: integer|Long expected";
+ }
+ if (message.dimParam != null && message.hasOwnProperty("dimParam")) {
+ if (properties.value === 1)
+ return "value: multiple values";
+ properties.value = 1;
+ if (!$util.isString(message.dimParam))
+ return "dimParam: string expected";
+ }
+ if (message.denotation != null && message.hasOwnProperty("denotation"))
+ if (!$util.isString(message.denotation))
+ return "denotation: string expected";
+ return null;
+ };
+
+ /**
+ * Creates a Dimension message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.TensorShapeProto.Dimension} Dimension
+ */
+ Dimension.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.TensorShapeProto.Dimension)
+ return object;
+ var message = new $root.onnx.TensorShapeProto.Dimension();
+ if (object.dimValue != null)
+ if ($util.Long)
+ (message.dimValue = $util.Long.fromValue(object.dimValue)).unsigned = false;
+ else if (typeof object.dimValue === "string")
+ message.dimValue = parseInt(object.dimValue, 10);
+ else if (typeof object.dimValue === "number")
+ message.dimValue = object.dimValue;
+ else if (typeof object.dimValue === "object")
+ message.dimValue = new $util.LongBits(object.dimValue.low >>> 0, object.dimValue.high >>> 0).toNumber();
+ if (object.dimParam != null)
+ message.dimParam = String(object.dimParam);
+ if (object.denotation != null)
+ message.denotation = String(object.denotation);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a Dimension message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @static
+ * @param {onnx.TensorShapeProto.Dimension} message Dimension
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ Dimension.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.defaults)
+ object.denotation = "";
+ if (message.dimValue != null && message.hasOwnProperty("dimValue")) {
+ if (typeof message.dimValue === "number")
+ object.dimValue = options.longs === String ? String(message.dimValue) : message.dimValue;
+ else
+ object.dimValue = options.longs === String ? $util.Long.prototype.toString.call(message.dimValue) : options.longs === Number ? new $util.LongBits(message.dimValue.low >>> 0, message.dimValue.high >>> 0).toNumber() : message.dimValue;
+ if (options.oneofs)
+ object.value = "dimValue";
+ }
+ if (message.dimParam != null && message.hasOwnProperty("dimParam")) {
+ object.dimParam = message.dimParam;
+ if (options.oneofs)
+ object.value = "dimParam";
+ }
+ if (message.denotation != null && message.hasOwnProperty("denotation"))
+ object.denotation = message.denotation;
+ return object;
+ };
+
+ /**
+ * Converts this Dimension to JSON.
+ * @function toJSON
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ Dimension.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for Dimension
+ * @function getTypeUrl
+ * @memberof onnx.TensorShapeProto.Dimension
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ Dimension.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/onnx.TensorShapeProto.Dimension";
+ };
+
+ return Dimension;
+ })();
+
+ return TensorShapeProto;
+ })();
+
+ onnx.TypeProto = (function() {
+
+ /**
+ * Properties of a TypeProto.
+ * @memberof onnx
+ * @interface ITypeProto
+ * @property {onnx.TypeProto.ITensor|null} [tensorType] TypeProto tensorType
+ * @property {onnx.TypeProto.ISequence|null} [sequenceType] TypeProto sequenceType
+ * @property {onnx.TypeProto.IMap|null} [mapType] TypeProto mapType
+ * @property {onnx.TypeProto.IOptional|null} [optionalType] TypeProto optionalType
+ * @property {onnx.TypeProto.ISparseTensor|null} [sparseTensorType] TypeProto sparseTensorType
+ * @property {string|null} [denotation] TypeProto denotation
+ */
+
+ /**
+ * Constructs a new TypeProto.
+ * @memberof onnx
+ * @classdesc Represents a TypeProto.
+ * @implements ITypeProto
+ * @constructor
+ * @param {onnx.ITypeProto=} [properties] Properties to set
+ */
+ function TypeProto(properties) {
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * TypeProto tensorType.
+ * @member {onnx.TypeProto.ITensor|null|undefined} tensorType
+ * @memberof onnx.TypeProto
+ * @instance
+ */
+ TypeProto.prototype.tensorType = null;
+
+ /**
+ * TypeProto sequenceType.
+ * @member {onnx.TypeProto.ISequence|null|undefined} sequenceType
+ * @memberof onnx.TypeProto
+ * @instance
+ */
+ TypeProto.prototype.sequenceType = null;
+
+ /**
+ * TypeProto mapType.
+ * @member {onnx.TypeProto.IMap|null|undefined} mapType
+ * @memberof onnx.TypeProto
+ * @instance
+ */
+ TypeProto.prototype.mapType = null;
+
+ /**
+ * TypeProto optionalType.
+ * @member {onnx.TypeProto.IOptional|null|undefined} optionalType
+ * @memberof onnx.TypeProto
+ * @instance
+ */
+ TypeProto.prototype.optionalType = null;
+
+ /**
+ * TypeProto sparseTensorType.
+ * @member {onnx.TypeProto.ISparseTensor|null|undefined} sparseTensorType
+ * @memberof onnx.TypeProto
+ * @instance
+ */
+ TypeProto.prototype.sparseTensorType = null;
+
+ /**
+ * TypeProto denotation.
+ * @member {string} denotation
+ * @memberof onnx.TypeProto
+ * @instance
+ */
+ TypeProto.prototype.denotation = "";
+
+ // OneOf field names bound to virtual getters and setters
+ var $oneOfFields;
+
+ /**
+ * TypeProto value.
+ * @member {"tensorType"|"sequenceType"|"mapType"|"optionalType"|"sparseTensorType"|undefined} value
+ * @memberof onnx.TypeProto
+ * @instance
+ */
+ Object.defineProperty(TypeProto.prototype, "value", {
+ get: $util.oneOfGetter($oneOfFields = ["tensorType", "sequenceType", "mapType", "optionalType", "sparseTensorType"]),
+ set: $util.oneOfSetter($oneOfFields)
+ });
+
+ /**
+ * Creates a new TypeProto instance using the specified properties.
+ * @function create
+ * @memberof onnx.TypeProto
+ * @static
+ * @param {onnx.ITypeProto=} [properties] Properties to set
+ * @returns {onnx.TypeProto} TypeProto instance
+ */
+ TypeProto.create = function create(properties) {
+ return new TypeProto(properties);
+ };
+
+ /**
+ * Encodes the specified TypeProto message. Does not implicitly {@link onnx.TypeProto.verify|verify} messages.
+ * @function encode
+ * @memberof onnx.TypeProto
+ * @static
+ * @param {onnx.ITypeProto} message TypeProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ TypeProto.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.tensorType != null && Object.hasOwnProperty.call(message, "tensorType"))
+ $root.onnx.TypeProto.Tensor.encode(message.tensorType, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
+ if (message.sequenceType != null && Object.hasOwnProperty.call(message, "sequenceType"))
+ $root.onnx.TypeProto.Sequence.encode(message.sequenceType, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
+ if (message.mapType != null && Object.hasOwnProperty.call(message, "mapType"))
+ $root.onnx.TypeProto.Map.encode(message.mapType, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim();
+ if (message.denotation != null && Object.hasOwnProperty.call(message, "denotation"))
+ writer.uint32(/* id 6, wireType 2 =*/50).string(message.denotation);
+ if (message.sparseTensorType != null && Object.hasOwnProperty.call(message, "sparseTensorType"))
+ $root.onnx.TypeProto.SparseTensor.encode(message.sparseTensorType, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim();
+ if (message.optionalType != null && Object.hasOwnProperty.call(message, "optionalType"))
+ $root.onnx.TypeProto.Optional.encode(message.optionalType, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim();
+ return writer;
+ };
+
+ /**
+ * Encodes the specified TypeProto message, length delimited. Does not implicitly {@link onnx.TypeProto.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof onnx.TypeProto
+ * @static
+ * @param {onnx.ITypeProto} message TypeProto message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ TypeProto.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a TypeProto message from the specified reader or buffer.
+ * @function decode
+ * @memberof onnx.TypeProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {onnx.TypeProto} TypeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ TypeProto.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.onnx.TypeProto();
+ while (reader.pos < end) {
+ var tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.tensorType = $root.onnx.TypeProto.Tensor.decode(reader, reader.uint32());
+ break;
+ }
+ case 4: {
+ message.sequenceType = $root.onnx.TypeProto.Sequence.decode(reader, reader.uint32());
+ break;
+ }
+ case 5: {
+ message.mapType = $root.onnx.TypeProto.Map.decode(reader, reader.uint32());
+ break;
+ }
+ case 9: {
+ message.optionalType = $root.onnx.TypeProto.Optional.decode(reader, reader.uint32());
+ break;
+ }
+ case 8: {
+ message.sparseTensorType = $root.onnx.TypeProto.SparseTensor.decode(reader, reader.uint32());
+ break;
+ }
+ case 6: {
+ message.denotation = reader.string();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a TypeProto message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof onnx.TypeProto
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {onnx.TypeProto} TypeProto
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ TypeProto.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a TypeProto message.
+ * @function verify
+ * @memberof onnx.TypeProto
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ TypeProto.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ var properties = {};
+ if (message.tensorType != null && message.hasOwnProperty("tensorType")) {
+ properties.value = 1;
+ {
+ var error = $root.onnx.TypeProto.Tensor.verify(message.tensorType);
+ if (error)
+ return "tensorType." + error;
+ }
+ }
+ if (message.sequenceType != null && message.hasOwnProperty("sequenceType")) {
+ if (properties.value === 1)
+ return "value: multiple values";
+ properties.value = 1;
+ {
+ var error = $root.onnx.TypeProto.Sequence.verify(message.sequenceType);
+ if (error)
+ return "sequenceType." + error;
+ }
+ }
+ if (message.mapType != null && message.hasOwnProperty("mapType")) {
+ if (properties.value === 1)
+ return "value: multiple values";
+ properties.value = 1;
+ {
+ var error = $root.onnx.TypeProto.Map.verify(message.mapType);
+ if (error)
+ return "mapType." + error;
+ }
+ }
+ if (message.optionalType != null && message.hasOwnProperty("optionalType")) {
+ if (properties.value === 1)
+ return "value: multiple values";
+ properties.value = 1;
+ {
+ var error = $root.onnx.TypeProto.Optional.verify(message.optionalType);
+ if (error)
+ return "optionalType." + error;
+ }
+ }
+ if (message.sparseTensorType != null && message.hasOwnProperty("sparseTensorType")) {
+ if (properties.value === 1)
+ return "value: multiple values";
+ properties.value = 1;
+ {
+ var error = $root.onnx.TypeProto.SparseTensor.verify(message.sparseTensorType);
+ if (error)
+ return "sparseTensorType." + error;
+ }
+ }
+ if (message.denotation != null && message.hasOwnProperty("denotation"))
+ if (!$util.isString(message.denotation))
+ return "denotation: string expected";
+ return null;
+ };
+
+ /**
+ * Creates a TypeProto message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof onnx.TypeProto
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {onnx.TypeProto} TypeProto
+ */
+ TypeProto.fromObject = function fromObject(object) {
+ if (object instanceof $root.onnx.TypeProto)
+ return object;
+ var message = new $root.onnx.TypeProto();
+ if (object.tensorType != null) {
+ if (typeof object.tensorType !== "object")
+ throw TypeError(".onnx.TypeProto.tensorType: object expected");
+ message.tensorType = $root.onnx.TypeProto.Tensor.fromObject(object.tensorType);
+ }
+ if (object.sequenceType != null) {
+ if (typeof object.sequenceType !== "object")
+ throw TypeError(".onnx.TypeProto.sequenceType: object expected");
+ message.sequenceType = $root.onnx.TypeProto.Sequence.fromObject(object.sequenceType);
+ }
+ if (object.mapType != null) {
+ if (typeof object.mapType !== "object")
+ throw TypeError(".onnx.TypeProto.mapType: object expected");
+ message.mapType = $root.onnx.TypeProto.Map.fromObject(object.mapType);
+ }
+ if (object.optionalType != null) {
+ if (typeof object.optionalType !== "object")
+ throw TypeError(".onnx.TypeProto.optionalType: object expected");
+ message.optionalType = $root.onnx.TypeProto.Optional.fromObject(object.optionalType);
+ }
+ if (object.sparseTensorType != null) {
+ if (typeof object.sparseTensorType !== "object")
+ throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");
+ message.sparseTensorType = $root.onnx.TypeProto.SparseTensor.fromObject(object.sparseTensorType);
+ }
+ if (object.denotation != null)
+ message.denotation = String(object.denotation);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a TypeProto message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof onnx.TypeProto
+ * @static
+ * @param {onnx.TypeProto} message TypeProto
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ TypeProto.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ var object = {};
+ if (options.defaults)
+ object.denotation = "";
+ if (message.tensorType != null && message.hasOwnProperty("tensorType")) {
+ object.tensorType = $root.onnx.TypeProto.Tensor.toObject(message.tensorType, options);
+ if (options.oneofs)
+ object.value = "tensorType";
+ }
+ if (message.sequenceType != null && message.hasOwnProperty("sequenceType")) {
+ object.sequenceType = $root.onnx.TypeProto.Sequence.toObject(message.sequenceType, options);
+ if (options.oneofs)
+ object.value = "sequenceType";
+ }
+ if (message.mapType != null && message.hasOwnProperty("mapType")) {
+ object.mapType = $root.onnx.TypeProto.Map.toObject(message.mapType, options);
+ if (options.oneofs)
+ object.value = "mapType";
+ }
+ if (message.denotation != null && message.hasOwnProperty("denotation"))
+ object.denotation = message.denotation;
+ if (message.sparseTensorType != null && message.hasOwnProperty("sparseTensorType")) {
+ object.sparseTensorType = $root.onnx.TypeProto.SparseTensor.toObject(message.sparseTensorType, options);
+ if (options.oneofs)
+ object.value = "sparseTensorType";
+ }
+ if (message.optionalType != null && message.hasOwnProperty("optionalType")) {
+ object.optionalType = $root.onnx.TypeProto.Optional.toObject(message.optionalType, options);
+ if (options.oneofs)
+ object.value = "optionalType";
+ }
+ return object;
+ };
+
+ /**
+ * Converts this TypeProto to JSON.
+ * @function toJSON
+ * @memberof onnx.TypeProto
+ * @instance
+ * @returns {Object.