From 2b850ecf108fd2df13025c601539452f580fd7fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=86=8A=E6=94=80?= Date: Thu, 10 Jul 2025 10:36:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=BC=80=E6=BA=90proto?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Third_Party_Open_Source_Software_Notice | 749 +- .../src/litert/delegate/coreml/CMakeLists.txt | 13 + mindspore-lite/tools/converter/CMakeLists.txt | 52 + third_party/patch/caffe/caffe.patch | 355 + .../caffe_proto_acl_quant_param.patch001 | 1 + third_party/patch/tensorflow/tensorflow.patch | 270 + third_party/proto/caffe/LICENSE | 44 - third_party/proto/caffe/caffe.proto | 1675 ----- third_party/proto/coreml/DataStructures.proto | 95 - third_party/proto/coreml/FeatureTypes.proto | 224 - third_party/proto/coreml/Model.proto | 164 - third_party/proto/coreml/NeuralNetwork.proto | 6531 ----------------- third_party/proto/coreml/Parameters.proto | 52 - third_party/proto/onnx/LICENSE | 202 - third_party/proto/onnx/onnx.proto | 569 -- third_party/proto/tensorflow/LICENSE | 203 - third_party/proto/tensorflow/attr_value.proto | 64 - third_party/proto/tensorflow/function.proto | 126 - third_party/proto/tensorflow/graph.proto | 58 - third_party/proto/tensorflow/lite/schema.fbs | 1094 --- .../proto/tensorflow/lite/schema_2.4.1.fbs | 1146 --- third_party/proto/tensorflow/node_def.proto | 88 - third_party/proto/tensorflow/op_def.proto | 170 - .../proto/tensorflow/resource_handle.proto | 45 - third_party/proto/tensorflow/tensor.proto | 96 - .../proto/tensorflow/tensor_shape.proto | 46 - third_party/proto/tensorflow/types.proto | 87 - third_party/proto/tensorflow/versions.proto | 33 - 28 files changed, 1439 insertions(+), 12813 deletions(-) create mode 100644 third_party/patch/caffe/caffe.patch create mode 100644 third_party/patch/tensorflow/tensorflow.patch delete mode 100644 third_party/proto/caffe/LICENSE delete mode 100755 third_party/proto/caffe/caffe.proto delete mode 100644 third_party/proto/coreml/DataStructures.proto delete mode 100644 third_party/proto/coreml/FeatureTypes.proto delete mode 100644 third_party/proto/coreml/Model.proto delete mode 100644 third_party/proto/coreml/NeuralNetwork.proto delete mode 100644 third_party/proto/coreml/Parameters.proto delete mode 100644 third_party/proto/onnx/LICENSE delete mode 100644 third_party/proto/onnx/onnx.proto delete mode 100644 third_party/proto/tensorflow/LICENSE delete mode 100644 third_party/proto/tensorflow/attr_value.proto delete mode 100644 third_party/proto/tensorflow/function.proto delete mode 100644 third_party/proto/tensorflow/graph.proto delete mode 100644 third_party/proto/tensorflow/lite/schema.fbs delete mode 100644 third_party/proto/tensorflow/lite/schema_2.4.1.fbs delete mode 100644 third_party/proto/tensorflow/node_def.proto delete mode 100644 third_party/proto/tensorflow/op_def.proto delete mode 100644 third_party/proto/tensorflow/resource_handle.proto delete mode 100644 third_party/proto/tensorflow/tensor.proto delete mode 100644 third_party/proto/tensorflow/tensor_shape.proto delete mode 100644 third_party/proto/tensorflow/types.proto delete mode 100644 third_party/proto/tensorflow/versions.proto diff --git a/Third_Party_Open_Source_Software_Notice b/Third_Party_Open_Source_Software_Notice index 87ec2915..082295ee 100644 --- a/Third_Party_Open_Source_Software_Notice +++ b/Third_Party_Open_Source_Software_Notice @@ -10819,4 +10819,751 @@ License: Apache License 2.0 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - \ No newline at end of file + +Software: tensorflow 2.4.1 +Copyright notice: +Copyright (c) . All rights reserved +Copyright (c) 2014 Ryan Juckett +copyright 2010 David Wolever . All rights reserved +Copyright 2020-2023 FUJITSU LIMITED +Copyright (c) 1991-2018 Unicode, Inc. All rights reserved +(c) 1995-2017 Jean-loup Gailly and Mark Adler +Copyright 2019 The TensorFlow Authors +Copyright (c) 2014 International Business Machines Corporation and others. All Rights Reserved +Copyright 2023 KNS Group LLC +Copyright 20121 The TensorFlow Authors. All Rights Reserved +Copyright 2018 The OpenXLA Authors +Copyright 2022 Arm Ltd. and affiliates +Copyright (c) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved +Copyright (c) 2014, The Regents +Copyright 2022 Google LLC. All Rights Reserved +Copyright 2020-2022 OpenAI +Copyright 2022 Google LLC +Copyright 2009-2022 NVIDIA Corporation. All rights reserved +Copyright 2016-2020 The TensorFlow Authors. All Rights Reserved +Copyright 2021 Alanna Tempest +Copyright (c) 2020 Da Yan HKUST +Copyright (c) 2013 Brian Eugene Wilson, Robert Martin Campbell. All rights reserved +Copyright (c) 1996 - 2014, Daniel Stenberg, +Copyright 2021 The OpenXLA Authors +Copyright (c) 2012, Noah Spurrier +Copyright (c) 2016 Wenzel Jakob , All rights reserved +Copyright 2024 Arm Limited and affiliates +Copyright (c) 2006-2008, Google Inc. +Copyright 2023 Google LLC +Copyright (c) 2016, Serge Guelton All rights reserved +Copyright 2016 The OpenXLA Authors +Copyright (c) 2013-2023, Graham Dumpleton All rights reserved +Copyright 2015 Google Inc. All Rights Reserved +Copyright (c) 2010-2015 Benjamin Peterson +Copyright (c) 1996-2019 Internet Software Consortium +Copyright 2019 The Kythe Authors. All rights reserved +Copyright (c) 2008 Ian Bicking and Contributors +Copyright various years +Copyright 2023 The OpenXLA Authors +Copyright (c) 2015 International Business Machines Corporation and others. All Rights Reserved +Copyright property of CompuServe Incorporated +Copyright (c) 2008-2011 Volvox Development Team +Copyright 2020 The TensorFlow Authors. All rights reserved +Copyright 2015, The TensorFlow Authors +Copyright 2022-2023 Arm Ltd. and affiliates +Copyright 2018 The Android Open Source Project +Copyright (c) 2005, 2006, 2007 Carabos Coop. V. All rights reserved +Copyright (c) 1995-1998 Eric Young (eay@cryptsoft.com) All rights reserved +Copyright 2022 The OpenXLA Authors. All Rights Reserved +(c) Elementwise users +Copyright 2019-2023 FUJITSU LIMITED +Copyright (c) 1992-2013 The University of Tennessee and The University of Tennessee Research Foundation. All rights reserved +Copyright (c) 2005-2019, NumPy Developers. All rights reserved +Copyright 2016 The TensorFlow Authors. All Rights Reserved +Copyright 2016, Google Inc. +Copyright (c) 1993, 1996, 1997 Free Software Foundation, Inc. +Copyright (c) 2014 Google, Inc. +Copyright (c) 1989, 1991 Free Software Foundation, Inc. +Copyright 2022 Google LLC All Rights Reserved +Copyright (c) 2010-2020 Benjamin Peterson +Copyright 2023 The JAX Authors +Copyright (c) 1995-2016 International Business Machines Corporation and others All rights reserved +Copyright 2024 The OpenXLA Authors +Copyright (c) 2006-2013 The University of Colorado Denver. All rights reserved +Copyright (c) 1999 Computer Systems and Communication Lab, Institute of Information Science, Academia Sinica. All rights reserved +Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved +Copyright 2024 The TensorFlow Authors +Copyright (c) 2011-2017, Andres Moreira All rights reserved +Copyright (c) 1991-2022 Unicode, Inc. All rights reserved +Copyright 2025 The OpenXLA Authors +Copyright 2019 Google Inc. All rights reserved +Copyright 2015-2017 The TensorFlow Authors. All Rights Reserved +Copyright (c) 2014, Simon Percivall All rights reserved +Copyright (c) 1997 Eric S. Raymond +Copyright 2023 The StableHLO Authors. All Rights Reserved +copyright by X Consortium +Copyright 2014 Melissa O'Neill +Copyright 2024 The Tensorflow Authors +Copyright (c) 2013 International Business Machines Corporation and others. All Rights Reserved +Copyright 2017 The TensorFlow Authors All Rights Reserved +Copyright 2023 The OpenXLA Authors. All Rights Reserved +Copyright (c) 1997,2001 Takuya OOURA +Copyright (c) 2000-2013 The University of California Berkeley. All rights reserved +Copyright 2020 Google LLC. All Rights Reserved +Copyright 2015-2021 The TensorFlow Authors. All Rights Reserved +Copyright 2023 The StableHLO Authors +Copyright (c) 2015, Google Inc. +Copyright 2020-2023 Arm Ltd. and affiliates +Copyright 2024 The TensorFlow Authors. All rights reserved +Copyright 2023 The TensorFlow Authors All Rights Reserved +Copyright (c) 2003-2005, Jean-Sebastien Roy (js@jeannot.org) +Copyright (c) 1991,1997,2011 Free Software Foundation, Inc. +Copyright 2018, The TensorFlow Authors +Copyright 2020-2022 Intel Corporation +Copyright 2008, Google Inc. All rights reserved +Copyright (c) 2016 - 2019 Kim Walisch, +Copyright 2018 The TensorFlow Authors. All Rights Reserved +Copyright 2015 Robert Kern +Copyright 2021 Google LLC. All Rights Reserved +Copyright (c) 1994 The Regents +Copyright 2024 Google LLC. +Copyright 2020 The TensorFlow Authors. All Rights Reserved +Copyright 2019 The TensorFlow Authors. Al Rights Reserved +Copyright (c) 2003-2019 University of Illinois at Urbana-Champaign. All rights reserved +Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Python Software Foundation All Rights Reserved +Copyright (c) 2011, Intel Corporation. All rights reserved +Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved +Copyright 2006-2007 by The HDF Group +Copyright 1996 Chih-Hao Tsai Beckman Institute, University of Illinois c-tsai4@uiuc.edu http://casper.beckman.uiuc.edu/~c-tsai4 +Copyright 2014 The Android Open Source Project +Copyright (c) 2010 - 2019 ridiculous_fish, +Copyright 2024 The OpenXLA Authors. All Rights Reserved +Copyright 2016-2023 Intel Corporation +Copyright 2015 The TensorFlow Authors. All rights reserved +Copyright (c) 2016 and later Unicode, Inc. and others +Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson +Copyright 2023 The TensorFlow Authors. All Rights Reserved +Copyright 2023 Google Inc. All Rights Reserved +Copyright (c) 1997-2020 by Dimitri van Heesch +Copyright (c) 2015-2018, NVIDIA CORPORATION. All rights reserved +(c) 2002-2008 John D. Hunter +Copyright 2020-2022 Codeplay Software Limited +Copyright 2019 Google Inc. All Rights Reserved +Copyright 2019-2021 The TensorFlow Authors. All Rights Reserved +Copyright (c) 1996-1997 Andreas Dilger +Copyright 2013 The TensorFlow Authors. All Rights Reserved +Copyright 2018-2020 Philippe Tillet +Copyright (c) 1993-2022 Free Software Foundation, Inc. +Copyright 2013 The Android Open Source Project +Copyright 2018-2020 The TensorFlow Authors. All Rights Reserved +Copyright 2020 The OpenXLA Authors +Copyright 2022 The TensorFlow Authors. All Rights Reserved +Copyright 2021 The TensorFlow Authors All Rights Reserved +Copyright 2017 The OpenXLA Authors +Copyright (c) 2004 eXtensible Systems, Inc. +Copyright 2022 The OpenXLA Authors +Copyright 2024 The StableHLO Authors +Copyright 2020 Google LLC +(c) Impl Erf +Copyright (c) 2013, LeRoy Benjamin Sharon All rights reserved +Copyright 2019 Google, LLC +Copyright 2020-2021 The TensorFlow Authors. All Rights Reserved +Copyright (c) 2008 Stefan van +Copyright 2018 The TensorFlow Authors. All rights reserved +Copyright 2018-2023 Intel Corporation +Copyright (c) 2017 - 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved +Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Python Software Foundation All Rights Reserved +Copyright (c) 1991, 1997, 2003 Free Software Foundation, Inc. +Copyright 2025 The TensorFlow Authors. All Rights Reserved +Copyright 2017 The TensorFlow Authors. All rights reserved +Copyright 2022 Google Inc. All rights reserved +Copyright 2016 The TensorFlow Authors All Rights Reserved +Copyright (c) 1991-2015 Unicode, Inc. All rights reserved +Copyright 2019 The TensorFlow Authors All Rights Reserved +Copyright (c) 2009 The RE2 Authors. All rights reserved +Copyright 2022 The TensorFlow Authors All Rights Reserved +Copyright 2018 Google Inc. All rights reserved +Copyright 2022 The StableHLO Authors +Copyright 2015 The TensorFlow Authors. All Rights Reserved +Copyright 2015 The OpenXLA Authors +Copyright 2024 TensorFlow Authors. All Rights Reserved +Copyright (c) 2015-2020, NVIDIA CORPORATION. All rights reserved +Copyright (c) 1999 Pai-Hsiang Hsiao. All rights reserved +Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Python Software Foundation All Rights Reserved +Copyright 2022 The TensorFlow Runtime +Copyright (c) 2015-present libuv project +Copyright 2024 The TensorFlow Authors. All Rights Reserved +Copyright 2015 The Chromium Authors. All rights reserved +Copyright 2016, 2017 Tobias Grosser. All rights reserved +Copyright (c) 1996-2014 Anthony Green, Red Hat, Inc and others +copyright (c) 1991-2016, Thomas G. Lane, Guido Vollbeding. All Rights Reserved +Copyright 2019 The Bazel Authors. All rights reserved +Copyright (c) 2016 Jason R Coombs +Copyright 2023 Arm Limited and affiliates +Copyright 2015 The Bazel Authors. All rights reserved +Copyright (c) 2006 Kirill Simonov +Copyright (c) 2006, Enthought, Inc. All rights reserved +Copyright 2022-2023 IBM Corporation +Copyright 2021 Google LLC +Copyright 2021 Google Inc. All Rights Reserved +Copyright (c) 2001 - 2019, Daniel Stenberg, +Copyright (c) 2002, 2003, 2004 Francesc Altet +Copyright 2017 The TensorFlow Authors. All Rights Reserved +Copyright 2016 Google Inc. All Rights Reserved +Copyright (c) 1995-2022 The PNG Reference Library Authors +Copyright 2020 Google Inc. All Rights Reserved +Copyright 2000, 2001, 2002, 2003 Nara Institute of Science and Technology. All Rights Reserved +Copyright (c) 1991-2023 Unicode, Inc. All rights reserved +Copyright 2018 YANDEX LLC +Copyright (c) 2009-2021, Google LLC All rights reserved +Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved +Copyright (c) 2002-2008 John D. Hunter All Rights Reserved +Copyright (c) 2019 Kevin Sheppard. All rights reserved +Copyright 2024 The ML Drift +Copyright 2020 The TensorFlow Runtime +Copyright (c) 1995-2001 Corporation +Copyright 2018 The Bazel Authors. All rights reserved +Copyright 2022 Google Inc. All Rights Reserved +Copyright (c) 1991-2022 Free Software Foundation, Inc. +Copyright (c) 1998, 1999, 2017 Kungliga Tekniska Hogskolan (Royal Institute of Technology, Stockholm, Sweden) +Copyright 2023 The TensorFlow Authors +Copyright (c) 2009 The Go Authors. All rights reserved +Copyright (c) 2007, 2011 David Schultz +(c) Batch Dimensions Axes +Copyright 2021 The TensorFlow Authors. All Rights Reserved +Copyright 2018 Google Inc. All Rights Reserved +Copyright (c) 2014 Daniel Smith +Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, The Netherlands. All rights reserved +Copyright 2020 Google Inc. All rights reserved +Copyright 2015 Google Inc. All rights reserved +Copyright 2015 The Android Open Source Project +Copyright 2019 The TensorFlow Authors. All Rights Reserved +Copyright (c) 1999 TaBE Project +Copyright (c) 2013-2014, Pexpect development team +Copyright 2023 The Tensorflow Authors +Copyright (c) 1993 by Sun Microsystems, Inc. All rights reserved +Copyright (c) 2018-2022 Cosmin Truta +Copyright 2023 Arm Ltd. and affiliates +Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. +Copyright (c) 1998-2000 Glenn Randers-Pehrson +Copyright 2018 Google LLC +Copyright 2025 Google LLC. +Copyright 2020 The TensorFlow Authors All Rights Reserved +Copyright (c) 2008-2013 Andrew Collette and contributors http://www.h5py.org All rights reserved +Copyright (c) 2019 The +Copyright 2019 The OpenXLA Authors +Copyright (c) 2012 Stephen Montgomery-Smith All rights reserved + +License: Apache License + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +## Some of TensorFlow's code is derived from Caffe, which is subject to the following copyright notice: + +COPYRIGHT + +All contributions by the University of California: + +Copyright (c) 2014, The Regents of the University of California (Regents) +All rights reserved. + +All other contributions: + +Copyright (c) 2014, the respective contributors +All rights reserved. + +Caffe uses a shared copyright model: each contributor holds copyright over +their contributions to Caffe. The project versioning records all such +contribution and copyright details. If a contributor wants to further mark +their specific copyright on a particular contribution, they should indicate +their copyright solely in the commit message of the change when it is +committed. + +LICENSE + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +CONTRIBUTION AGREEMENT + +By contributing to the BVLC/caffe repository through pull-request, comment, +or otherwise, the contributor releases their content to the +license and copyright terms herein. + +Software: coremltools 4.1 +Copyright notice: +Copyright © 2020-2023, Apple Inc. All rights reserved. +License: BSD 3-Clause "New" or "Revised" License +Copyright © 2020-2023, Apple Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Software: caffe 1.0 +Copyright notice: +All contributions by the University of California: +Copyright (c) 2014-2017 The Regents of the University of California (Regents) +All rights reserved. + +All other contributions: +Copyright (c) 2014-2017, the respective contributors +All rights reserved. + +Caffe uses a shared copyright model: each contributor holds copyright over +their contributions to Caffe. The project versioning records all such +contribution and copyright details. If a contributor wants to further mark +their specific copyright on a particular contribution, they should indicate +their copyright solely in the commit message of the change when it is +committed. +License: BSD 2-Clause License +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +CONTRIBUTION AGREEMENT + +By contributing to the BVLC/caffe repository through pull-request, comment, +or otherwise, the contributor releases their content to the +license and copyright terms herein. + +Software: MNN 1.2.0 +Copyright notice: +Copyright @ 2019 Alibaba. All rights reserved. +License: Apache License + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2018] [Alibaba Group] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/mindspore-lite/src/litert/delegate/coreml/CMakeLists.txt b/mindspore-lite/src/litert/delegate/coreml/CMakeLists.txt index 859f00ee..39307c00 100644 --- a/mindspore-lite/src/litert/delegate/coreml/CMakeLists.txt +++ b/mindspore-lite/src/litert/delegate/coreml/CMakeLists.txt @@ -1,3 +1,16 @@ +include(${TOP_DIR}/cmake/utils.cmake) +__download_pkg(coreml https://gitee.com/mirrors/coremltools/repository/archive/4.1 + be3f3fa4e5b215a585b7ba98b841215c1217b1c56cf3d598550b88d552e1e036) +__download_pkg(mnn https://gitee.com/mirrors/mnn/repository/archive/1.2.0 + 613bd5cbce2b50227a4fb847de6ffafb98d8660c34f4f6819aa73f8a152581b8) +message("coreml package path:${coreml_SOURCE_DIR}") +message("mnn package path:${mnn_SOURCE_DIR}") +file(COPY ${coreml_SOURCE_DIR}/mlmodel/format/DataStructures.proto DESTINATION ${TOP_DIR}/third_party/proto/coreml) +file(COPY ${coreml_SOURCE_DIR}/mlmodel/format/FeatureTypes.proto DESTINATION ${TOP_DIR}/third_party/proto/coreml) +file(COPY ${mnn_SOURCE_DIR}/source/backend/coreml/mlmodel/proto/Model.proto + DESTINATION ${TOP_DIR}/third_party/proto/coreml) +file(COPY ${coreml_SOURCE_DIR}/mlmodel/format/NeuralNetwork.proto DESTINATION ${TOP_DIR}/third_party/proto/coreml) +file(COPY ${coreml_SOURCE_DIR}/mlmodel/format/Parameters.proto DESTINATION ${TOP_DIR}/third_party/proto/coreml) file(GLOB PROTO_FILE "" ${TOP_DIR}/third_party/proto/coreml/*.proto) ms_protobuf_generate(PROTO_SRCS PROTO_HDRS ${PROTO_FILE}) add_library(coreml_proto_mid OBJECT ${PROTO_SRCS}) diff --git a/mindspore-lite/tools/converter/CMakeLists.txt b/mindspore-lite/tools/converter/CMakeLists.txt index dbde737c..967d19ab 100644 --- a/mindspore-lite/tools/converter/CMakeLists.txt +++ b/mindspore-lite/tools/converter/CMakeLists.txt @@ -268,6 +268,58 @@ if(MSLITE_GPU_BACKEND STREQUAL opencl) ) endif() +include(${TOP_DIR}/cmake/utils.cmake) +__download_pkg(onnx https://gitee.com/mirrors/ONNX/repository/archive/v1.6.0 + 8470ee37fa44510c0ffca591bd17a0b4160ae23f5989014030456778fcb740a1) +__download_pkg(tensorflow https://gitee.com/mirrors/tensorflow/repository/archive/v2.4.1 + bc32b7046e1ad83158d99d890aafe384ef94b1d03a2c0a86859c72e264a9d885) +__download_pkg(caffe https://gitee.com/mirrors/caffe/repository/archive/1.0 + 17ae8ce8f1b4ba426e500c30efa93bc279209bea99c6ceafde49d2746bf3ef93) + +message("tf package path:${tensorflow_SOURCE_DIR}") +message("onnx package path:${onnx_SOURCE_DIR}") +message("caffe package path:${caffe_SOURCE_DIR}") + +file(COPY ${tensorflow_SOURCE_DIR}/tensorflow/core/framework/attr_value.proto + DESTINATION ${TOP_DIR}/third_party/proto/tensorflow) +file(COPY ${tensorflow_SOURCE_DIR}/tensorflow/core/framework/function.proto + DESTINATION ${TOP_DIR}/third_party/proto/tensorflow) +file(COPY ${tensorflow_SOURCE_DIR}/tensorflow/core/framework/graph.proto + DESTINATION ${TOP_DIR}/third_party/proto/tensorflow) +file(COPY ${tensorflow_SOURCE_DIR}/tensorflow/core/framework/node_def.proto + DESTINATION ${TOP_DIR}/third_party/proto/tensorflow) +file(COPY ${tensorflow_SOURCE_DIR}/tensorflow/core/framework/op_def.proto + DESTINATION ${TOP_DIR}/third_party/proto/tensorflow) +file(COPY ${tensorflow_SOURCE_DIR}/tensorflow/core/framework/resource_handle.proto + DESTINATION ${TOP_DIR}/third_party/proto/tensorflow) +file(COPY ${tensorflow_SOURCE_DIR}/tensorflow/core/framework/tensor.proto + DESTINATION ${TOP_DIR}/third_party/proto/tensorflow) +file(COPY ${tensorflow_SOURCE_DIR}/tensorflow/core/framework/tensor_shape.proto + DESTINATION ${TOP_DIR}/third_party/proto/tensorflow) +file(COPY ${tensorflow_SOURCE_DIR}/tensorflow/core/framework/types.proto + DESTINATION ${TOP_DIR}/third_party/proto/tensorflow) +file(COPY ${tensorflow_SOURCE_DIR}/tensorflow/core/framework/versions.proto + DESTINATION ${TOP_DIR}/third_party/proto/tensorflow) +file(COPY ${tensorflow_SOURCE_DIR}/tensorflow/lite/schema/schema.fbs + DESTINATION ${TOP_DIR}/third_party/proto/tensorflow/lite) +file(COPY ${onnx_SOURCE_DIR}/onnx/onnx.proto DESTINATION ${TOP_DIR}/third_party/proto/onnx) +file(COPY ${caffe_SOURCE_DIR}/src/caffe/proto/caffe.proto DESTINATION ${TOP_DIR}/third_party/proto/caffe) + +set(TENSORFLOW_PATCH_FILE ${TOP_DIR}/third_party/patch/tensorflow/tensorflow.patch) +set(CAFFE_PATCH_FILE ${TOP_DIR}/third_party/patch/caffe/caffe.patch) + +execute_process(COMMAND ${Patch_EXECUTABLE} -Np1 -i ${TENSORFLOW_PATCH_FILE} -d ${TOP_DIR} + RESULT_VARIABLE Result) +if(NOT Result EQUAL "0") + message(FATAL_ERROR "Failed patch: ${_LF_PATCH_FILE}") +endif() + +execute_process(COMMAND ${Patch_EXECUTABLE} -Np1 -i ${CAFFE_PATCH_FILE} -d ${TOP_DIR} + RESULT_VARIABLE Result) +if(NOT Result EQUAL "0") + message(FATAL_ERROR "Failed patch: ${_LF_PATCH_FILE}") +endif() + file(GLOB PROTO_FILE "" ${TOP_DIR}/third_party/proto/tensorflow/*.proto ${TOP_DIR}/third_party/proto/onnx/onnx.proto) diff --git a/third_party/patch/caffe/caffe.patch b/third_party/patch/caffe/caffe.patch new file mode 100644 index 00000000..704771e1 --- /dev/null +++ b/third_party/patch/caffe/caffe.patch @@ -0,0 +1,355 @@ +diff --git a/third_party/proto/caffe/caffe.proto b/third_party/proto/caffe/caffe.proto +index c96966b589d..163734ba6cb 100755 +# copy from https://github.com/BVLC/caffe/blob/1.0/src/caffe/proto/caffe.proto +--- a/third_party/proto/caffe/caffe.proto ++++ b/third_party/proto/caffe/caffe.proto +@@ -128,7 +128,8 @@ message SolverParameter { + // The states for the train/test nets. Must be unspecified or + // specified once per net. + // +- // By default, train_state will have phase = TRAIN, ++ // By default, all states will have solver = true; ++ // train_state will have phase = TRAIN, + // and all test_state's will have phase = TEST. + // Other defaults are set according to the NetState defaults. + optional NetState train_state = 26; +@@ -308,7 +309,7 @@ message ParamSpec { + // NOTE + // Update the next available ID when you add a new LayerParameter field. + // +-// LayerParameter next available layer-specific ID: 147 (last added: recurrent_param) ++// LayerParameter next available layer-specific ID: 151 (last added: smooth_l1_loss_param) + message LayerParameter { + optional string name = 1; // the layer name + optional string type = 2; // the layer type +@@ -369,6 +370,7 @@ message LayerParameter { + optional ConvolutionParameter convolution_param = 106; + optional CropParameter crop_param = 144; + optional DataParameter data_param = 107; ++ optional DetectionOutputParameter detection_output_param = 150; + optional DropoutParameter dropout_param = 108; + optional DummyDataParameter dummy_data_param = 109; + optional EltwiseParameter eltwise_param = 110; +@@ -391,13 +393,16 @@ message LayerParameter { + optional PoolingParameter pooling_param = 121; + optional PowerParameter power_param = 122; + optional PReLUParameter prelu_param = 131; ++ optional ProposalParameter proposal_param = 900; + optional PythonParameter python_param = 130; + optional RecurrentParameter recurrent_param = 146; + optional ReductionParameter reduction_param = 136; + optional ReLUParameter relu_param = 123; + optional ReshapeParameter reshape_param = 133; ++ optional ROIPoolingParameter roi_pooling_param = 147; + optional ScaleParameter scale_param = 142; + optional SigmoidParameter sigmoid_param = 124; ++ optional SmoothL1LossParameter smooth_l1_loss_param = 148; + optional SoftmaxParameter softmax_param = 125; + optional SPPParameter spp_param = 132; + optional SliceParameter slice_param = 126; +@@ -405,6 +410,20 @@ message LayerParameter { + optional ThresholdParameter threshold_param = 128; + optional TileParameter tile_param = 138; + optional WindowDataParameter window_data_param = 129; ++ optional PermuteParameter permute_param = 202; ++ optional PriorBoxParameter prior_box_param = 203; ++ optional NormalizeParameter norm_param = 206; ++ optional PSROIPoolingParameter psroi_pooling_param = 207; ++ optional FreespaceExtractParameter freespace_extract_param = 151; ++ optional PostprocessParameter postprocess_param = 152; ++ optional SpatialTransformParameter spatial_transform_param = 153; ++ optional ROIAlignParameter roi_align_param = 154; ++ optional ReorgParameter reorg_param = 155; ++ optional RegionParameter region_param = 156; ++ optional ReverseParameter reverse_param = 157; ++ optional InterpParameter interp_param = 158; ++ optional ShuffleChannelParameter shuffle_channel_param = 159; ++ optional UpsampleParameter upsample_param = 160; + } + + // Message that stores parameters used to apply transformation +@@ -674,6 +693,7 @@ message DataParameter { + + message DropoutParameter { + optional float dropout_ratio = 1 [default = 0.5]; // dropout ratio ++ optional bool scale_train = 2 [default = true]; // scale train or test phase + } + + // DummyDataLayer fills any number of arbitrarily shaped blobs with random +@@ -921,6 +941,13 @@ message PoolingParameter { + // If global_pooling then it will pool over the size of the bottom by doing + // kernel_h = bottom->height and kernel_w = bottom->width + optional bool global_pooling = 12 [default = false]; ++ optional bool ceil_mode = 13 [default = true]; ++ // How to calculate the output size - using ceil (default) or floor rounding. ++ enum RoundMode { ++ CEIL = 0; ++ FLOOR = 1; ++ } ++ optional RoundMode round_mode = 14 [default = CEIL]; + } + + message PowerParameter { +@@ -938,7 +965,9 @@ message PythonParameter { + // string, dictionary in Python dict format, JSON, etc. You may parse this + // string in `setup` method and use it in `forward` and `backward`. + optional string param_str = 3 [default = '']; +- // DEPRECATED ++ // Whether this PythonLayer is shared among worker solvers during data parallelism. ++ // If true, each worker solver sequentially run forward from this layer. ++ // This value should be set true if you are using it as a data layer. + optional bool share_in_parallel = 4 [default = false]; + } + +@@ -1070,6 +1099,17 @@ message ReshapeParameter { + optional int32 num_axes = 3 [default = -1]; + } + ++// Message that stores parameters used by ROIPoolingLayer ++message ROIPoolingParameter { ++ // Pad, kernel size, and stride are all given as a single value for equal ++ // dimensions in height and width or as Y, X pairs. ++ optional uint32 pooled_h = 1 [default = 0]; // The pooled output height ++ optional uint32 pooled_w = 2 [default = 0]; // The pooled output width ++ // Multiplicative spatial scale factor to translate ROI coords from their ++ // input scale to the scale used when pooling ++ optional float spatial_scale = 3 [default = 1]; ++} ++ + message ScaleParameter { + // The first axis of bottom[0] (the first input Blob) along which to apply + // bottom[1] (the second input Blob). May be negative to index from the end +@@ -1127,6 +1167,13 @@ message SliceParameter { + optional uint32 slice_dim = 1 [default = 1]; + } + ++message SmoothL1LossParameter { ++ // SmoothL1Loss(x) = ++ // 0.5 * (sigma * x) ** 2 -- if x < 1.0 / sigma / sigma ++ // |x| - 0.5 / sigma / sigma -- otherwise ++ optional float sigma = 1 [default = 1]; ++} ++ + // Message that stores parameters used by SoftmaxLayer, SoftmaxWithLossLayer + message SoftmaxParameter { + enum Engine { +@@ -1410,3 +1457,219 @@ message PReLUParameter { + // Whether or not slope parameters are shared across channels. + optional bool channel_shared = 2 [default = false]; + } ++ ++// Message that stores parameters used by ProposalLayer ++message ProposalParameter { ++ optional float feat_stride = 1; ++ optional float base_size = 2; ++ optional float min_size = 3; ++ repeated float ratio = 4; ++ repeated float scale = 5; ++ optional int32 pre_nms_topn = 6; ++ optional int32 post_nms_topn = 7; ++ optional float nms_thresh = 8; ++} ++ ++// Message that stores parameters used by DetectionOutputLayer ++//message DetectionOutputParameter { ++// optional int32 num_classes = 1 [default = 21]; ++// optional float nms_threshold = 2 [default = 0.3]; ++// optional int32 top_k = 3; ++// optional float confidence_threshold = 4 [default = 0.8]; ++//} ++ ++// Message that store parameters used by PriorBoxLayer ++message PriorBoxParameter { ++ // Encode/decode type. ++ enum CodeType { ++ CORNER = 1; ++ CENTER_SIZE = 2; ++ CORNER_SIZE = 3; ++ } ++ // Minimum box size (in pixels). Required! ++ repeated float min_size = 1; ++ // Maximum box size (in pixels). Required! ++ repeated float max_size = 2; ++ // Various of aspect ratios. Duplicate ratios will be ignored. ++ // If none is provided, we use default ratio 1. ++ repeated float aspect_ratio = 3; ++ // If true, will flip each aspect ratio. ++ // For example, if there is aspect ratio "r", ++ // we will generate aspect ratio "1.0/r" as well. ++ optional bool flip = 4 [default = true]; ++ // If true, will clip the prior so that it is within [0, 1] ++ optional bool clip = 5 [default = false]; ++ // Variance for adjusting the prior boxes. ++ repeated float variance = 6; ++ // By default, we calculate img_height, img_width, step_x, step_y based on ++ // bottom[0] (feat) and bottom[1] (img). Unless these values are explicitly ++ // provided. ++ // Explicitly provide the img_size. ++ optional uint32 img_size = 7; ++ // Either img_size or img_h/img_w should be specified; not both. ++ optional uint32 img_h = 8; ++ optional uint32 img_w = 9; ++ ++ // Explicitly provide the step size. ++ optional float step = 10; ++ // Either step or step_h/step_w should be specified; not both. ++ optional float step_h = 11; ++ optional float step_w = 12; ++ ++ // Offset to the top left corner of each cell. ++ optional float offset = 13 [default = 0.5]; ++} ++ ++// Message that stores parameters used by PermutetLayer ++message PermuteParameter { ++ // The new orders of the axes of data. Notice it should be with ++ // in the same range as the input data, and it starts from 0. ++ // Do not provide repeated order. ++ repeated uint32 order = 1; ++} ++ ++message NormalizeParameter { ++ optional bool across_spatial = 1 [default = true]; ++ // Initial value of scale. Default is 1.0 for all ++ optional FillerParameter scale_filler = 2; ++ // Whether or not scale parameters are shared across channels. ++ optional bool channel_shared = 3 [default = true]; ++ // Epsilon for not dividing by zero while normalizing variance ++ optional float eps = 4 [default = 1e-10]; ++} ++ ++// needed by ssd ++message SaveOutputParameter { ++ // Output directory. If not empty, we will save the results. ++ optional string output_directory = 1; ++ // Output name prefix. ++ optional string output_name_prefix = 2; ++ // Output format. ++ // VOC - PASCAL VOC output format. ++ // COCO - MS COCO output format. ++ optional string output_format = 3; ++ // If you want to output results, must also provide the following two files. ++ // Otherwise, we will ignore saving results. ++ // label map file. ++ optional string label_map_file = 4; ++ // A file which contains a list of names and sizes with same order ++ // of the input DB. The file is in the following format: ++ // name height width ++ // ... ++ optional string name_size_file = 5; ++ // Number of test images. It can be less than the lines specified in ++ // name_size_file. For example, when we only want to evaluate on part ++ // of the test images. ++ optional uint32 num_test_image = 6; ++ // The resize parameter used in saving the data. ++ // optional ResizeParameter resize_param = 7; ++} ++ ++message NonMaximumSuppressionParameter { ++ // Threshold to be used in nms. ++ optional float nms_threshold = 1 [default = 0.3]; ++ // Maximum number of results to be kept. ++ optional int32 top_k = 2; ++ // Parameter for adaptive nms. ++ optional float eta = 3 [default = 1.0]; ++} ++ ++message GeneralNmsParameter { ++ optional int32 post_top_k = 1 ; ++ optional float nms_threshold = 2 [default = 0]; ++ optional float iou_threshold_decay = 3 [default = 1.0]; ++ optional float coor_scale_factor = 4 [default = 1.0]; ++} ++ ++// Message that store parameters used by DetectionOutputLayer, ssd/fasterRcnn ++message DetectionOutputParameter { ++ optional int32 num_classes = 1; ++ optional bool share_location = 2 [default = true]; ++ optional int32 background_label_id = 3 [default = 0]; ++ optional NonMaximumSuppressionParameter nms_param = 4; ++ optional SaveOutputParameter save_output_param = 5; ++ optional PriorBoxParameter.CodeType code_type = 6 [default = CENTER_SIZE]; ++ optional bool variance_encoded_in_target = 8 [default = true]; ++ optional int32 keep_top_k = 7; ++ optional float confidence_threshold = 9; ++ optional float nms_threshold = 13; ++ optional int32 top_k = 14; ++ optional int32 boxes = 15 [default = 1]; ++ optional bool relative = 17 [default = true]; ++ optional float objectness_threshold = 18 [default = 0.5]; ++ optional float class_threshold = 19 [default = 0.5]; ++ repeated float biases = 20; ++ optional GeneralNmsParameter general_nms_param = 21; ++} ++message PSROIPoolingParameter { ++ required float spatial_scale = 1; ++ required int32 output_dim = 2; // output channel number ++ required int32 group_size = 3; // number of groups to encode position-sensitive score maps ++} ++// Message that stores parameters used by FreespaceExtractLayer ++message FreespaceExtractParameter { ++ optional float org_height = 1; ++} ++ ++// Message that stores parameters used by DetectpostprocessLayer ++message PostprocessParameter { ++ optional float nms_thresh = 1 [default = 0.3]; ++ optional float conf_thresh = 2 [default = 0.5]; ++ optional uint32 post_nms_topn = 3 [default = 100]; ++ optional uint32 cls_num = 4 [default = 12]; ++ repeated float bbox_reg_weights = 5; ++} ++ ++// Message that stores parameters used by SpatialTransformLayer ++message SpatialTransformParameter { ++ optional uint32 output_h = 1 [default = 0]; ++ optional uint32 output_w = 2 [default = 0]; ++ optional float border_value = 3 [default = 0]; ++ repeated float affine_transform = 4; ++ enum Engine { ++ DEFAULT = 0; ++ CAFFE = 1; ++ CUDNN = 2; ++ } ++ optional Engine engine = 15 [default = DEFAULT]; ++} ++message ROIAlignParameter { ++ // Pad, kernel size, and stride are all given as a single value for equal ++ // dimensions in height and width or as Y, X pairs. ++ optional uint32 pooled_h = 1 [default = 0]; // The pooled output height ++ optional uint32 pooled_w = 2 [default = 0]; // The pooled output width ++ // Multiplicative spatial scale factor to translate ROI coords from their ++ // input scale to the scale used when pooling ++ optional float spatial_scale = 3 [default = 1]; ++ optional int32 sampling_ratio = 4 [default = -1]; ++} ++ ++message RegionParameter { ++ optional uint32 classes = 1 [default = 20]; //分类的种类 ++ optional uint32 coords = 2 [default = 4]; //box的坐标数 ++ optional uint32 boxes = 3 [default = 1]; //每个grid预测的boxes数 ++ optional uint32 softmax = 4 [default = 0]; ++ optional string softmax_tree = 5 [default = ""]; ++ optional uint32 background = 6 [default = 0]; ++} ++message ReorgParameter{ ++ optional uint32 stride = 2 [default = 2]; ++ optional bool reverse = 1 [default = false]; ++} ++message ReverseParameter{ ++ optional int32 axis = 1 [default = 1]; ++} ++message InterpParameter{ ++ optional int32 height = 1 [default = 0];//Height of output ++ optional int32 width = 2 [default = 0];//Width of output ++ optional int32 zoom_factor = 3 [default = 1];//zoom factor ++ optional int32 shrink_factor = 4 [default = 1];//shrink factor ++ optional int32 pad_beg = 5 [default = 0];//padding at begin of input ++ optional int32 pad_end = 6 [default = 0];//padding at end of input ++} ++message ShuffleChannelParameter{ ++ optional uint32 group = 1[default = 1]; // The number of group ++} ++message UpsampleParameter{ ++ optional int32 scale = 1[default = 1]; ++} diff --git a/third_party/patch/caffe/caffe_proto_acl_quant_param.patch001 b/third_party/patch/caffe/caffe_proto_acl_quant_param.patch001 index f6353fa6..95149b7f 100644 --- a/third_party/patch/caffe/caffe_proto_acl_quant_param.patch001 +++ b/third_party/patch/caffe/caffe_proto_acl_quant_param.patch001 @@ -4,6 +4,7 @@ diff --git a/third_party/proto/caffe/caffe.proto b/third_party/proto/caffe/caffe.proto index 163734ba6c..1a2287b8a2 100755 +# modified from https://github.com/BVLC/caffe/blob/1.0/src/caffe/proto/caffe.proto --- a/third_party/proto/caffe/caffe.proto +++ b/third_party/proto/caffe/caffe.proto @@ -13,6 +13,9 @@ message BlobProto { diff --git a/third_party/patch/tensorflow/tensorflow.patch b/third_party/patch/tensorflow/tensorflow.patch new file mode 100644 index 00000000..dc5b8084 --- /dev/null +++ b/third_party/patch/tensorflow/tensorflow.patch @@ -0,0 +1,270 @@ +diff --git a/third_party/proto/tensorflow/attr_value.proto b/third_party/proto/tensorflow/attr_value.proto +index 2e913130dfd..ddf134b239c 100644 +# copy from https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/core/framework/attr_value.proto +--- a/third_party/proto/tensorflow/attr_value.proto ++++ b/third_party/proto/tensorflow/attr_value.proto +@@ -2,9 +2,9 @@ syntax = "proto3"; + + package tensorflow; + +-import "tensorflow/core/framework/tensor.proto"; +-import "tensorflow/core/framework/tensor_shape.proto"; +-import "tensorflow/core/framework/types.proto"; ++import "tensor.proto"; ++import "tensor_shape.proto"; ++import "types.proto"; + + option cc_enable_arenas = true; + option java_outer_classname = "AttrValueProtos"; +diff --git a/third_party/proto/tensorflow/function.proto b/third_party/proto/tensorflow/function.proto +index 6d43c05f52c..8502ae5c494 100644 +# copy from https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/core/framework/function.proto +--- a/third_party/proto/tensorflow/function.proto ++++ b/third_party/proto/tensorflow/function.proto +@@ -2,9 +2,9 @@ syntax = "proto3"; + + package tensorflow; + +-import "tensorflow/core/framework/attr_value.proto"; +-import "tensorflow/core/framework/node_def.proto"; +-import "tensorflow/core/framework/op_def.proto"; ++import "attr_value.proto"; ++import "node_def.proto"; ++import "op_def.proto"; + + option cc_enable_arenas = true; + option java_outer_classname = "FunctionProtos"; +diff --git a/third_party/proto/tensorflow/graph.proto b/third_party/proto/tensorflow/graph.proto +index f49e41aa0b0..13a05d89ea5 100644 +# copy from https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/core/framework/graph.proto +--- a/third_party/proto/tensorflow/graph.proto ++++ b/third_party/proto/tensorflow/graph.proto +@@ -2,9 +2,9 @@ syntax = "proto3"; + + package tensorflow; + +-import "tensorflow/core/framework/function.proto"; +-import "tensorflow/core/framework/node_def.proto"; +-import "tensorflow/core/framework/versions.proto"; ++import "function.proto"; ++import "node_def.proto"; ++import "versions.proto"; + + option cc_enable_arenas = true; + option java_outer_classname = "GraphProtos"; +diff --git a/third_party/proto/tensorflow/node_def.proto b/third_party/proto/tensorflow/node_def.proto +index c0dc6836977..17d8ecf684b 100644 +# copy from https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/core/framework/node_def.proto +--- a/third_party/proto/tensorflow/node_def.proto ++++ b/third_party/proto/tensorflow/node_def.proto +@@ -2,7 +2,7 @@ syntax = "proto3"; + + package tensorflow; + +-import "tensorflow/core/framework/attr_value.proto"; ++import "attr_value.proto"; + + option cc_enable_arenas = true; + option java_outer_classname = "NodeProto"; +diff --git a/third_party/proto/tensorflow/op_def.proto b/third_party/proto/tensorflow/op_def.proto +index ad109a3b814..3b2396cbe21 100644 +# copy from https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/core/framework/op_def.proto +--- a/third_party/proto/tensorflow/op_def.proto ++++ b/third_party/proto/tensorflow/op_def.proto +@@ -6,8 +6,8 @@ option java_outer_classname = "OpDefProtos"; + option java_multiple_files = true; + option java_package = "org.tensorflow.framework"; + option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/op_def_go_proto"; +-import "tensorflow/core/framework/attr_value.proto"; +-import "tensorflow/core/framework/types.proto"; ++import "attr_value.proto"; ++import "types.proto"; + + // Defines an operation. A NodeDef in a GraphDef specifies an Op by + // using the "op" field which should match the name of a OpDef. +diff --git a/third_party/proto/tensorflow/resource_handle.proto b/third_party/proto/tensorflow/resource_handle.proto +index 5a41750475d..e2bce956547 100644 +# copy from https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/core/framework/resource_handle.proto +--- a/third_party/proto/tensorflow/resource_handle.proto ++++ b/third_party/proto/tensorflow/resource_handle.proto +@@ -2,8 +2,8 @@ syntax = "proto3"; + + package tensorflow; + +-import "tensorflow/core/framework/tensor_shape.proto"; +-import "tensorflow/core/framework/types.proto"; ++import "tensor_shape.proto"; ++import "types.proto"; + + option cc_enable_arenas = true; + option java_outer_classname = "ResourceHandle"; +diff --git a/third_party/proto/tensorflow/lite/schema.fbs b/third_party/proto/tensorflow/lite/schema.fbs +index 62045344755..a8bdf5e067a 100644 +# copy from https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/lite/schema/schema.fbs +--- a/third_party/proto/tensorflow/lite/schema.fbs ++++ b/third_party/proto/tensorflow/lite/schema.fbs +@@ -17,8 +17,6 @@ + // Version 1: Add subgraphs to schema. + // Version 2: Rename operators to conform to NN API. + // Version 3: Move buffer data from Model.Subgraph.Tensors to Model.Buffers. +-// Version 3a: Add new builtin op code field. Has backward compatibility with +-// version 3. + + namespace tflite; + +@@ -43,7 +41,6 @@ enum TensorType : byte { + COMPLEX64 = 8, + INT8 = 9, + FLOAT64 = 10, +- COMPLEX128 = 11, + } + + // Custom quantization parameters for experimenting with new quantization +@@ -217,7 +214,7 @@ table Tensor { + // object containing configuration parameters, builtins have a predetermined + // set of acceptable options. + +-enum BuiltinOperator : int32 { ++enum BuiltinOperator : byte { + ADD = 0, + AVERAGE_POOL_2D = 1, + CONCATENATION = 2, +@@ -250,6 +247,7 @@ enum BuiltinOperator : int32 { + SPACE_TO_DEPTH = 26, + SVDF = 27, + TANH = 28, ++ // Consider rename to CONCATENATE_EMBEDDINGS + CONCAT_EMBEDDINGS = 29, + SKIP_GRAM = 30, + CALL = 31, +@@ -350,9 +348,7 @@ enum BuiltinOperator : int32 { + SELECT_V2 = 123, + DENSIFY = 124, + SEGMENT_SUM = 125, +- BATCH_MATMUL = 126, +- PLACEHOLDER_FOR_GREATER_OP_CODES = 127, +- CUMSUM = 128 ++ BATCH_MATMUL = 126 + } + + +@@ -458,8 +454,7 @@ union BuiltinOptions { + SelectV2Options, + DensifyOptions, + SegmentSumOptions, +- BatchMatMulOptions, +- CumsumOptions, ++ BatchMatMulOptions + } + + enum Padding : byte { SAME, VALID } +@@ -587,8 +582,6 @@ table ConcatenationOptions { + + table AddOptions { + fused_activation_function:ActivationFunctionType; +- // Parameters supported by version 4. +- pot_scale_int16:bool = true; + } + + table MulOptions { +@@ -710,8 +703,6 @@ table DepthToSpaceOptions { + + table SubOptions { + fused_activation_function:ActivationFunctionType; +- // Parameters supported by version 5 +- pot_scale_int16:bool = true; + } + + table DivOptions { +@@ -983,29 +974,15 @@ table BatchMatMulOptions { + adj_y:bool; + } + +-table CumsumOptions { +- exclusive:bool; +- reverse:bool; +-} +- + // An OperatorCode can be an enum value (BuiltinOperator) if the operator is a + // builtin, or a string if the operator is custom. + table OperatorCode { +- // This field is for backward compatibility. This field will be used when +- // the value of the extended builtin_code field has less than +- // BulitinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES. +- deprecated_builtin_code:byte; ++ builtin_code:BuiltinOperator; + custom_code:string; + + // The version of the operator. The version need to be bumped whenever new + // parameters are introduced into an op. + version:int = 1; +- +- // This field is introduced for resolving op builtin code shortage problem +- // (the original BuiltinOperator enum field was represented as a byte). +- // This field will be used when the value of the extended builtin_code field +- // has greater than BulitinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES. +- builtin_code:BuiltinOperator; + } + + enum CustomOptionsFormat : byte { +@@ -1084,32 +1061,6 @@ table Metadata { + buffer:uint; + } + +-// Map from an alias name of tensor to tensor index in the graph. +-// This is used in Signature def. +-table TensorMap { +- // Represents the alias to use for this tensor. +- name:string; +- +- // The actual tensor index in the primary graph, that 'name' corresponds to. +- tensor_index:uint; +-} +- +-// This corresponds to SignatureDef in Tensorflow SavedModel. +-// The SignatureDef will be part of the SavedModel provided for conversion. +-table SignatureDef { +- // Named inputs for this signature. +- inputs:[TensorMap]; +- +- // Named outputs for this signature. +- outputs:[TensorMap]; +- +- // Exported method name for this signature. +- method_name:string; +- +- // Key value which was in the Tensorflow SavedModel SignatureDef map. +- key:string; +-} +- + table Model { + // Version of the schema. + version:uint; +@@ -1138,9 +1089,6 @@ table Model { + + // Metadata about the model. + metadata:[Metadata]; +- +- // Optional SignatureDefs for the model. +- signature_defs:[SignatureDef]; + } + + root_type Model; +diff --git a/third_party/proto/tensorflow/tensor.proto b/third_party/proto/tensorflow/tensor.proto +index 47b694f4361..7a25c446e68 100644 +# copy from https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/core/framework/tensor.proto +--- a/third_party/proto/tensorflow/tensor.proto ++++ b/third_party/proto/tensorflow/tensor.proto +@@ -2,9 +2,9 @@ syntax = "proto3"; + + package tensorflow; + +-import "tensorflow/core/framework/resource_handle.proto"; +-import "tensorflow/core/framework/tensor_shape.proto"; +-import "tensorflow/core/framework/types.proto"; ++import "resource_handle.proto"; ++import "tensor_shape.proto"; ++import "types.proto"; + + option cc_enable_arenas = true; + option java_outer_classname = "TensorProtos"; diff --git a/third_party/proto/caffe/LICENSE b/third_party/proto/caffe/LICENSE deleted file mode 100644 index 0c99adc1..00000000 --- a/third_party/proto/caffe/LICENSE +++ /dev/null @@ -1,44 +0,0 @@ -COPYRIGHT - -All contributions by the University of California: -Copyright (c) 2014-2017 The Regents of the University of California (Regents) -All rights reserved. - -All other contributions: -Copyright (c) 2014-2017, the respective contributors -All rights reserved. - -Caffe uses a shared copyright model: each contributor holds copyright over -their contributions to Caffe. The project versioning records all such -contribution and copyright details. If a contributor wants to further mark -their specific copyright on a particular contribution, they should indicate -their copyright solely in the commit message of the change when it is -committed. - -LICENSE - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -CONTRIBUTION AGREEMENT - -By contributing to the BVLC/caffe repository through pull-request, comment, -or otherwise, the contributor releases their content to the -license and copyright terms herein. diff --git a/third_party/proto/caffe/caffe.proto b/third_party/proto/caffe/caffe.proto deleted file mode 100755 index 163734ba..00000000 --- a/third_party/proto/caffe/caffe.proto +++ /dev/null @@ -1,1675 +0,0 @@ -syntax = "proto2"; - -package caffe; - -// Specifies the shape (dimensions) of a Blob. -message BlobShape { - repeated int64 dim = 1 [packed = true]; -} - -message BlobProto { - optional BlobShape shape = 7; - repeated float data = 5 [packed = true]; - repeated float diff = 6 [packed = true]; - repeated double double_data = 8 [packed = true]; - repeated double double_diff = 9 [packed = true]; - - // 4D dimensions -- deprecated. Use "shape" instead. - optional int32 num = 1 [default = 0]; - optional int32 channels = 2 [default = 0]; - optional int32 height = 3 [default = 0]; - optional int32 width = 4 [default = 0]; -} - -// The BlobProtoVector is simply a way to pass multiple blobproto instances -// around. -message BlobProtoVector { - repeated BlobProto blobs = 1; -} - -message Datum { - optional int32 channels = 1; - optional int32 height = 2; - optional int32 width = 3; - // the actual image data, in bytes - optional bytes data = 4; - optional int32 label = 5; - // Optionally, the datum could also hold float data. - repeated float float_data = 6; - // If true data contains an encoded image that need to be decoded - optional bool encoded = 7 [default = false]; -} - -message FillerParameter { - // The filler type. - optional string type = 1 [default = 'constant']; - optional float value = 2 [default = 0]; // the value in constant filler - optional float min = 3 [default = 0]; // the min value in uniform filler - optional float max = 4 [default = 1]; // the max value in uniform filler - optional float mean = 5 [default = 0]; // the mean value in Gaussian filler - optional float std = 6 [default = 1]; // the std value in Gaussian filler - // The expected number of non-zero output weights for a given input in - // Gaussian filler -- the default -1 means don't perform sparsification. - optional int32 sparse = 7 [default = -1]; - // Normalize the filler variance by fan_in, fan_out, or their average. - // Applies to 'xavier' and 'msra' fillers. - enum VarianceNorm { - FAN_IN = 0; - FAN_OUT = 1; - AVERAGE = 2; - } - optional VarianceNorm variance_norm = 8 [default = FAN_IN]; -} - -message NetParameter { - optional string name = 1; // consider giving the network a name - // DEPRECATED. See InputParameter. The input blobs to the network. - repeated string input = 3; - // DEPRECATED. See InputParameter. The shape of the input blobs. - repeated BlobShape input_shape = 8; - - // 4D input dimensions -- deprecated. Use "input_shape" instead. - // If specified, for each input blob there should be four - // values specifying the num, channels, height and width of the input blob. - // Thus, there should be a total of (4 * #input) numbers. - repeated int32 input_dim = 4; - - // Whether the network will force every layer to carry out backward operation. - // If set False, then whether to carry out backward is determined - // automatically according to the net structure and learning rates. - optional bool force_backward = 5 [default = false]; - // The current "state" of the network, including the phase, level, and stage. - // Some layers may be included/excluded depending on this state and the states - // specified in the layers' include and exclude fields. - optional NetState state = 6; - - // Print debugging information about results while running Net::Forward, - // Net::Backward, and Net::Update. - optional bool debug_info = 7 [default = false]; - - // The layers that make up the net. Each of their configurations, including - // connectivity and behavior, is specified as a LayerParameter. - repeated LayerParameter layer = 100; // ID 100 so layers are printed last. - - // DEPRECATED: use 'layer' instead. - repeated V1LayerParameter layers = 2; -} - -// NOTE -// Update the next available ID when you add a new SolverParameter field. -// -// SolverParameter next available ID: 42 (last added: layer_wise_reduce) -message SolverParameter { - ////////////////////////////////////////////////////////////////////////////// - // Specifying the train and test networks - // - // Exactly one train net must be specified using one of the following fields: - // train_net_param, train_net, net_param, net - // One or more test nets may be specified using any of the following fields: - // test_net_param, test_net, net_param, net - // If more than one test net field is specified (e.g., both net and - // test_net are specified), they will be evaluated in the field order given - // above: (1) test_net_param, (2) test_net, (3) net_param/net. - // A test_iter must be specified for each test_net. - // A test_level and/or a test_stage may also be specified for each test_net. - ////////////////////////////////////////////////////////////////////////////// - - // Proto filename for the train net, possibly combined with one or more - // test nets. - optional string net = 24; - // Inline train net param, possibly combined with one or more test nets. - optional NetParameter net_param = 25; - - optional string train_net = 1; // Proto filename for the train net. - repeated string test_net = 2; // Proto filenames for the test nets. - optional NetParameter train_net_param = 21; // Inline train net params. - repeated NetParameter test_net_param = 22; // Inline test net params. - - // The states for the train/test nets. Must be unspecified or - // specified once per net. - // - // By default, all states will have solver = true; - // train_state will have phase = TRAIN, - // and all test_state's will have phase = TEST. - // Other defaults are set according to the NetState defaults. - optional NetState train_state = 26; - repeated NetState test_state = 27; - - // The number of iterations for each test net. - repeated int32 test_iter = 3; - - // The number of iterations between two testing phases. - optional int32 test_interval = 4 [default = 0]; - optional bool test_compute_loss = 19 [default = false]; - // If true, run an initial test pass before the first iteration, - // ensuring memory availability and printing the starting value of the loss. - optional bool test_initialization = 32 [default = true]; - optional float base_lr = 5; // The base learning rate - // the number of iterations between displaying info. If display = 0, no info - // will be displayed. - optional int32 display = 6; - // Display the loss averaged over the last average_loss iterations - optional int32 average_loss = 33 [default = 1]; - optional int32 max_iter = 7; // the maximum number of iterations - // accumulate gradients over `iter_size` x `batch_size` instances - optional int32 iter_size = 36 [default = 1]; - - // The learning rate decay policy. The currently implemented learning rate - // policies are as follows: - // - fixed: always return base_lr. - // - step: return base_lr * gamma ^ (floor(iter / step)) - // - exp: return base_lr * gamma ^ iter - // - inv: return base_lr * (1 + gamma * iter) ^ (- power) - // - multistep: similar to step but it allows non uniform steps defined by - // stepvalue - // - poly: the effective learning rate follows a polynomial decay, to be - // zero by the max_iter. return base_lr (1 - iter/max_iter) ^ (power) - // - sigmoid: the effective learning rate follows a sigmod decay - // return base_lr ( 1/(1 + exp(-gamma * (iter - stepsize)))) - // - // where base_lr, max_iter, gamma, step, stepvalue and power are defined - // in the solver parameter protocol buffer, and iter is the current iteration. - optional string lr_policy = 8; - optional float gamma = 9; // The parameter to compute the learning rate. - optional float power = 10; // The parameter to compute the learning rate. - optional float momentum = 11; // The momentum value. - optional float weight_decay = 12; // The weight decay. - // regularization types supported: L1 and L2 - // controlled by weight_decay - optional string regularization_type = 29 [default = "L2"]; - // the stepsize for learning rate policy "step" - optional int32 stepsize = 13; - // the stepsize for learning rate policy "multistep" - repeated int32 stepvalue = 34; - - // Set clip_gradients to >= 0 to clip parameter gradients to that L2 norm, - // whenever their actual L2 norm is larger. - optional float clip_gradients = 35 [default = -1]; - - optional int32 snapshot = 14 [default = 0]; // The snapshot interval - optional string snapshot_prefix = 15; // The prefix for the snapshot. - // whether to snapshot diff in the results or not. Snapshotting diff will help - // debugging but the final protocol buffer size will be much larger. - optional bool snapshot_diff = 16 [default = false]; - enum SnapshotFormat { - HDF5 = 0; - BINARYPROTO = 1; - } - optional SnapshotFormat snapshot_format = 37 [default = BINARYPROTO]; - // the mode solver will use: 0 for CPU and 1 for GPU. Use GPU in default. - enum SolverMode { - CPU = 0; - GPU = 1; - } - optional SolverMode solver_mode = 17 [default = GPU]; - // the device_id will that be used in GPU mode. Use device_id = 0 in default. - optional int32 device_id = 18 [default = 0]; - // If non-negative, the seed with which the Solver will initialize the Caffe - // random number generator -- useful for reproducible results. Otherwise, - // (and by default) initialize using a seed derived from the system clock. - optional int64 random_seed = 20 [default = -1]; - - // type of the solver - optional string type = 40 [default = "SGD"]; - - // numerical stability for RMSProp, AdaGrad and AdaDelta and Adam - optional float delta = 31 [default = 1e-8]; - // parameters for the Adam solver - optional float momentum2 = 39 [default = 0.999]; - - // RMSProp decay value - // MeanSquare(t) = rms_decay*MeanSquare(t-1) + (1-rms_decay)*SquareGradient(t) - optional float rms_decay = 38 [default = 0.99]; - - // If true, print information about the state of the net that may help with - // debugging learning problems. - optional bool debug_info = 23 [default = false]; - - // If false, don't save a snapshot after training finishes. - optional bool snapshot_after_train = 28 [default = true]; - - // DEPRECATED: old solver enum types, use string instead - enum SolverType { - SGD = 0; - NESTEROV = 1; - ADAGRAD = 2; - RMSPROP = 3; - ADADELTA = 4; - ADAM = 5; - } - // DEPRECATED: use type instead of solver_type - optional SolverType solver_type = 30 [default = SGD]; - - // Overlap compute and communication for data parallel training - optional bool layer_wise_reduce = 41 [default = true]; -} - -// A message that stores the solver snapshots -message SolverState { - optional int32 iter = 1; // The current iteration - optional string learned_net = 2; // The file that stores the learned net. - repeated BlobProto history = 3; // The history for sgd solvers - optional int32 current_step = 4 [default = 0]; // The current step for learning rate -} - -enum Phase { - TRAIN = 0; - TEST = 1; -} - -message NetState { - optional Phase phase = 1 [default = TEST]; - optional int32 level = 2 [default = 0]; - repeated string stage = 3; -} - -message NetStateRule { - // Set phase to require the NetState have a particular phase (TRAIN or TEST) - // to meet this rule. - optional Phase phase = 1; - - // Set the minimum and/or maximum levels in which the layer should be used. - // Leave undefined to meet the rule regardless of level. - optional int32 min_level = 2; - optional int32 max_level = 3; - - // Customizable sets of stages to include or exclude. - // The net must have ALL of the specified stages and NONE of the specified - // "not_stage"s to meet the rule. - // (Use multiple NetStateRules to specify conjunctions of stages.) - repeated string stage = 4; - repeated string not_stage = 5; -} - -// Specifies training parameters (multipliers on global learning constants, -// and the name and other settings used for weight sharing). -message ParamSpec { - // The names of the parameter blobs -- useful for sharing parameters among - // layers, but never required otherwise. To share a parameter between two - // layers, give it a (non-empty) name. - optional string name = 1; - - // Whether to require shared weights to have the same shape, or just the same - // count -- defaults to STRICT if unspecified. - optional DimCheckMode share_mode = 2; - enum DimCheckMode { - // STRICT (default) requires that num, channels, height, width each match. - STRICT = 0; - // PERMISSIVE requires only the count (num*channels*height*width) to match. - PERMISSIVE = 1; - } - - // The multiplier on the global learning rate for this parameter. - optional float lr_mult = 3 [default = 1.0]; - - // The multiplier on the global weight decay for this parameter. - optional float decay_mult = 4 [default = 1.0]; -} - -// NOTE -// Update the next available ID when you add a new LayerParameter field. -// -// LayerParameter next available layer-specific ID: 151 (last added: smooth_l1_loss_param) -message LayerParameter { - optional string name = 1; // the layer name - optional string type = 2; // the layer type - repeated string bottom = 3; // the name of each bottom blob - repeated string top = 4; // the name of each top blob - - // The train / test phase for computation. - optional Phase phase = 10; - - // The amount of weight to assign each top blob in the objective. - // Each layer assigns a default value, usually of either 0 or 1, - // to each top blob. - repeated float loss_weight = 5; - - // Specifies training parameters (multipliers on global learning constants, - // and the name and other settings used for weight sharing). - repeated ParamSpec param = 6; - - // The blobs containing the numeric parameters of the layer. - repeated BlobProto blobs = 7; - - // Specifies whether to backpropagate to each bottom. If unspecified, - // Caffe will automatically infer whether each input needs backpropagation - // to compute parameter gradients. If set to true for some inputs, - // backpropagation to those inputs is forced; if set false for some inputs, - // backpropagation to those inputs is skipped. - // - // The size must be either 0 or equal to the number of bottoms. - repeated bool propagate_down = 11; - - // Rules controlling whether and when a layer is included in the network, - // based on the current NetState. You may specify a non-zero number of rules - // to include OR exclude, but not both. If no include or exclude rules are - // specified, the layer is always included. If the current NetState meets - // ANY (i.e., one or more) of the specified rules, the layer is - // included/excluded. - repeated NetStateRule include = 8; - repeated NetStateRule exclude = 9; - - // Parameters for data pre-processing. - optional TransformationParameter transform_param = 100; - - // Parameters shared by loss layers. - optional LossParameter loss_param = 101; - - // Layer type-specific parameters. - // - // Note: certain layers may have more than one computational engine - // for their implementation. These layers include an Engine type and - // engine parameter for selecting the implementation. - // The default for the engine is set by the ENGINE switch at compile-time. - optional AccuracyParameter accuracy_param = 102; - optional ArgMaxParameter argmax_param = 103; - optional BatchNormParameter batch_norm_param = 139; - optional BiasParameter bias_param = 141; - optional ConcatParameter concat_param = 104; - optional ContrastiveLossParameter contrastive_loss_param = 105; - optional ConvolutionParameter convolution_param = 106; - optional CropParameter crop_param = 144; - optional DataParameter data_param = 107; - optional DetectionOutputParameter detection_output_param = 150; - optional DropoutParameter dropout_param = 108; - optional DummyDataParameter dummy_data_param = 109; - optional EltwiseParameter eltwise_param = 110; - optional ELUParameter elu_param = 140; - optional EmbedParameter embed_param = 137; - optional ExpParameter exp_param = 111; - optional FlattenParameter flatten_param = 135; - optional HDF5DataParameter hdf5_data_param = 112; - optional HDF5OutputParameter hdf5_output_param = 113; - optional HingeLossParameter hinge_loss_param = 114; - optional ImageDataParameter image_data_param = 115; - optional InfogainLossParameter infogain_loss_param = 116; - optional InnerProductParameter inner_product_param = 117; - optional InputParameter input_param = 143; - optional LogParameter log_param = 134; - optional LRNParameter lrn_param = 118; - optional MemoryDataParameter memory_data_param = 119; - optional MVNParameter mvn_param = 120; - optional ParameterParameter parameter_param = 145; - optional PoolingParameter pooling_param = 121; - optional PowerParameter power_param = 122; - optional PReLUParameter prelu_param = 131; - optional ProposalParameter proposal_param = 900; - optional PythonParameter python_param = 130; - optional RecurrentParameter recurrent_param = 146; - optional ReductionParameter reduction_param = 136; - optional ReLUParameter relu_param = 123; - optional ReshapeParameter reshape_param = 133; - optional ROIPoolingParameter roi_pooling_param = 147; - optional ScaleParameter scale_param = 142; - optional SigmoidParameter sigmoid_param = 124; - optional SmoothL1LossParameter smooth_l1_loss_param = 148; - optional SoftmaxParameter softmax_param = 125; - optional SPPParameter spp_param = 132; - optional SliceParameter slice_param = 126; - optional TanHParameter tanh_param = 127; - optional ThresholdParameter threshold_param = 128; - optional TileParameter tile_param = 138; - optional WindowDataParameter window_data_param = 129; - optional PermuteParameter permute_param = 202; - optional PriorBoxParameter prior_box_param = 203; - optional NormalizeParameter norm_param = 206; - optional PSROIPoolingParameter psroi_pooling_param = 207; - optional FreespaceExtractParameter freespace_extract_param = 151; - optional PostprocessParameter postprocess_param = 152; - optional SpatialTransformParameter spatial_transform_param = 153; - optional ROIAlignParameter roi_align_param = 154; - optional ReorgParameter reorg_param = 155; - optional RegionParameter region_param = 156; - optional ReverseParameter reverse_param = 157; - optional InterpParameter interp_param = 158; - optional ShuffleChannelParameter shuffle_channel_param = 159; - optional UpsampleParameter upsample_param = 160; -} - -// Message that stores parameters used to apply transformation -// to the data layer's data -message TransformationParameter { - // For data pre-processing, we can do simple scaling and subtracting the - // data mean, if provided. Note that the mean subtraction is always carried - // out before scaling. - optional float scale = 1 [default = 1]; - // Specify if we want to randomly mirror data. - optional bool mirror = 2 [default = false]; - // Specify if we would like to randomly crop an image. - optional uint32 crop_size = 3 [default = 0]; - // mean_file and mean_value cannot be specified at the same time - optional string mean_file = 4; - // if specified can be repeated once (would subtract it from all the channels) - // or can be repeated the same number of times as channels - // (would subtract them from the corresponding channel) - repeated float mean_value = 5; - // Force the decoded image to have 3 color channels. - optional bool force_color = 6 [default = false]; - // Force the decoded image to have 1 color channels. - optional bool force_gray = 7 [default = false]; -} - -// Message that stores parameters shared by loss layers -message LossParameter { - // If specified, ignore instances with the given label. - optional int32 ignore_label = 1; - // How to normalize the loss for loss layers that aggregate across batches, - // spatial dimensions, or other dimensions. Currently only implemented in - // SoftmaxWithLoss and SigmoidCrossEntropyLoss layers. - enum NormalizationMode { - // Divide by the number of examples in the batch times spatial dimensions. - // Outputs that receive the ignore label will NOT be ignored in computing - // the normalization factor. - FULL = 0; - // Divide by the total number of output locations that do not take the - // ignore_label. If ignore_label is not set, this behaves like FULL. - VALID = 1; - // Divide by the batch size. - BATCH_SIZE = 2; - // Do not normalize the loss. - NONE = 3; - } - // For historical reasons, the default normalization for - // SigmoidCrossEntropyLoss is BATCH_SIZE and *not* VALID. - optional NormalizationMode normalization = 3 [default = VALID]; - // Deprecated. Ignored if normalization is specified. If normalization - // is not specified, then setting this to false will be equivalent to - // normalization = BATCH_SIZE to be consistent with previous behavior. - optional bool normalize = 2; -} - -// Messages that store parameters used by individual layer types follow, in -// alphabetical order. - -message AccuracyParameter { - // When computing accuracy, count as correct by comparing the true label to - // the top k scoring classes. By default, only compare to the top scoring - // class (i.e. argmax). - optional uint32 top_k = 1 [default = 1]; - - // The "label" axis of the prediction blob, whose argmax corresponds to the - // predicted label -- may be negative to index from the end (e.g., -1 for the - // last axis). For example, if axis == 1 and the predictions are - // (N x C x H x W), the label blob is expected to contain N*H*W ground truth - // labels with integer values in {0, 1, ..., C-1}. - optional int32 axis = 2 [default = 1]; - - // If specified, ignore instances with the given label. - optional int32 ignore_label = 3; -} - -message ArgMaxParameter { - // If true produce pairs (argmax, maxval) - optional bool out_max_val = 1 [default = false]; - optional uint32 top_k = 2 [default = 1]; - // The axis along which to maximise -- may be negative to index from the - // end (e.g., -1 for the last axis). - // By default ArgMaxLayer maximizes over the flattened trailing dimensions - // for each index of the first / num dimension. - optional int32 axis = 3; -} - -message ConcatParameter { - // The axis along which to concatenate -- may be negative to index from the - // end (e.g., -1 for the last axis). Other axes must have the - // same dimension for all the bottom blobs. - // By default, ConcatLayer concatenates blobs along the "channels" axis (1). - optional int32 axis = 2 [default = 1]; - - // DEPRECATED: alias for "axis" -- does not support negative indexing. - optional uint32 concat_dim = 1 [default = 1]; -} - -message BatchNormParameter { - // If false, normalization is performed over the current mini-batch - // and global statistics are accumulated (but not yet used) by a moving - // average. - // If true, those accumulated mean and variance values are used for the - // normalization. - // By default, it is set to false when the network is in the training - // phase and true when the network is in the testing phase. - optional bool use_global_stats = 1; - // What fraction of the moving average remains each iteration? - // Smaller values make the moving average decay faster, giving more - // weight to the recent values. - // Each iteration updates the moving average @f$S_{t-1}@f$ with the - // current mean @f$ Y_t @f$ by - // @f$ S_t = (1-\beta)Y_t + \beta \cdot S_{t-1} @f$, where @f$ \beta @f$ - // is the moving_average_fraction parameter. - optional float moving_average_fraction = 2 [default = .999]; - // Small value to add to the variance estimate so that we don't divide by - // zero. - optional float eps = 3 [default = 1e-5]; -} - -message BiasParameter { - // The first axis of bottom[0] (the first input Blob) along which to apply - // bottom[1] (the second input Blob). May be negative to index from the end - // (e.g., -1 for the last axis). - // - // For example, if bottom[0] is 4D with shape 100x3x40x60, the output - // top[0] will have the same shape, and bottom[1] may have any of the - // following shapes (for the given value of axis): - // (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60 - // (axis == 1 == -3) 3; 3x40; 3x40x60 - // (axis == 2 == -2) 40; 40x60 - // (axis == 3 == -1) 60 - // Furthermore, bottom[1] may have the empty shape (regardless of the value of - // "axis") -- a scalar bias. - optional int32 axis = 1 [default = 1]; - - // (num_axes is ignored unless just one bottom is given and the bias is - // a learned parameter of the layer. Otherwise, num_axes is determined by the - // number of axes by the second bottom.) - // The number of axes of the input (bottom[0]) covered by the bias - // parameter, or -1 to cover all axes of bottom[0] starting from `axis`. - // Set num_axes := 0, to add a zero-axis Blob: a scalar. - optional int32 num_axes = 2 [default = 1]; - - // (filler is ignored unless just one bottom is given and the bias is - // a learned parameter of the layer.) - // The initialization for the learned bias parameter. - // Default is the zero (0) initialization, resulting in the BiasLayer - // initially performing the identity operation. - optional FillerParameter filler = 3; -} - -message ContrastiveLossParameter { - // margin for dissimilar pair - optional float margin = 1 [default = 1.0]; - // The first implementation of this cost did not exactly match the cost of - // Hadsell et al 2006 -- using (margin - d^2) instead of (margin - d)^2. - // legacy_version = false (the default) uses (margin - d)^2 as proposed in the - // Hadsell paper. New models should probably use this version. - // legacy_version = true uses (margin - d^2). This is kept to support / - // reproduce existing models and results - optional bool legacy_version = 2 [default = false]; -} - -message ConvolutionParameter { - optional uint32 num_output = 1; // The number of outputs for the layer - optional bool bias_term = 2 [default = true]; // whether to have bias terms - - // Pad, kernel size, and stride are all given as a single value for equal - // dimensions in all spatial dimensions, or once per spatial dimension. - repeated uint32 pad = 3; // The padding size; defaults to 0 - repeated uint32 kernel_size = 4; // The kernel size - repeated uint32 stride = 6; // The stride; defaults to 1 - // Factor used to dilate the kernel, (implicitly) zero-filling the resulting - // holes. (Kernel dilation is sometimes referred to by its use in the - // algorithme à trous from Holschneider et al. 1987.) - repeated uint32 dilation = 18; // The dilation; defaults to 1 - - // For 2D convolution only, the *_h and *_w versions may also be used to - // specify both spatial dimensions. - optional uint32 pad_h = 9 [default = 0]; // The padding height (2D only) - optional uint32 pad_w = 10 [default = 0]; // The padding width (2D only) - optional uint32 kernel_h = 11; // The kernel height (2D only) - optional uint32 kernel_w = 12; // The kernel width (2D only) - optional uint32 stride_h = 13; // The stride height (2D only) - optional uint32 stride_w = 14; // The stride width (2D only) - - optional uint32 group = 5 [default = 1]; // The group size for group conv - - optional FillerParameter weight_filler = 7; // The filler for the weight - optional FillerParameter bias_filler = 8; // The filler for the bias - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 15 [default = DEFAULT]; - - // The axis to interpret as "channels" when performing convolution. - // Preceding dimensions are treated as independent inputs; - // succeeding dimensions are treated as "spatial". - // With (N, C, H, W) inputs, and axis == 1 (the default), we perform - // N independent 2D convolutions, sliding C-channel (or (C/g)-channels, for - // groups g>1) filters across the spatial axes (H, W) of the input. - // With (N, C, D, H, W) inputs, and axis == 1, we perform - // N independent 3D convolutions, sliding (C/g)-channels - // filters across the spatial axes (D, H, W) of the input. - optional int32 axis = 16 [default = 1]; - - // Whether to force use of the general ND convolution, even if a specific - // implementation for blobs of the appropriate number of spatial dimensions - // is available. (Currently, there is only a 2D-specific convolution - // implementation; for input blobs with num_axes != 2, this option is - // ignored and the ND implementation will be used.) - optional bool force_nd_im2col = 17 [default = false]; -} - -message CropParameter { - // To crop, elements of the first bottom are selected to fit the dimensions - // of the second, reference bottom. The crop is configured by - // - the crop `axis` to pick the dimensions for cropping - // - the crop `offset` to set the shift for all/each dimension - // to align the cropped bottom with the reference bottom. - // All dimensions up to but excluding `axis` are preserved, while - // the dimensions including and trailing `axis` are cropped. - // If only one `offset` is set, then all dimensions are offset by this amount. - // Otherwise, the number of offsets must equal the number of cropped axes to - // shift the crop in each dimension accordingly. - // Note: standard dimensions are N,C,H,W so the default is a spatial crop, - // and `axis` may be negative to index from the end (e.g., -1 for the last - // axis). - optional int32 axis = 1 [default = 2]; - repeated uint32 offset = 2; -} - -message DataParameter { - enum DB { - LEVELDB = 0; - LMDB = 1; - } - // Specify the data source. - optional string source = 1; - // Specify the batch size. - optional uint32 batch_size = 4; - // The rand_skip variable is for the data layer to skip a few data points - // to avoid all asynchronous sgd clients to start at the same point. The skip - // point would be set as rand_skip * rand(0,1). Note that rand_skip should not - // be larger than the number of keys in the database. - // DEPRECATED. Each solver accesses a different subset of the database. - optional uint32 rand_skip = 7 [default = 0]; - optional DB backend = 8 [default = LEVELDB]; - // DEPRECATED. See TransformationParameter. For data pre-processing, we can do - // simple scaling and subtracting the data mean, if provided. Note that the - // mean subtraction is always carried out before scaling. - optional float scale = 2 [default = 1]; - optional string mean_file = 3; - // DEPRECATED. See TransformationParameter. Specify if we would like to randomly - // crop an image. - optional uint32 crop_size = 5 [default = 0]; - // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror - // data. - optional bool mirror = 6 [default = false]; - // Force the encoded image to have 3 color channels - optional bool force_encoded_color = 9 [default = false]; - // Prefetch queue (Increase if data feeding bandwidth varies, within the - // limit of device memory for GPU training) - optional uint32 prefetch = 10 [default = 4]; -} - -message DropoutParameter { - optional float dropout_ratio = 1 [default = 0.5]; // dropout ratio - optional bool scale_train = 2 [default = true]; // scale train or test phase -} - -// DummyDataLayer fills any number of arbitrarily shaped blobs with random -// (or constant) data generated by "Fillers" (see "message FillerParameter"). -message DummyDataParameter { - // This layer produces N >= 1 top blobs. DummyDataParameter must specify 1 or N - // shape fields, and 0, 1 or N data_fillers. - // - // If 0 data_fillers are specified, ConstantFiller with a value of 0 is used. - // If 1 data_filler is specified, it is applied to all top blobs. If N are - // specified, the ith is applied to the ith top blob. - repeated FillerParameter data_filler = 1; - repeated BlobShape shape = 6; - - // 4D dimensions -- deprecated. Use "shape" instead. - repeated uint32 num = 2; - repeated uint32 channels = 3; - repeated uint32 height = 4; - repeated uint32 width = 5; -} - -message EltwiseParameter { - enum EltwiseOp { - PROD = 0; - SUM = 1; - MAX = 2; - } - optional EltwiseOp operation = 1 [default = SUM]; // element-wise operation - repeated float coeff = 2; // blob-wise coefficient for SUM operation - - // Whether to use an asymptotically slower (for >2 inputs) but stabler method - // of computing the gradient for the PROD operation. (No effect for SUM op.) - optional bool stable_prod_grad = 3 [default = true]; -} - -// Message that stores parameters used by ELULayer -message ELUParameter { - // Described in: - // Clevert, D.-A., Unterthiner, T., & Hochreiter, S. (2015). Fast and Accurate - // Deep Network Learning by Exponential Linear Units (ELUs). arXiv - optional float alpha = 1 [default = 1]; -} - -// Message that stores parameters used by EmbedLayer -message EmbedParameter { - optional uint32 num_output = 1; // The number of outputs for the layer - // The input is given as integers to be interpreted as one-hot - // vector indices with dimension num_input. Hence num_input should be - // 1 greater than the maximum possible input value. - optional uint32 input_dim = 2; - - optional bool bias_term = 3 [default = true]; // Whether to use a bias term - optional FillerParameter weight_filler = 4; // The filler for the weight - optional FillerParameter bias_filler = 5; // The filler for the bias - -} - -// Message that stores parameters used by ExpLayer -message ExpParameter { - // ExpLayer computes outputs y = base ^ (shift + scale * x), for base > 0. - // Or if base is set to the default (-1), base is set to e, - // so y = exp(shift + scale * x). - optional float base = 1 [default = -1.0]; - optional float scale = 2 [default = 1.0]; - optional float shift = 3 [default = 0.0]; -} - -/// Message that stores parameters used by FlattenLayer -message FlattenParameter { - // The first axis to flatten: all preceding axes are retained in the output. - // May be negative to index from the end (e.g., -1 for the last axis). - optional int32 axis = 1 [default = 1]; - - // The last axis to flatten: all following axes are retained in the output. - // May be negative to index from the end (e.g., the default -1 for the last - // axis). - optional int32 end_axis = 2 [default = -1]; -} - -// Message that stores parameters used by HDF5DataLayer -message HDF5DataParameter { - // Specify the data source. - optional string source = 1; - // Specify the batch size. - optional uint32 batch_size = 2; - - // Specify whether to shuffle the data. - // If shuffle == true, the ordering of the HDF5 files is shuffled, - // and the ordering of data within any given HDF5 file is shuffled, - // but data between different files are not interleaved; all of a file's - // data are output (in a random order) before moving onto another file. - optional bool shuffle = 3 [default = false]; -} - -message HDF5OutputParameter { - optional string file_name = 1; -} - -message HingeLossParameter { - enum Norm { - L1 = 1; - L2 = 2; - } - // Specify the Norm to use L1 or L2 - optional Norm norm = 1 [default = L1]; -} - -message ImageDataParameter { - // Specify the data source. - optional string source = 1; - // Specify the batch size. - optional uint32 batch_size = 4 [default = 1]; - // The rand_skip variable is for the data layer to skip a few data points - // to avoid all asynchronous sgd clients to start at the same point. The skip - // point would be set as rand_skip * rand(0,1). Note that rand_skip should not - // be larger than the number of keys in the database. - optional uint32 rand_skip = 7 [default = 0]; - // Whether or not ImageLayer should shuffle the list of files at every epoch. - optional bool shuffle = 8 [default = false]; - // It will also resize images if new_height or new_width are not zero. - optional uint32 new_height = 9 [default = 0]; - optional uint32 new_width = 10 [default = 0]; - // Specify if the images are color or gray - optional bool is_color = 11 [default = true]; - // DEPRECATED. See TransformationParameter. For data pre-processing, we can do - // simple scaling and subtracting the data mean, if provided. Note that the - // mean subtraction is always carried out before scaling. - optional float scale = 2 [default = 1]; - optional string mean_file = 3; - // DEPRECATED. See TransformationParameter. Specify if we would like to randomly - // crop an image. - optional uint32 crop_size = 5 [default = 0]; - // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror - // data. - optional bool mirror = 6 [default = false]; - optional string root_folder = 12 [default = ""]; -} - -message InfogainLossParameter { - // Specify the infogain matrix source. - optional string source = 1; - optional int32 axis = 2 [default = 1]; // axis of prob -} - -message InnerProductParameter { - optional uint32 num_output = 1; // The number of outputs for the layer - optional bool bias_term = 2 [default = true]; // whether to have bias terms - optional FillerParameter weight_filler = 3; // The filler for the weight - optional FillerParameter bias_filler = 4; // The filler for the bias - - // The first axis to be lumped into a single inner product computation; - // all preceding axes are retained in the output. - // May be negative to index from the end (e.g., -1 for the last axis). - optional int32 axis = 5 [default = 1]; - // Specify whether to transpose the weight matrix or not. - // If transpose == true, any operations will be performed on the transpose - // of the weight matrix. The weight matrix itself is not going to be transposed - // but rather the transfer flag of operations will be toggled accordingly. - optional bool transpose = 6 [default = false]; -} - -message InputParameter { - // This layer produces N >= 1 top blob(s) to be assigned manually. - // Define N shapes to set a shape for each top. - // Define 1 shape to set the same shape for every top. - // Define no shape to defer to reshaping manually. - repeated BlobShape shape = 1; -} - -// Message that stores parameters used by LogLayer -message LogParameter { - // LogLayer computes outputs y = log_base(shift + scale * x), for base > 0. - // Or if base is set to the default (-1), base is set to e, - // so y = ln(shift + scale * x) = log_e(shift + scale * x) - optional float base = 1 [default = -1.0]; - optional float scale = 2 [default = 1.0]; - optional float shift = 3 [default = 0.0]; -} - -// Message that stores parameters used by LRNLayer -message LRNParameter { - optional uint32 local_size = 1 [default = 5]; - optional float alpha = 2 [default = 1.]; - optional float beta = 3 [default = 0.75]; - enum NormRegion { - ACROSS_CHANNELS = 0; - WITHIN_CHANNEL = 1; - } - optional NormRegion norm_region = 4 [default = ACROSS_CHANNELS]; - optional float k = 5 [default = 1.]; - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 6 [default = DEFAULT]; -} - -message MemoryDataParameter { - optional uint32 batch_size = 1; - optional uint32 channels = 2; - optional uint32 height = 3; - optional uint32 width = 4; -} - -message MVNParameter { - // This parameter can be set to false to normalize mean only - optional bool normalize_variance = 1 [default = true]; - - // This parameter can be set to true to perform DNN-like MVN - optional bool across_channels = 2 [default = false]; - - // Epsilon for not dividing by zero while normalizing variance - optional float eps = 3 [default = 1e-9]; -} - -message ParameterParameter { - optional BlobShape shape = 1; -} - -message PoolingParameter { - enum PoolMethod { - MAX = 0; - AVE = 1; - STOCHASTIC = 2; - } - optional PoolMethod pool = 1 [default = MAX]; // The pooling method - // Pad, kernel size, and stride are all given as a single value for equal - // dimensions in height and width or as Y, X pairs. - optional uint32 pad = 4 [default = 0]; // The padding size (equal in Y, X) - optional uint32 pad_h = 9 [default = 0]; // The padding height - optional uint32 pad_w = 10 [default = 0]; // The padding width - optional uint32 kernel_size = 2; // The kernel size (square) - optional uint32 kernel_h = 5; // The kernel height - optional uint32 kernel_w = 6; // The kernel width - optional uint32 stride = 3 [default = 1]; // The stride (equal in Y, X) - optional uint32 stride_h = 7; // The stride height - optional uint32 stride_w = 8; // The stride width - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 11 [default = DEFAULT]; - // If global_pooling then it will pool over the size of the bottom by doing - // kernel_h = bottom->height and kernel_w = bottom->width - optional bool global_pooling = 12 [default = false]; - optional bool ceil_mode = 13 [default = true]; - // How to calculate the output size - using ceil (default) or floor rounding. - enum RoundMode { - CEIL = 0; - FLOOR = 1; - } - optional RoundMode round_mode = 14 [default = CEIL]; -} - -message PowerParameter { - // PowerLayer computes outputs y = (shift + scale * x) ^ power. - optional float power = 1 [default = 1.0]; - optional float scale = 2 [default = 1.0]; - optional float shift = 3 [default = 0.0]; -} - -message PythonParameter { - optional string module = 1; - optional string layer = 2; - // This value is set to the attribute `param_str` of the `PythonLayer` object - // in Python before calling the `setup()` method. This could be a number, - // string, dictionary in Python dict format, JSON, etc. You may parse this - // string in `setup` method and use it in `forward` and `backward`. - optional string param_str = 3 [default = '']; - // Whether this PythonLayer is shared among worker solvers during data parallelism. - // If true, each worker solver sequentially run forward from this layer. - // This value should be set true if you are using it as a data layer. - optional bool share_in_parallel = 4 [default = false]; -} - -// Message that stores parameters used by RecurrentLayer -message RecurrentParameter { - // The dimension of the output (and usually hidden state) representation -- - // must be explicitly set to non-zero. - optional uint32 num_output = 1 [default = 0]; - - optional FillerParameter weight_filler = 2; // The filler for the weight - optional FillerParameter bias_filler = 3; // The filler for the bias - - // Whether to enable displaying debug_info in the unrolled recurrent net. - optional bool debug_info = 4 [default = false]; - - // Whether to add as additional inputs (bottoms) the initial hidden state - // blobs, and add as additional outputs (tops) the final timestep hidden state - // blobs. The number of additional bottom/top blobs required depends on the - // recurrent architecture -- e.g., 1 for RNNs, 2 for LSTMs. - optional bool expose_hidden = 5 [default = false]; -} - -// Message that stores parameters used by ReductionLayer -message ReductionParameter { - enum ReductionOp { - SUM = 1; - ASUM = 2; - SUMSQ = 3; - MEAN = 4; - } - - optional ReductionOp operation = 1 [default = SUM]; // reduction operation - - // The first axis to reduce to a scalar -- may be negative to index from the - // end (e.g., -1 for the last axis). - // (Currently, only reduction along ALL "tail" axes is supported; reduction - // of axis M through N, where N < num_axes - 1, is unsupported.) - // Suppose we have an n-axis bottom Blob with shape: - // (d0, d1, d2, ..., d(m-1), dm, d(m+1), ..., d(n-1)). - // If axis == m, the output Blob will have shape - // (d0, d1, d2, ..., d(m-1)), - // and the ReductionOp operation is performed (d0 * d1 * d2 * ... * d(m-1)) - // times, each including (dm * d(m+1) * ... * d(n-1)) individual data. - // If axis == 0 (the default), the output Blob always has the empty shape - // (count 1), performing reduction across the entire input -- - // often useful for creating new loss functions. - optional int32 axis = 2 [default = 0]; - - optional float coeff = 3 [default = 1.0]; // coefficient for output -} - -// Message that stores parameters used by ReLULayer -message ReLUParameter { - // Allow non-zero slope for negative inputs to speed up optimization - // Described in: - // Maas, A. L., Hannun, A. Y., & Ng, A. Y. (2013). Rectifier nonlinearities - // improve neural network acoustic models. In ICML Workshop on Deep Learning - // for Audio, Speech, and Language Processing. - optional float negative_slope = 1 [default = 0]; - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 2 [default = DEFAULT]; -} - -message ReshapeParameter { - // Specify the output dimensions. If some of the dimensions are set to 0, - // the corresponding dimension from the bottom layer is used (unchanged). - // Exactly one dimension may be set to -1, in which case its value is - // inferred from the count of the bottom blob and the remaining dimensions. - // For example, suppose we want to reshape a 2D blob "input" with shape 2 x 8: - // - // layer { - // type: "Reshape" bottom: "input" top: "output" - // reshape_param { ... } - // } - // - // If "input" is 2D with shape 2 x 8, then the following reshape_param - // specifications are all equivalent, producing a 3D blob "output" with shape - // 2 x 2 x 4: - // - // reshape_param { shape { dim: 2 dim: 2 dim: 4 } } - // reshape_param { shape { dim: 0 dim: 2 dim: 4 } } - // reshape_param { shape { dim: 0 dim: 2 dim: -1 } } - // reshape_param { shape { dim: 0 dim:-1 dim: 4 } } - // - optional BlobShape shape = 1; - - // axis and num_axes control the portion of the bottom blob's shape that are - // replaced by (included in) the reshape. By default (axis == 0 and - // num_axes == -1), the entire bottom blob shape is included in the reshape, - // and hence the shape field must specify the entire output shape. - // - // axis may be non-zero to retain some portion of the beginning of the input - // shape (and may be negative to index from the end; e.g., -1 to begin the - // reshape after the last axis, including nothing in the reshape, - // -2 to include only the last axis, etc.). - // - // For example, suppose "input" is a 2D blob with shape 2 x 8. - // Then the following ReshapeLayer specifications are all equivalent, - // producing a blob "output" with shape 2 x 2 x 4: - // - // reshape_param { shape { dim: 2 dim: 2 dim: 4 } } - // reshape_param { shape { dim: 2 dim: 4 } axis: 1 } - // reshape_param { shape { dim: 2 dim: 4 } axis: -3 } - // - // num_axes specifies the extent of the reshape. - // If num_axes >= 0 (and axis >= 0), the reshape will be performed only on - // input axes in the range [axis, axis+num_axes]. - // num_axes may also be -1, the default, to include all remaining axes - // (starting from axis). - // - // For example, suppose "input" is a 2D blob with shape 2 x 8. - // Then the following ReshapeLayer specifications are equivalent, - // producing a blob "output" with shape 1 x 2 x 8. - // - // reshape_param { shape { dim: 1 dim: 2 dim: 8 } } - // reshape_param { shape { dim: 1 dim: 2 } num_axes: 1 } - // reshape_param { shape { dim: 1 } num_axes: 0 } - // - // On the other hand, these would produce output blob shape 2 x 1 x 8: - // - // reshape_param { shape { dim: 2 dim: 1 dim: 8 } } - // reshape_param { shape { dim: 1 } axis: 1 num_axes: 0 } - // - optional int32 axis = 2 [default = 0]; - optional int32 num_axes = 3 [default = -1]; -} - -// Message that stores parameters used by ROIPoolingLayer -message ROIPoolingParameter { - // Pad, kernel size, and stride are all given as a single value for equal - // dimensions in height and width or as Y, X pairs. - optional uint32 pooled_h = 1 [default = 0]; // The pooled output height - optional uint32 pooled_w = 2 [default = 0]; // The pooled output width - // Multiplicative spatial scale factor to translate ROI coords from their - // input scale to the scale used when pooling - optional float spatial_scale = 3 [default = 1]; -} - -message ScaleParameter { - // The first axis of bottom[0] (the first input Blob) along which to apply - // bottom[1] (the second input Blob). May be negative to index from the end - // (e.g., -1 for the last axis). - // - // For example, if bottom[0] is 4D with shape 100x3x40x60, the output - // top[0] will have the same shape, and bottom[1] may have any of the - // following shapes (for the given value of axis): - // (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60 - // (axis == 1 == -3) 3; 3x40; 3x40x60 - // (axis == 2 == -2) 40; 40x60 - // (axis == 3 == -1) 60 - // Furthermore, bottom[1] may have the empty shape (regardless of the value of - // "axis") -- a scalar multiplier. - optional int32 axis = 1 [default = 1]; - - // (num_axes is ignored unless just one bottom is given and the scale is - // a learned parameter of the layer. Otherwise, num_axes is determined by the - // number of axes by the second bottom.) - // The number of axes of the input (bottom[0]) covered by the scale - // parameter, or -1 to cover all axes of bottom[0] starting from `axis`. - // Set num_axes := 0, to multiply with a zero-axis Blob: a scalar. - optional int32 num_axes = 2 [default = 1]; - - // (filler is ignored unless just one bottom is given and the scale is - // a learned parameter of the layer.) - // The initialization for the learned scale parameter. - // Default is the unit (1) initialization, resulting in the ScaleLayer - // initially performing the identity operation. - optional FillerParameter filler = 3; - - // Whether to also learn a bias (equivalent to a ScaleLayer+BiasLayer, but - // may be more efficient). Initialized with bias_filler (defaults to 0). - optional bool bias_term = 4 [default = false]; - optional FillerParameter bias_filler = 5; -} - -message SigmoidParameter { - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 1 [default = DEFAULT]; -} - -message SliceParameter { - // The axis along which to slice -- may be negative to index from the end - // (e.g., -1 for the last axis). - // By default, SliceLayer concatenates blobs along the "channels" axis (1). - optional int32 axis = 3 [default = 1]; - repeated uint32 slice_point = 2; - - // DEPRECATED: alias for "axis" -- does not support negative indexing. - optional uint32 slice_dim = 1 [default = 1]; -} - -message SmoothL1LossParameter { - // SmoothL1Loss(x) = - // 0.5 * (sigma * x) ** 2 -- if x < 1.0 / sigma / sigma - // |x| - 0.5 / sigma / sigma -- otherwise - optional float sigma = 1 [default = 1]; -} - -// Message that stores parameters used by SoftmaxLayer, SoftmaxWithLossLayer -message SoftmaxParameter { - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 1 [default = DEFAULT]; - - // The axis along which to perform the softmax -- may be negative to index - // from the end (e.g., -1 for the last axis). - // Any other axes will be evaluated as independent softmaxes. - optional int32 axis = 2 [default = 1]; -} - -message TanHParameter { - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 1 [default = DEFAULT]; -} - -// Message that stores parameters used by TileLayer -message TileParameter { - // The index of the axis to tile. - optional int32 axis = 1 [default = 1]; - - // The number of copies (tiles) of the blob to output. - optional int32 tiles = 2; -} - -// Message that stores parameters used by ThresholdLayer -message ThresholdParameter { - optional float threshold = 1 [default = 0]; // Strictly positive values -} - -message WindowDataParameter { - // Specify the data source. - optional string source = 1; - // For data pre-processing, we can do simple scaling and subtracting the - // data mean, if provided. Note that the mean subtraction is always carried - // out before scaling. - optional float scale = 2 [default = 1]; - optional string mean_file = 3; - // Specify the batch size. - optional uint32 batch_size = 4; - // Specify if we would like to randomly crop an image. - optional uint32 crop_size = 5 [default = 0]; - // Specify if we want to randomly mirror data. - optional bool mirror = 6 [default = false]; - // Foreground (object) overlap threshold - optional float fg_threshold = 7 [default = 0.5]; - // Background (non-object) overlap threshold - optional float bg_threshold = 8 [default = 0.5]; - // Fraction of batch that should be foreground objects - optional float fg_fraction = 9 [default = 0.25]; - // Amount of contextual padding to add around a window - // (used only by the window_data_layer) - optional uint32 context_pad = 10 [default = 0]; - // Mode for cropping out a detection window - // warp: cropped window is warped to a fixed size and aspect ratio - // square: the tightest square around the window is cropped - optional string crop_mode = 11 [default = "warp"]; - // cache_images: will load all images in memory for faster access - optional bool cache_images = 12 [default = false]; - // append root_folder to locate images - optional string root_folder = 13 [default = ""]; -} - -message SPPParameter { - enum PoolMethod { - MAX = 0; - AVE = 1; - STOCHASTIC = 2; - } - optional uint32 pyramid_height = 1; - optional PoolMethod pool = 2 [default = MAX]; // The pooling method - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 6 [default = DEFAULT]; -} - -// DEPRECATED: use LayerParameter. -message V1LayerParameter { - repeated string bottom = 2; - repeated string top = 3; - optional string name = 4; - repeated NetStateRule include = 32; - repeated NetStateRule exclude = 33; - enum LayerType { - NONE = 0; - ABSVAL = 35; - ACCURACY = 1; - ARGMAX = 30; - BNLL = 2; - CONCAT = 3; - CONTRASTIVE_LOSS = 37; - CONVOLUTION = 4; - DATA = 5; - DECONVOLUTION = 39; - DROPOUT = 6; - DUMMY_DATA = 32; - EUCLIDEAN_LOSS = 7; - ELTWISE = 25; - EXP = 38; - FLATTEN = 8; - HDF5_DATA = 9; - HDF5_OUTPUT = 10; - HINGE_LOSS = 28; - IM2COL = 11; - IMAGE_DATA = 12; - INFOGAIN_LOSS = 13; - INNER_PRODUCT = 14; - LRN = 15; - MEMORY_DATA = 29; - MULTINOMIAL_LOGISTIC_LOSS = 16; - MVN = 34; - POOLING = 17; - POWER = 26; - RELU = 18; - SIGMOID = 19; - SIGMOID_CROSS_ENTROPY_LOSS = 27; - SILENCE = 36; - SOFTMAX = 20; - SOFTMAX_LOSS = 21; - SPLIT = 22; - SLICE = 33; - TANH = 23; - WINDOW_DATA = 24; - THRESHOLD = 31; - } - optional LayerType type = 5; - repeated BlobProto blobs = 6; - repeated string param = 1001; - repeated DimCheckMode blob_share_mode = 1002; - enum DimCheckMode { - STRICT = 0; - PERMISSIVE = 1; - } - repeated float blobs_lr = 7; - repeated float weight_decay = 8; - repeated float loss_weight = 35; - optional AccuracyParameter accuracy_param = 27; - optional ArgMaxParameter argmax_param = 23; - optional ConcatParameter concat_param = 9; - optional ContrastiveLossParameter contrastive_loss_param = 40; - optional ConvolutionParameter convolution_param = 10; - optional DataParameter data_param = 11; - optional DropoutParameter dropout_param = 12; - optional DummyDataParameter dummy_data_param = 26; - optional EltwiseParameter eltwise_param = 24; - optional ExpParameter exp_param = 41; - optional HDF5DataParameter hdf5_data_param = 13; - optional HDF5OutputParameter hdf5_output_param = 14; - optional HingeLossParameter hinge_loss_param = 29; - optional ImageDataParameter image_data_param = 15; - optional InfogainLossParameter infogain_loss_param = 16; - optional InnerProductParameter inner_product_param = 17; - optional LRNParameter lrn_param = 18; - optional MemoryDataParameter memory_data_param = 22; - optional MVNParameter mvn_param = 34; - optional PoolingParameter pooling_param = 19; - optional PowerParameter power_param = 21; - optional ReLUParameter relu_param = 30; - optional SigmoidParameter sigmoid_param = 38; - optional SoftmaxParameter softmax_param = 39; - optional SliceParameter slice_param = 31; - optional TanHParameter tanh_param = 37; - optional ThresholdParameter threshold_param = 25; - optional WindowDataParameter window_data_param = 20; - optional TransformationParameter transform_param = 36; - optional LossParameter loss_param = 42; - optional V0LayerParameter layer = 1; -} - -// DEPRECATED: V0LayerParameter is the old way of specifying layer parameters -// in Caffe. We keep this message type around for legacy support. -message V0LayerParameter { - optional string name = 1; // the layer name - optional string type = 2; // the string to specify the layer type - - // Parameters to specify layers with inner products. - optional uint32 num_output = 3; // The number of outputs for the layer - optional bool biasterm = 4 [default = true]; // whether to have bias terms - optional FillerParameter weight_filler = 5; // The filler for the weight - optional FillerParameter bias_filler = 6; // The filler for the bias - - optional uint32 pad = 7 [default = 0]; // The padding size - optional uint32 kernelsize = 8; // The kernel size - optional uint32 group = 9 [default = 1]; // The group size for group conv - optional uint32 stride = 10 [default = 1]; // The stride - enum PoolMethod { - MAX = 0; - AVE = 1; - STOCHASTIC = 2; - } - optional PoolMethod pool = 11 [default = MAX]; // The pooling method - optional float dropout_ratio = 12 [default = 0.5]; // dropout ratio - - optional uint32 local_size = 13 [default = 5]; // for local response norm - optional float alpha = 14 [default = 1.]; // for local response norm - optional float beta = 15 [default = 0.75]; // for local response norm - optional float k = 22 [default = 1.]; - - // For data layers, specify the data source - optional string source = 16; - // For data pre-processing, we can do simple scaling and subtracting the - // data mean, if provided. Note that the mean subtraction is always carried - // out before scaling. - optional float scale = 17 [default = 1]; - optional string meanfile = 18; - // For data layers, specify the batch size. - optional uint32 batchsize = 19; - // For data layers, specify if we would like to randomly crop an image. - optional uint32 cropsize = 20 [default = 0]; - // For data layers, specify if we want to randomly mirror data. - optional bool mirror = 21 [default = false]; - - // The blobs containing the numeric parameters of the layer - repeated BlobProto blobs = 50; - // The ratio that is multiplied on the global learning rate. If you want to - // set the learning ratio for one blob, you need to set it for all blobs. - repeated float blobs_lr = 51; - // The weight decay that is multiplied on the global weight decay. - repeated float weight_decay = 52; - - // The rand_skip variable is for the data layer to skip a few data points - // to avoid all asynchronous sgd clients to start at the same point. The skip - // point would be set as rand_skip * rand(0,1). Note that rand_skip should not - // be larger than the number of keys in the database. - optional uint32 rand_skip = 53 [default = 0]; - - // Fields related to detection (det_*) - // foreground (object) overlap threshold - optional float det_fg_threshold = 54 [default = 0.5]; - // background (non-object) overlap threshold - optional float det_bg_threshold = 55 [default = 0.5]; - // Fraction of batch that should be foreground objects - optional float det_fg_fraction = 56 [default = 0.25]; - - // optional bool OBSOLETE_can_clobber = 57 [default = true]; - - // Amount of contextual padding to add around a window - // (used only by the window_data_layer) - optional uint32 det_context_pad = 58 [default = 0]; - - // Mode for cropping out a detection window - // warp: cropped window is warped to a fixed size and aspect ratio - // square: the tightest square around the window is cropped - optional string det_crop_mode = 59 [default = "warp"]; - - // For ReshapeLayer, one needs to specify the new dimensions. - optional int32 new_num = 60 [default = 0]; - optional int32 new_channels = 61 [default = 0]; - optional int32 new_height = 62 [default = 0]; - optional int32 new_width = 63 [default = 0]; - - // Whether or not ImageLayer should shuffle the list of files at every epoch. - // It will also resize images if new_height or new_width are not zero. - optional bool shuffle_images = 64 [default = false]; - - // For ConcatLayer, one needs to specify the dimension for concatenation, and - // the other dimensions must be the same for all the bottom blobs. - // By default it will concatenate blobs along the channels dimension. - optional uint32 concat_dim = 65 [default = 1]; - - optional HDF5OutputParameter hdf5_output_param = 1001; -} - -message PReLUParameter { - // Parametric ReLU described in K. He et al, Delving Deep into Rectifiers: - // Surpassing Human-Level Performance on ImageNet Classification, 2015. - - // Initial value of a_i. Default is a_i=0.25 for all i. - optional FillerParameter filler = 1; - // Whether or not slope parameters are shared across channels. - optional bool channel_shared = 2 [default = false]; -} - -// Message that stores parameters used by ProposalLayer -message ProposalParameter { - optional float feat_stride = 1; - optional float base_size = 2; - optional float min_size = 3; - repeated float ratio = 4; - repeated float scale = 5; - optional int32 pre_nms_topn = 6; - optional int32 post_nms_topn = 7; - optional float nms_thresh = 8; -} - -// Message that stores parameters used by DetectionOutputLayer -//message DetectionOutputParameter { -// optional int32 num_classes = 1 [default = 21]; -// optional float nms_threshold = 2 [default = 0.3]; -// optional int32 top_k = 3; -// optional float confidence_threshold = 4 [default = 0.8]; -//} - -// Message that store parameters used by PriorBoxLayer -message PriorBoxParameter { - // Encode/decode type. - enum CodeType { - CORNER = 1; - CENTER_SIZE = 2; - CORNER_SIZE = 3; - } - // Minimum box size (in pixels). Required! - repeated float min_size = 1; - // Maximum box size (in pixels). Required! - repeated float max_size = 2; - // Various of aspect ratios. Duplicate ratios will be ignored. - // If none is provided, we use default ratio 1. - repeated float aspect_ratio = 3; - // If true, will flip each aspect ratio. - // For example, if there is aspect ratio "r", - // we will generate aspect ratio "1.0/r" as well. - optional bool flip = 4 [default = true]; - // If true, will clip the prior so that it is within [0, 1] - optional bool clip = 5 [default = false]; - // Variance for adjusting the prior boxes. - repeated float variance = 6; - // By default, we calculate img_height, img_width, step_x, step_y based on - // bottom[0] (feat) and bottom[1] (img). Unless these values are explicitly - // provided. - // Explicitly provide the img_size. - optional uint32 img_size = 7; - // Either img_size or img_h/img_w should be specified; not both. - optional uint32 img_h = 8; - optional uint32 img_w = 9; - - // Explicitly provide the step size. - optional float step = 10; - // Either step or step_h/step_w should be specified; not both. - optional float step_h = 11; - optional float step_w = 12; - - // Offset to the top left corner of each cell. - optional float offset = 13 [default = 0.5]; -} - -// Message that stores parameters used by PermutetLayer -message PermuteParameter { - // The new orders of the axes of data. Notice it should be with - // in the same range as the input data, and it starts from 0. - // Do not provide repeated order. - repeated uint32 order = 1; -} - -message NormalizeParameter { - optional bool across_spatial = 1 [default = true]; - // Initial value of scale. Default is 1.0 for all - optional FillerParameter scale_filler = 2; - // Whether or not scale parameters are shared across channels. - optional bool channel_shared = 3 [default = true]; - // Epsilon for not dividing by zero while normalizing variance - optional float eps = 4 [default = 1e-10]; -} - -// needed by ssd -message SaveOutputParameter { - // Output directory. If not empty, we will save the results. - optional string output_directory = 1; - // Output name prefix. - optional string output_name_prefix = 2; - // Output format. - // VOC - PASCAL VOC output format. - // COCO - MS COCO output format. - optional string output_format = 3; - // If you want to output results, must also provide the following two files. - // Otherwise, we will ignore saving results. - // label map file. - optional string label_map_file = 4; - // A file which contains a list of names and sizes with same order - // of the input DB. The file is in the following format: - // name height width - // ... - optional string name_size_file = 5; - // Number of test images. It can be less than the lines specified in - // name_size_file. For example, when we only want to evaluate on part - // of the test images. - optional uint32 num_test_image = 6; - // The resize parameter used in saving the data. - // optional ResizeParameter resize_param = 7; -} - -message NonMaximumSuppressionParameter { - // Threshold to be used in nms. - optional float nms_threshold = 1 [default = 0.3]; - // Maximum number of results to be kept. - optional int32 top_k = 2; - // Parameter for adaptive nms. - optional float eta = 3 [default = 1.0]; -} - -message GeneralNmsParameter { - optional int32 post_top_k = 1 ; - optional float nms_threshold = 2 [default = 0]; - optional float iou_threshold_decay = 3 [default = 1.0]; - optional float coor_scale_factor = 4 [default = 1.0]; -} - -// Message that store parameters used by DetectionOutputLayer, ssd/fasterRcnn -message DetectionOutputParameter { - optional int32 num_classes = 1; - optional bool share_location = 2 [default = true]; - optional int32 background_label_id = 3 [default = 0]; - optional NonMaximumSuppressionParameter nms_param = 4; - optional SaveOutputParameter save_output_param = 5; - optional PriorBoxParameter.CodeType code_type = 6 [default = CENTER_SIZE]; - optional bool variance_encoded_in_target = 8 [default = true]; - optional int32 keep_top_k = 7; - optional float confidence_threshold = 9; - optional float nms_threshold = 13; - optional int32 top_k = 14; - optional int32 boxes = 15 [default = 1]; - optional bool relative = 17 [default = true]; - optional float objectness_threshold = 18 [default = 0.5]; - optional float class_threshold = 19 [default = 0.5]; - repeated float biases = 20; - optional GeneralNmsParameter general_nms_param = 21; -} -message PSROIPoolingParameter { - required float spatial_scale = 1; - required int32 output_dim = 2; // output channel number - required int32 group_size = 3; // number of groups to encode position-sensitive score maps -} -// Message that stores parameters used by FreespaceExtractLayer -message FreespaceExtractParameter { - optional float org_height = 1; -} - -// Message that stores parameters used by DetectpostprocessLayer -message PostprocessParameter { - optional float nms_thresh = 1 [default = 0.3]; - optional float conf_thresh = 2 [default = 0.5]; - optional uint32 post_nms_topn = 3 [default = 100]; - optional uint32 cls_num = 4 [default = 12]; - repeated float bbox_reg_weights = 5; -} - -// Message that stores parameters used by SpatialTransformLayer -message SpatialTransformParameter { - optional uint32 output_h = 1 [default = 0]; - optional uint32 output_w = 2 [default = 0]; - optional float border_value = 3 [default = 0]; - repeated float affine_transform = 4; - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 15 [default = DEFAULT]; -} -message ROIAlignParameter { - // Pad, kernel size, and stride are all given as a single value for equal - // dimensions in height and width or as Y, X pairs. - optional uint32 pooled_h = 1 [default = 0]; // The pooled output height - optional uint32 pooled_w = 2 [default = 0]; // The pooled output width - // Multiplicative spatial scale factor to translate ROI coords from their - // input scale to the scale used when pooling - optional float spatial_scale = 3 [default = 1]; - optional int32 sampling_ratio = 4 [default = -1]; -} - -message RegionParameter { - optional uint32 classes = 1 [default = 20]; //分类的种类 - optional uint32 coords = 2 [default = 4]; //box的坐标数 - optional uint32 boxes = 3 [default = 1]; //每个grid预测的boxes数 - optional uint32 softmax = 4 [default = 0]; - optional string softmax_tree = 5 [default = ""]; - optional uint32 background = 6 [default = 0]; -} -message ReorgParameter{ - optional uint32 stride = 2 [default = 2]; - optional bool reverse = 1 [default = false]; -} -message ReverseParameter{ - optional int32 axis = 1 [default = 1]; -} -message InterpParameter{ - optional int32 height = 1 [default = 0];//Height of output - optional int32 width = 2 [default = 0];//Width of output - optional int32 zoom_factor = 3 [default = 1];//zoom factor - optional int32 shrink_factor = 4 [default = 1];//shrink factor - optional int32 pad_beg = 5 [default = 0];//padding at begin of input - optional int32 pad_end = 6 [default = 0];//padding at end of input -} -message ShuffleChannelParameter{ - optional uint32 group = 1[default = 1]; // The number of group -} -message UpsampleParameter{ - optional int32 scale = 1[default = 1]; -} diff --git a/third_party/proto/coreml/DataStructures.proto b/third_party/proto/coreml/DataStructures.proto deleted file mode 100644 index 8b120c2d..00000000 --- a/third_party/proto/coreml/DataStructures.proto +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) 2017, Apple Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-3-clause license that can be -// found in LICENSE.txt or at https://opensource.org/licenses/BSD-3-Clause - -syntax = "proto3"; -option optimize_for = LITE_RUNTIME; - -import public "FeatureTypes.proto"; - -package CoreML.Specification; - -/** - * A mapping from a string - * to a 64-bit integer. - */ -message StringToInt64Map { - map map = 1; -} - -/** - * A mapping from a 64-bit integer - * to a string. - */ -message Int64ToStringMap { - map map = 1; -} - -/** - * A mapping from a string - * to a double-precision floating point number. - */ -message StringToDoubleMap { - map map = 1; -} - -/** - * A mapping from a 64-bit integer - * to a double-precision floating point number. - */ -message Int64ToDoubleMap { - map map = 1; -} - -/** - * A vector of strings. - */ -message StringVector { - repeated string vector = 1; -} - -/** - * A vector of 64-bit integers. - */ -message Int64Vector { - repeated int64 vector = 1; -} - -/** - * A vector of floating point numbers. - */ -message FloatVector { - repeated float vector = 1; -} - -/** - * A vector of double-precision floating point numbers. - */ -message DoubleVector { - repeated double vector = 1; -} - -/** - * A range of int64 values - */ -message Int64Range { - int64 minValue = 1; - int64 maxValue = 2; -} - -/** - * A set of int64 values - */ -message Int64Set { - repeated int64 values = 1; -} - -/** - * A range of double values - */ -message DoubleRange { - double minValue = 1; - double maxValue = 2; -} - diff --git a/third_party/proto/coreml/FeatureTypes.proto b/third_party/proto/coreml/FeatureTypes.proto deleted file mode 100644 index 8711ac7d..00000000 --- a/third_party/proto/coreml/FeatureTypes.proto +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright (c) 2017, Apple Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-3-clause license that can be -// found in LICENSE.txt or at https://opensource.org/licenses/BSD-3-Clause - -syntax = "proto3"; -option optimize_for = LITE_RUNTIME; - -package CoreML.Specification; - -/** - * The 64-bit integer feature type. - */ -message Int64FeatureType {} - -/** - * The double-precision floating point number feature type. - */ -message DoubleFeatureType {} - -/** - * The string feature type. - */ -message StringFeatureType {} - - -message SizeRange { - uint64 lowerBound = 1; - int64 upperBound = 2; // negative value means unbound otherwise upperbound is included in range -} - -/** - * The image feature type. - */ -message ImageFeatureType { - // Assumes raw (decompressed) format - enum ColorSpace { - INVALID_COLOR_SPACE = 0; - GRAYSCALE = 10; // 8 bits per pixel - RGB = 20; // 32 bits per pixel: RGBA with A channel ignored - BGR = 30; // 32 bits per pixel: BGRA with A channel ignored - } - - message ImageSize { - uint64 width = 1; - uint64 height = 2; - } - - message EnumeratedImageSizes { - repeated ImageSize sizes = 1; - } - - message ImageSizeRange { - SizeRange widthRange = 1; - SizeRange heightRange = 2; - } - - // The required or default image size is width x height - // - // If specificationVersion <= 2 or SizeFlexibility is empty, - // width x height is the required fixed image size - // - // If SizeFlexibility is present, width x height indicate a "default" - // image size which must be consistent with the flexibilty specified - - int64 width = 1; - int64 height = 2; - - // For specification version >= 3 you can specify image size flexibility. - - oneof SizeFlexibility { - - // Use enumeratedSizes for a set of distinct fixed sizes - // e.g. portrait or landscape: [80 x 100, 100 x 8] - // - // If the width x height fields above are specified then they must be - // one of the sizes listed. - // - // If width and height are not specified above then the default width - // and height will be enumeratedSizes[0] - // - // Must be non-empty - - EnumeratedImageSizes enumeratedSizes = 21; - - // Use imageSizeRange to allow for ranges of values - // e.g. any image greater than 10 x 20: [10..= 3 you can specify image size flexibility. - - oneof ShapeFlexibility { - - // Use enumeratedShapes for a set of distinct fixed shapes - // - // If the shape field is specified then it must be - // one of the enumerated shapes. - /// - // If shape is not specifed, the "default" shape will be considered - // enumeratedShapes[0] - // - // Must be non-empty - - EnumeratedShapes enumeratedShapes = 21; - - // Use shapeRange to allow the size of each dimension vary within - // indpendently specified ranges - // - // If you specify shape above it must fall in the range - // specified in shapeRanges. It will be treated as the default shape. - // - // If you don't specify shape above then the default shape will - // have shape[d] = shapeRange.sizeRanges[d].lowerBound - - ShapeRange shapeRange = 31; - - } - - oneof defaultOptionalValue { - int32 intDefaultValue = 41; - float floatDefaultValue = 51; - double doubleDefaultValue = 61; - } - -} - -/** - * The dictionary feature type. - */ -message DictionaryFeatureType { - /** - * Key/value type tags, with the following restrictions: - * - ``keyType`` must be a hashable type - * - ``valueType`` is assumed to be a ``double`` - */ - oneof KeyType { - Int64FeatureType int64KeyType = 1; - StringFeatureType stringKeyType = 2; - } -} - -/** - * The Sequence feature type. - */ -message SequenceFeatureType { - - /** - * Currently only categorical int64 and String sequences are supported - */ - oneof Type { - Int64FeatureType int64Type = 1; - StringFeatureType stringType = 3; - } - - // Range of allowed size/length/count of sequence - SizeRange sizeRange = 101; -} - -/** - * A feature, which may be optional. - */ -message FeatureType { - oneof Type { - Int64FeatureType int64Type = 1; - DoubleFeatureType doubleType = 2; - StringFeatureType stringType = 3; - ImageFeatureType imageType = 4; - ArrayFeatureType multiArrayType = 5; - DictionaryFeatureType dictionaryType = 6; - SequenceFeatureType sequenceType = 7; - } - - bool isOptional = 1000; -} - diff --git a/third_party/proto/coreml/Model.proto b/third_party/proto/coreml/Model.proto deleted file mode 100644 index 83db60e8..00000000 --- a/third_party/proto/coreml/Model.proto +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) 2017, Apple Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-3-clause license that can be -// found in LICENSE.txt or at https://opensource.org/licenses/BSD-3-Clause - - -syntax = "proto3"; -option optimize_for = LITE_RUNTIME; - -import public "NeuralNetwork.proto"; - -package CoreML.Specification; - -/** - * A feature description, - * consisting of a name, short description, and type. - */ -message FeatureDescription { - string name = 1; - string shortDescription = 2; - FeatureType type = 3; -} - -/** - * Model metadata, - * consisting of a short description, a version string, - * an author, a license, and any other user defined - * key/value meta data. - */ -message Metadata { - string shortDescription = 1; - string versionString = 2; - string author = 3; - string license = 4; - map userDefined = 100; -} - -/** - * A description of a model, - * consisting of descriptions of its input and output features. - * Both regressor and classifier models require the name of the - * primary predicted output feature (``predictedFeatureName``). - * Classifier models can specify the output feature containing - * probabilities for the predicted classes - * (``predictedProbabilitiesName``). - */ -message ModelDescription { - repeated FeatureDescription input = 1; - repeated FeatureDescription output = 10; - - // [Required for regressor and classifier models]: the name - // to give to an output feature containing the prediction. - string predictedFeatureName = 11; - - // [Optional for classifier models]: the name to give to an - // output feature containing a dictionary mapping class - // labels to their predicted probabilities. If not specified, - // the dictionary will not be returned by the model. - string predictedProbabilitiesName = 12; - - repeated FeatureDescription trainingInput = 50; - - Metadata metadata = 100; -} - -message SerializedModel { - // Identifier whose content describes the model type of the serialized protocol buffer message. - string identifier = 1; - - // Must be a valid serialized protocol buffer of the above specified type. - bytes model = 2; -} - -/** - * A Core ML model, - * consisting of a specification version, - * a model description, and a model type. - * - * Core ML model compatibility is indicated by - * a monotonically increasing specification version number, - * which is incremented anytime a backward-incompatible change is made - * (this is functionally equivalent to the MAJOR version number - * described by `Semantic Versioning 2.0.0 `_). - * - * Specification Versions : OS Availability (Core ML Version) - * - * 1 : iOS 11, macOS 10.13, tvOS 11, watchOS 4 (Core ML 1) - * - Feedforward & Recurrent Neural Networks - * - General Linear Models - * - Tree Ensembles - * - Support Vector Machines - * - Pipelines - * - Feature Engineering - * - * 2 : iOS 11.2, macOS 10.13.2, tvOS 11.2, watchOS 4.2 (Core ML 1.2) - * - Custom Layers for Neural Networks - * - Float 16 support for Neural Network layers - * - * 3 : iOS 12, macOS 10.14, tvOS 12, watchOS 5 (Core ML 2) - * - Flexible shapes and image sizes - * - Categorical sequences - * - Core ML Vision Feature Print, Text Classifier, Word Tagger - * - Non Max Suppression - * - Crop and Resize Bilinear NN layers - * - Custom Models - * - * 4 : iOS 13, macOS 10.15, tvOS 13, watchOS 6 (Core ML 3) - * - Updatable models - * - Exact shape / general rank mapping for neural networks - * - Large expansion of supported neural network layers - * - Generalized operations - * - Control flow - * - Dynamic layers - * - See NeuralNetwork.proto - * - Nearest Neighbor Classifier - * - Sound Analysis Prepreocessing - * - Recommender - * - Linked Model - * - NLP Gazeteer - * - NLP WordEmbedding - * - * 5 : iOS 14, macOS 11, tvOS 14, watchOS 7 (Core ML 4) - * - Model Deployment - * - Model Encryption - * - Unified converter API with PyTorch and Tensorflow 2 Support in coremltools 4 - * - MIL builder for neural networks and composite ops in coremltools 4 - * - New layers in neural network: - * - CumSum - * - OneHot - * - ClampedReLu - * - ArgSort - * - SliceBySize - * - Convolution3D - * - Pool3D - * - Bilinear Upsample with align corners and fractional factors - * - PixelShuffle - * - MatMul with int8 weights and int8 activations - * - Concat interleave - * - See NeuralNetwork.proto - * - Enhanced Xcode model view with interactive previews - * - Enhanced Xcode Playground support for Core ML models - * - */ -message Model { - int32 specificationVersion = 1; - ModelDescription description = 2; - - /* - * Following model types support on-device update: - * - * - NeuralNetworkClassifier - * - NeuralNetworkRegressor - * - NeuralNetwork - * - KNearestNeighborsClassifier - */ - bool isUpdatable = 10; - - // start at 200 here - // model specific parameters: - oneof Type { - // generic models start at 500 - NeuralNetwork neuralNetwork = 500; - } -} diff --git a/third_party/proto/coreml/NeuralNetwork.proto b/third_party/proto/coreml/NeuralNetwork.proto deleted file mode 100644 index 6b2ebb1c..00000000 --- a/third_party/proto/coreml/NeuralNetwork.proto +++ /dev/null @@ -1,6531 +0,0 @@ -// Copyright (c) 2017-2019, Apple Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-3-clause license that can be -// found in LICENSE.txt or at https://opensource.org/licenses/BSD-3-Clause - -/** - * A neural network is defined through a collection of layers - * and represents a directed acyclic graph (DAG). - * Each layer has a name, a layer type, - * a list of input names, a list of output names, - * and a collection of parameters specific to the layer type. - * - * The graph structure and connectivity of the neural network - * is inferred from the input and output names. - * A neural network starts with the layer - * whose input name is equal to the value specified in - * ``Model.description.input.name``, - * and ends with the layer - * whose output name is equal to the value specified in - * ``Model.description.output.name``. - * Layers must have unique input and output names, - * and a layer may not have input or output names that - * refer to layers that are not yet defined. - * - * For Core ML specification version <=3, - * all inputs are mapped to static rank 5 tensors, with axis notations - * [Sequence, Batch, Channel, Height, Width]. - * - * From specification version 4 onwards (iOS >= 13, macOS >= 10.15), more options are available - * (see enums ``NeuralNetworkMultiArrayShapeMapping``, ``NeuralNetworkImageShapeMapping``) - * to map inputs to generic N-Dimensional (or N rank) tensors, where N >= 1. - * - * Each layer type may have specific constraints on the ranks of its inputs and outputs. - * - * Some of the layers (such as softmax, reduce, etc) have parameters that have been described in - * terms of notational axis "Channel", "Height", "Width" or "Sequence". They can be re-interpreted easily in - * the general ND setting by using the following rule: - * "width" is same as axis = -1 (i.e. the last axis from the end) - * "height" is same as axis = -2 (i.e. the second last axis from the end) - * "channel" is same as axis = -3 (i.e. the third last axis from the end) - * "sequence" is same as axis = -5 (i.e. the fifth last axis from the end) - * - * Several layers are available in 3 different variations, with the names ending - * in identifiers: ``like``, ``static`` and ``dynamic``. For instance, ``FillLike``, - * ``FillStatic`` and ``FillDynamic``. The ``static`` variation generally will have - * a property corresponding to the shape of the output. For instance, if the - * output of the ``FillStatic`` layer is desired to be of shape (10, 4), the - * property ``targetShape`` will have to be set to [10, 4]. In the ``dynamic`` case, - * the shape is an input, hence it can be changed at runtime. For instance, for - * a ``FillDynamic`` layer, the input would have to be an array containing the - * values 10 and 4, if the desired output is of shape (10, 4). Whereas in the - * ``like`` case, the additional input's shape is used as the output shape, ignoring - * its values. For instance, for a ``FillLike`` layer, for an input with shape - * (10, 4), the output generated will also be of shape (10, 4), values of the - * input will be ignored. - */ - -syntax = "proto3"; -option optimize_for = LITE_RUNTIME; - -import public "DataStructures.proto"; -import public "Parameters.proto"; - -package CoreML.Specification; - - -enum NeuralNetworkMultiArrayShapeMapping { - - /* - * Describes how the MultiArray shape for the inputs, - * provided in Features Types proto via model description, - * is mapped to construct tensors that are fed into the Neural Network layers. - */ - - /* - * Default legacy value. Only supported for Core ML Specification version <= 3. - * - * The default legacy shape mapping resolves all input shapes to a rank 5 equivalent - * with axis notation of [Seq, Batch, Channel, Height, Width]. - * - * When this enum value is selected, - * the repeated shape field in the message "ArrayFeatureType" in feature types proto, - * must be either length 1 or length 3. - * - * The following rule is used to map the values in the shape field to the actual tensor shape: - * rank 1 shape is mapped to shape [1,1,C,1,1] - * rank 3 shape is mapped to shape [1,1,C,H,W] - * At runtime, the first two dimensions (Seq or Batch) can be presented as well, with non-1 values. - * - * It is invalid to use this enum value if any of the layers added - * Specification version 4 (iOS >= 13, macOS >= 10.15) onwards are used in the network. - * Validator will raise an error in that case. - */ - RANK5_ARRAY_MAPPING = 0; - - /* - * The exact shape and rank (i.e. number of dimensions in the shape) of the input, - * as specified in the message "ArrayFeatureType", is passed through to the layers. - * Supported only for Specification version >= 4 (iOS >= 13, macOS >= 10.15). - */ - EXACT_ARRAY_MAPPING = 1; - -} - -enum NeuralNetworkImageShapeMapping { - - /* - * Describes how the shape of the input tensors is constructed from image inputs. - */ - - /* - * In this case, image input is mapped to a rank 5 tensor. - * For Color images, input tensor is shaped as [1,1,3,H,W]. - * For Gray images, input tensor is shaped as [1,1,1,H,W]. - */ - RANK5_IMAGE_MAPPING = 0; - - /* - * For Color images, input tensor is shaped as [1,3,H,W]. - * For Gray images, input tensor is shaped as [1,1,H,W]. - * Supported only for Specification version >= 4 (iOS >= 13, macOS >= 10.15). - */ - RANK4_IMAGE_MAPPING = 1; - -} - -/** - A neural network. - */ -message NeuralNetwork { - - repeated NeuralNetworkLayer layers = 1; - repeated NeuralNetworkPreprocessing preprocessing = 2; - - // use this enum value to determine the input tensor shapes to the neural network, for multiarray inputs - NeuralNetworkMultiArrayShapeMapping arrayInputShapeMapping = 5; - - // use this enum value to determine the input tensor shapes to the neural network, for image inputs - NeuralNetworkImageShapeMapping imageInputShapeMapping = 6; - - - NetworkUpdateParameters updateParams = 10; - -} - -/// Preprocessing -/// ------------- - -/** - * A neural network preprocessor that - * performs a scalar multiplication of an image - * followed by addition of scalar biases to the channels. - * - * Input: X - * An image in BGR or RGB format with shape ``[3, H, W]`` - * or in grayscale format with shape ``[1, H, W]``. - * Output: Y - * An image with format and shape corresponding to the input. - * - * If the input image is in BGR format: - * - * .. code:: - * - * Y[0, :, :] = channelScale * X[0, :, :] + blueBias - * Y[1, :, :] = channelScale * X[1, :, :] + greenBias - * Y[2, :, :] = channelScale * X[2, :, :] + redBias - * - * If the input image is in RGB format: - * - * .. code:: - * - * Y[0, :, :] = channelScale * X[0, :, :] + redBias - * Y[1, :, :] = channelScale * X[1, :, :] + greenBias - * Y[2, :, :] = channelScale * X[2, :, :] + blueBias - * - * If the input image is in grayscale format: - * - * .. code:: - * - * Y[0, :, :] = channelScale * X[0, :, :] + grayBias - */ -message NeuralNetworkImageScaler { - - float channelScale = 10; ///Scalar to be multiplied. - float blueBias = 20; ///Scalar blue bias to be added. - float greenBias = 21; ///Scalar green bias to be added. - float redBias = 22; ///Scalar red bias to be added. - float grayBias = 30; ///Scalar bias to be added for grayscale images. - -} - -/** - * A neural network preprocessor that - * subtracts the provided mean image from the input image. - * The mean image is subtracted from the input named - * ``NeuralNetworkPreprocessing.featureName``. - */ -message NeuralNetworkMeanImage { - - /** - * Mean image stored as a flattened array of floats, - * representing shape [Channel,Height,Width]. - */ - repeated float meanImage = 1; - -} - -/// Preprocessing parameters for image inputs. -message NeuralNetworkPreprocessing { - - string featureName = 1; /// must be equal to the input name to which the preprocessing is applied - oneof preprocessor { - NeuralNetworkImageScaler scaler = 10; - NeuralNetworkMeanImage meanImage = 11; - } - -} - -/// Activation Functions -/// -------------------- - -/** - * A rectified linear unit (ReLU) activation function. - * - * This function has the following formula: - * - * .. math:: - * f(x) = \text{max}(0, x) - */ -message ActivationReLU { - -} - -/** - * A leaky rectified linear unit (ReLU) activation function. - * - * This function has the following formula: - * - * .. math:: - * f(x) = \begin{cases} - * x & \text{if } x \geq 0 \\ - * \alpha x & \text{if } x < 0 - * \end{cases} - */ -message ActivationLeakyReLU { - - float alpha = 1; //negative slope value for leakyReLU - -} - -/** - * A hyperbolic tangent activation function. - * - * This function has the following formula: - * - * .. math:: - * f(x) = \dfrac{1 - e^{-2x}}{1 + e^{-2x}} - */ -message ActivationTanh { - -} - -/** - * A scaled hyperbolic tangent activation function. - * - * This function has the following formula: - * - * .. math:: - * f(x) = \alpha \tanh(\beta x) - */ -message ActivationScaledTanh { - - float alpha = 1; - float beta = 2; - -} - -/** - * A sigmoid activation function. - * - * This function has the following formula: - * - * .. math:: - * f(x) = \dfrac{1}{1 + e^{-x}} - */ -message ActivationSigmoid { - -} - -/** - * A linear activation function. - * - * This function has the following formula: - * - * .. math:: - * f(x) = \alpha x + \beta - */ -message ActivationLinear { - - float alpha = 1; - float beta = 2; - -} - -/** - * A hard sigmoid activation function. - * - * This function has the following formula: - * - * .. math:: - * f(x) = \text{min}(\text{max}(\alpha x + \beta, 0), 1) - */ -message ActivationSigmoidHard { - - float alpha = 1; - float beta = 2; - -} - -/** - * A parameterized rectified linear unit (PReLU) activation function. - * Input must be at least rank 3. Axis = -3 is denoted by "C", or channels. - * "alpha" parameter can be a vector of length C. - * - * This function has the following formula: - * - * .. math:: - * f(x_i) = \begin{cases} - * x_i & \text{if } x_i \geq 0 \\ - * \alpha_i x_i & \text{if } x_i < 0 - * \end{cases} \;,\;i=1,...,C - */ -message ActivationPReLU { - - // parameter of length C or 1. - // If length is 1, same value is used for all channels - WeightParams alpha = 1; - -} - -/** - * An exponential linear unit (ELU) activation function. - * - * This function has the following formula: - * - * .. math:: - * f(x) = \begin{cases} - * x & \text{if } x \geq 0 \\ - * \alpha (e^x - 1) & \text{if } x < 0 - * \end{cases} - */ -message ActivationELU { - - float alpha = 1; - -} - -/** - * A thresholded rectified linear unit (ReLU) activation function. - * - * This function has the following formula: - * - * .. math:: - * f(x) = \begin{cases} - * x & \text{if } x \geq \alpha \\ - * 0 & \text{if } x < \alpha - * \end{cases} - */ -message ActivationThresholdedReLU { - - float alpha = 1; - -} - -/** - * A softsign activation function. - * - * This function has the following formula: - * - * .. math:: - * f(x) = \dfrac{x}{1 + |x|} - */ -message ActivationSoftsign { - -} - -/** - * A softplus activation function. - * - * This function has the following formula: - * - * .. math:: - * f(x) = \text{log}(1 + e^x) - */ -message ActivationSoftplus { - -} - -/** - * A parametric softplus activation function. - * Input must be at least rank 3. axis = -3 is denoted by "C", or channels. - * "alpha"/"beta" parameter can be a vector of length C. - * - * This function has the following formula: - * - * .. math:: - * f(x_i) = \alpha_i \text{log}(1 + e^{\beta_i x_i}) \;,\;i=1,...,C - */ -message ActivationParametricSoftplus { - - // If length is 1, same value is used for all channels - WeightParams alpha = 1; //parameter of length C or 1 - WeightParams beta = 2; //parameter of length C or 1 - -} - -message ActivationParams { - - oneof NonlinearityType { - ActivationLinear linear = 5; - - ActivationReLU ReLU = 10; - ActivationLeakyReLU leakyReLU = 15; - ActivationThresholdedReLU thresholdedReLU = 20; - ActivationPReLU PReLU = 25; - - ActivationTanh tanh = 30; - ActivationScaledTanh scaledTanh = 31; - - ActivationSigmoid sigmoid = 40; - ActivationSigmoidHard sigmoidHard = 41; - - ActivationELU ELU = 50; - - ActivationSoftsign softsign = 60; - ActivationSoftplus softplus = 70; - ActivationParametricSoftplus parametricSoftplus = 71; - } - -} - -/** - * Representation of the intermediate tensors - */ -message Tensor { - - // Number of dimensions in the tensor shape - uint32 rank = 1; - // actual value of the tensor shape. - // must be of length "rank". Can contain -1s for unknown dimensions. - repeated int64 dimValue = 2; - -} - -/** - * A single neural network layer. - */ -message NeuralNetworkLayer { - - string name = 1; //descriptive name of the layer - repeated string input = 2; - repeated string output = 3; - - repeated Tensor inputTensor = 4; // must be the same length as the "input" field - repeated Tensor outputTensor = 5; // must be the same length as the "output" field - - // Must be set to true to mark the layer as updatable. - // If true, the weightParams in the layer's properties must also be set to updatable - // If false, the value of the isUpdatable parameter within the layer's weights are ignored - bool isUpdatable = 10; - - oneof layer { - - // Start at 100 here - ConvolutionLayerParams convolution = 100; - - PoolingLayerParams pooling = 120; - - ActivationParams activation = 130; - - InnerProductLayerParams innerProduct = 140; - EmbeddingLayerParams embedding = 150; - - // Normalization-related Layers - BatchnormLayerParams batchnorm = 160; - MeanVarianceNormalizeLayerParams mvn = 165; - L2NormalizeLayerParams l2normalize = 170; - SoftmaxLayerParams softmax = 175; - LRNLayerParams lrn = 180; - - CropLayerParams crop = 190; - PaddingLayerParams padding = 200; - UpsampleLayerParams upsample = 210; - - ResizeBilinearLayerParams resizeBilinear = 211; - CropResizeLayerParams cropResize = 212; - - UnaryFunctionLayerParams unary = 220; - - // Element-wise Operations - AddLayerParams add = 230; - MultiplyLayerParams multiply = 231; - - AverageLayerParams average = 240; - ScaleLayerParams scale = 245; - - BiasLayerParams bias = 250; - MaxLayerParams max = 260; - MinLayerParams min = 261; - - DotProductLayerParams dot = 270; - ReduceLayerParams reduce = 280; - LoadConstantLayerParams loadConstant = 290; - - // Data Reorganization - ReshapeLayerParams reshape = 300; - FlattenLayerParams flatten = 301; - PermuteLayerParams permute = 310; - ConcatLayerParams concat = 320; - SplitLayerParams split = 330; - SequenceRepeatLayerParams sequenceRepeat = 340; - - ReorganizeDataLayerParams reorganizeData = 345; - SliceLayerParams slice = 350; - - // Recurrent Layers - SimpleRecurrentLayerParams simpleRecurrent = 400; - GRULayerParams gru = 410; - UniDirectionalLSTMLayerParams uniDirectionalLSTM = 420; - BiDirectionalLSTMLayerParams biDirectionalLSTM = 430; - - // Custom (user-implemented) Layer - CustomLayerParams custom = 500; - - // Following layers are available only after Core ML Specification - // version >= 4 (iOS >= 13, macOS >= 10.15) - - // Control Flow related Layers - CopyLayerParams copy = 600; - BranchLayerParams branch = 605; - - LoopLayerParams loop = 615; - LoopBreakLayerParams loopBreak = 620; - LoopContinueLayerParams loopContinue = 625; - - RangeStaticLayerParams rangeStatic = 635; - RangeDynamicLayerParams rangeDynamic = 640; - - // Element-wise Unary Layers - ClipLayerParams clip = 660; - CeilLayerParams ceil = 665; - FloorLayerParams floor = 670; - - SignLayerParams sign = 680; - RoundLayerParams round = 685; - - Exp2LayerParams exp2 = 700; - - SinLayerParams sin = 710; - CosLayerParams cos = 715; - TanLayerParams tan = 720; - - AsinLayerParams asin = 730; - AcosLayerParams acos = 735; - AtanLayerParams atan = 740; - - SinhLayerParams sinh = 750; - CoshLayerParams cosh = 755; - TanhLayerParams tanh = 760; - - AsinhLayerParams asinh = 770; - AcoshLayerParams acosh = 775; - AtanhLayerParams atanh = 780; - - ErfLayerParams erf = 790; - GeluLayerParams gelu = 795; - - // Element-wise Binary with Broadcasting Support - EqualLayerParams equal = 815; - NotEqualLayerParams notEqual = 820; - LessThanLayerParams lessThan = 825; - LessEqualLayerParams lessEqual = 827; - GreaterThanLayerParams greaterThan = 830; - GreaterEqualLayerParams greaterEqual = 832; - - LogicalOrLayerParams logicalOr = 840; - LogicalXorLayerParams logicalXor = 845; - LogicalNotLayerParams logicalNot = 850; - LogicalAndLayerParams logicalAnd = 855; - - ModBroadcastableLayerParams modBroadcastable = 865; - MinBroadcastableLayerParams minBroadcastable = 870; - MaxBroadcastableLayerParams maxBroadcastable = 875; - AddBroadcastableLayerParams addBroadcastable = 880; - PowBroadcastableLayerParams powBroadcastable = 885; - DivideBroadcastableLayerParams divideBroadcastable = 890; - FloorDivBroadcastableLayerParams floorDivBroadcastable = 895; - MultiplyBroadcastableLayerParams multiplyBroadcastable = 900; - SubtractBroadcastableLayerParams subtractBroadcastable = 905; - - // Tensor Manipulations - TileLayerParams tile = 920; - StackLayerParams stack = 925; - GatherLayerParams gather = 930; - ScatterLayerParams scatter = 935; - GatherNDLayerParams gatherND = 940; - ScatterNDLayerParams scatterND = 945; - SoftmaxNDLayerParams softmaxND = 950; - GatherAlongAxisLayerParams gatherAlongAxis = 952; - ScatterAlongAxisLayerParams scatterAlongAxis = 954; - - ReverseLayerParams reverse = 960; - ReverseSeqLayerParams reverseSeq = 965; - - SplitNDLayerParams splitND = 975; - ConcatNDLayerParams concatND = 980; - TransposeLayerParams transpose = 985; - - SliceStaticLayerParams sliceStatic = 995; - SliceDynamicLayerParams sliceDynamic = 1000; - SlidingWindowsLayerParams slidingWindows = 1005; - - TopKLayerParams topK = 1015; - ArgMinLayerParams argMin = 1020; - ArgMaxLayerParams argMax = 1025; - - EmbeddingNDLayerParams embeddingND = 1040; - BatchedMatMulLayerParams batchedMatmul = 1045; - - // Tensor Allocation / Reshape-related Operations - GetShapeLayerParams getShape = 1065; - LoadConstantNDLayerParams loadConstantND = 1070; - - FillLikeLayerParams fillLike = 1080; - FillStaticLayerParams fillStatic = 1085; - FillDynamicLayerParams fillDynamic = 1090; - - BroadcastToLikeLayerParams broadcastToLike = 1100; - BroadcastToStaticLayerParams broadcastToStatic = 1105; - BroadcastToDynamicLayerParams broadcastToDynamic = 1110; - - SqueezeLayerParams squeeze = 1120; - ExpandDimsLayerParams expandDims = 1125; - FlattenTo2DLayerParams flattenTo2D = 1130; - ReshapeLikeLayerParams reshapeLike = 1135; - ReshapeStaticLayerParams reshapeStatic = 1140; - ReshapeDynamicLayerParams reshapeDynamic = 1145; - RankPreservingReshapeLayerParams rankPreservingReshape = 1150; - - ConstantPaddingLayerParams constantPad = 1155; - - // Random Distributions - RandomNormalLikeLayerParams randomNormalLike = 1170; - RandomNormalStaticLayerParams randomNormalStatic = 1175; - RandomNormalDynamicLayerParams randomNormalDynamic = 1180; - - RandomUniformLikeLayerParams randomUniformLike = 1190; - RandomUniformStaticLayerParams randomUniformStatic = 1195; - RandomUniformDynamicLayerParams randomUniformDynamic = 1200; - - RandomBernoulliLikeLayerParams randomBernoulliLike = 1210; - RandomBernoulliStaticLayerParams randomBernoulliStatic = 1215; - RandomBernoulliDynamicLayerParams randomBernoulliDynamic = 1220; - - CategoricalDistributionLayerParams categoricalDistribution = 1230; - - // Reduction-related Layers: - ReduceL1LayerParams reduceL1 = 1250; - ReduceL2LayerParams reduceL2 = 1255; - ReduceMaxLayerParams reduceMax = 1260; - ReduceMinLayerParams reduceMin = 1265; - ReduceSumLayerParams reduceSum = 1270; - ReduceProdLayerParams reduceProd = 1275; - ReduceMeanLayerParams reduceMean = 1280; - ReduceLogSumLayerParams reduceLogSum = 1285; - ReduceSumSquareLayerParams reduceSumSquare = 1290; - ReduceLogSumExpLayerParams reduceLogSumExp = 1295; - - // Masking / Selection Layers - WhereNonZeroLayerParams whereNonZero = 1313; - MatrixBandPartLayerParams matrixBandPart = 1315; - LowerTriangularLayerParams lowerTriangular = 1320; - UpperTriangularLayerParams upperTriangular = 1325; - WhereBroadcastableLayerParams whereBroadcastable = 1330; - - // Normalization Layers - LayerNormalizationLayerParams layerNormalization = 1350; - - NonMaximumSuppressionLayerParams NonMaximumSuppression = 1400; - - // Following layers are available only after Core ML Specification - // version >= 5 (iOS >= 14, macOS >= 11.0) - OneHotLayerParams oneHot = 1450; - CumSumLayerParams cumSum = 1455; - ClampedReLULayerParams clampedReLU = 1460; - ArgSortLayerParams argSort = 1461; - Pooling3DLayerParams pooling3d = 1465; - GlobalPooling3DLayerParams globalPooling3d = 1466; - SliceBySizeLayerParams sliceBySize = 1470; - Convolution3DLayerParams convolution3d = 1471; - - } - -} - -/** - * Branching Layer - * - * A layer that provides the functionality of branching or an If-Else block. - * - * Must have 1 input. There are no outputs as the execution is transferred to either the - * if or the else branch based on the value of the input. - * - * Input is the condition predicate. Must be a scalar (length 1 tensor). - * - */ -message BranchLayerParams { - - /** - * execute this graph if the absolute value of the input Tensor is greater than 1e-6 - * This must be present. - */ - NeuralNetwork ifBranch = 1; - /** - * execute this graph if the absolute value of the input Tensor is less than 1e-6 - * This is optional. - */ - NeuralNetwork elseBranch = 2; - -} - -/** - * Loop Layer - * - * A layer that provides the functionality of a "for" loop or a "while" loop. - * - * There are either no inputs or 1 input. When an input is present, it corresponds to the maximum loop count, - * in that case the value of the "maxLoopIterations" field is ignored. Input must be a scalar. - * (For description below, maxLoopIterations is assumed to be the value of the input, when its present) - * - * No outputs are produced. Blobs produced by the condition or the body network are visible in the scope of the overall network. - * - * "conditionNetwork" must produce a tensor with the name specified in the "conditionVar" field. - * - * There are 3 possible cases for determining the termination condition: - * - * Case 1: - * - * If there is no "conditionNetwork", in this case the layer corresponds to a pure for loop, which is run "maxLoopIterations" number of times. - * Equivalent pseudo-code: - * - * for loopIterator = 0 : maxLoopIterations - * bodyNetwork() - * - * - * Case 2: - * - * "conditionNetwork" is present, and "maxLoopIterations" is 0 and there is no input, - * in this case the layer corresponds to a while loop. Equivalent pseudo-code: - * - * conditionVar = conditionNetwork() - * while conditionVar: - * bodyNetwork() - * conditionVar = conditionNetwork() - * - * - * Case 3: - * - * "conditionNetwork" is provided, and "maxLoopIterations" is positive or there is an input, - * in this case the layer corresponds to a while loop with a joint condition. Equivalent pseudo-code: - * - * loopIterator = 0 - * conditionVar = conditionNetwork() - * while (conditionVar and loopIterator < maxLoopIterations): - * bodyNetwork() - * loopIterator = loopIterator + 1 - * conditionVar = conditionNetwork() - * - */ -message LoopLayerParams { - - /** - * maximum number of iterations. Ignored if input is present. - */ - uint64 maxLoopIterations = 1; - /** - * This field provides the name of the tensor which is produced by the conditionNetwork - * and whose value is checked to start/continue/terminate the loop. Value close to 0.0f is treated as False. - * This field is optional. - * Must be a non empty string if and only if "conditionNetwork" is present. - */ - string conditionVar = 2; - /** - * Must generate a tensor with the name provided in the "conditionVar" field. - * This field is optional. - * Must be present if and only if "conditionVar" field is a non empty string. - */ - NeuralNetwork conditionNetwork = 3; - /** - * Body of the loop. - * This field must be present. - */ - NeuralNetwork bodyNetwork = 4; - -} - -/** - * Loop break Layer - * - * Terminate the loop that has this layer. - * If present, it should always reside in the "bodyNetwork" of the loop layer - * - * No inputs/outputs - * - */ -message LoopBreakLayerParams { - -} - -/** - * Loop Continue Layer - * - * Stop the current loop iteration and continue on the next iteration. - * If present, it should always reside in the "bodyNetwork" of the loop layer - * - * No inputs/outputs - * - */ -message LoopContinueLayerParams { - -} - -/** - * Copy Layer - * - * A layer that copies its input tensor to the output tensor. - * Must have 1 input and 1 output, with distinct names. - * This is the only layer that is allowed to re-generate an output that is already present in the neural network prior to this layer, - * in which case it will overwrite the output tensor. - * - */ -message CopyLayerParams { - -} - -/** - * GreaterThan Layer - * - * Either 1 or 2 inputs. - * Produces 1 output. - * Perform elementwise greater than operation. - * - * Output is 1.0f if the condition is true otherwise 0.0f. - * - * .. code:: - * - * y = x1 > x2 - * or - * y = x1 > alpha, if only one input is provided - * - * Broadcasting is supported. - * - */ -message GreaterThanLayerParams { - - /** - * Compare to the scalar value provided here if there is 1 input - */ - float alpha = 2; - -} - -/** - * GreaterEqual Layer - * - * Either 1 or 2 inputs. - * Produces 1 output. - * Perform elementwise greater equal operation. - * - * Output is 1.0f if the condition is true otherwise 0.0f. - * - * .. code:: - * - * y = x1 >= x2 - * or - * y = x1 >= alpha, if only one input is provided - * - * Broadcasting is supported. - * - */ -message GreaterEqualLayerParams { - - /** - * Compare to the scalar value provided here if there is 1 input - */ - float alpha = 2; - -} - -/** - * LessThan Layer - * - * Either 1 or 2 inputs. - * Produces 1 output. - * Perform elementwise less than operation. - * - * Output is 1.0f if the condition is true otherwise 0.0f. - * - * .. code:: - * - * y = x1 < x2 - * or - * y = x1 < alpha, if only one input is provided - * - * Broadcasting is supported. - * - */ -message LessThanLayerParams { - - /** - * Compare to the scalar value provided here if there is 1 input - */ - float alpha = 2; - -} - -/** - * LessEqual Layer - * - * Either 1 or 2 inputs. - * Produces 1 output. - * Perform elementwise less equal operation. - * - * Output is 1.0f if the condition is true otherwise 0.0f. - * - * .. code:: - * - * y = x1 <= x2 - * or - * y = x1 <= alpha, if only one input is provided - * - * Broadcasting is supported. - * - */ -message LessEqualLayerParams { - - /** - * Compare to the scalar value provided here if there is 1 input - */ - float alpha = 2; - -} - -/** - * Equal Layer - * - * Either 1 or 2 inputs. - * Produces 1 output. - * Perform elementwise equal operation. - * - * Output is 1.0f if the condition is true otherwise 0.0f. - * - * .. code:: - * - * y = x1 == x2 - * or - * y = x1 == alpha, if only one input is provided - * - * Broadcasting is supported. - * - */ -message EqualLayerParams { - - /** - * Compare to the scalar value provided here if there is 1 input - */ - float alpha = 1; - -} - -/** - * NotEqual Layer - * - * Either 1 or 2 inputs. - * Produces 1 output. - * Perform elementwise not equal operation. - * - * Output is 1.0f if the condition is true otherwise 0.0f. - * - * .. code:: - * - * y = x1 != x2 - * or - * y = x1 != alpha, if only one input is provided - * - * Broadcasting is supported. - * - */ -message NotEqualLayerParams { - - /** - * Compare to the scalar value provided here if there is 1 input - */ - float alpha = 1; - -} - -/** - * LogicalAnd Layer - * - * Must have 2 inputs, produces 1 output. - * Perform elementwise logical AND operation. - * - * Input is considered False if equal to 0.0f otherwise True. - * Output is 1.0f if the condition is true otherwise 0.0f. - * - * .. code:: - * - * y = AND(x1, x2) - * - * Broadcasting is supported. - * - */ -message LogicalAndLayerParams { - -} - -/** - * LogicalOr Layer - * - * Must have 2 inputs, produces 1 output. - * Perform elementwise logical OR operation. - * - * Input is considered False if equal to 0.0f otherwise True. - * Output is 1.0f if the condition is true otherwise 0.0f. - * - * .. code:: - * - * y = OR(x1, x2) - * - * Broadcasting is supported. - * - */ -message LogicalOrLayerParams { - -} - -/** - * LogicalXor Layer - * - * Must have 2 inputs, produces 1 output. - * Perform elementwise logical XOR operation. - * - * Input is considered False if equal to 0.0f otherwise True. - * Output is 1.0f if the condition is true otherwise 0.0f. - * - * .. code:: - * - * y = XOR(x1, x2) - * - * Broadcasting is supported. - * - */ -message LogicalXorLayerParams { - -} - -/** - * LogicalNot Layer - * - * Must have 1 input, produces 1 output. - * Perform elementwise logical NOT operation. - * - * Input is considered False if equal to 0.0f otherwise True. - * Output is 1.0f if the condition is true otherwise 0.0f. - * - * .. code:: - * - * y = NOT(x) - * - * - */ -message LogicalNotLayerParams { - -} - -/// Border Amounts -/// -------------- - -/** - * Specifies the amount of spatial border to be either padded or cropped. - * - * For padding: - * - * .. code:: - * - * H_out = borderAmounts[0].startEdgeSize + H_in + borderAmounts[0].endEdgeSize - * W_out = borderAmounts[1].startEdgeSize + W_in + borderAmounts[1].endEdgeSize - * - * topPaddingAmount == Height startEdgeSize - * bottomPaddingAmount == Height endEdgeSize - * leftPaddingAmount == Width startEdgeSize - * rightPaddingAmount == Width endEdgeSize - * - * For cropping: - * - * .. code:: - * - * H_out = (-borderAmounts[0].startEdgeSize) + H_in + (-borderAmounts[0].endEdgeSize) - * W_out = (-borderAmounts[1].startEdgeSize) + W_in + (-borderAmounts[1].endEdgeSize) - * - * topCropAmount == Height startEdgeSize - * bottomCropAmount == Height endEdgeSize - * leftCropAmount == Width startEdgeSize - * rightCropAmount == Width endEdgeSize - */ -message BorderAmounts { - - message EdgeSizes { - /** - * The amount to be padded or cropped from the beginning. - */ - uint64 startEdgeSize = 1; - - /** - * The amount to be padded or cropped from the end. - */ - uint64 endEdgeSize = 2; - } - - /** - * The border amounts. - * This must be length 2 in the order ``[H, W]``. - */ - repeated EdgeSizes borderAmounts = 10; - -} - -/** - * Specifies the type of padding to be used with Convolution/Deconvolution and Pooling layers. - * After padding, input spatial shape: ``[H_in, W_in]``, gets modified to the - * output spatial shape ``[H_out, W_out]``. - * - * .. code:: - * - * topPaddingAmount == Height startEdgeSize == borderAmounts[0].startEdgeSize - * bottomPaddingAmount == Height endEdgeSize == borderAmounts[0].endEdgeSize - * leftPaddingAmount == Width startEdgeSize == borderAmounts[1].startEdgeSize - * rightPaddingAmount == Width endEdgeSize == borderAmounts[1].endEdgeSize - * - * With Convolution or Pooling: - * - * .. code:: - * - * H_out = int_division_round_down((H_in + topPaddingAmount + bottomPaddingAmount - KernelSize[0]),stride[0]) + 1 - * - * which is same as: - * - * .. code:: - * - * H_out = int_division_round_up((H_in + topPaddingAmount + bottomPaddingAmount - KernelSize[0] + 1),stride[0]) - * - * With Deconvolution: - * - * .. code:: - * - * H_out = (H_in-1) * stride[0] + kernelSize[0] - (topPaddingAmount + bottomPaddingAmount) - * - * - * The equivalent expressions hold true for ``W_out`` as well. - * - * - * By default, the values of ``paddingAmounts`` are set to ``0``, - * which results in a "true" valid padding. - * If non-zero values are provided for ``paddingAmounts``, - * "valid" convolution/pooling is performed within the spatially expanded input. - * - */ -message ValidPadding { - - BorderAmounts paddingAmounts = 1; - -} - -/** - * Specifies the type of padding to be used with Convolution/Deconvolution and pooling layers. - * After padding, input spatial shape: ``[H_in, W_in]``, gets modified to the - * output spatial shape ``[H_out, W_out]``. - * With Convolution or pooling: - * - * .. code:: - * - * H_out = int_division_round_up(H_in,stride[0]) - * W_out = int_division_round_up(W_in,stride[1]) - * - * This is achieved by using the following padding amounts: - * - * .. code:: - * - * totalPaddingHeight = max(0,(H_out-1) * stride[0] + KernelSize[0] - Hin) - * totalPaddingWidth = max(0,(W_out-1) * stride[1] + KernelSize[1] - Win) - * - * There are two modes of asymmetry: - * ``BOTTOM_RIGHT_HEAVY``, and ``TOP_LEFT_HEAVY``. - * - * If the mode is ``BOTTOM_RIGHT_HEAVY``: - * - * .. code:: - * - * topPaddingAmount = floor(totalPaddingHeight / 2) - * bottomPaddingAmount = totalPaddingHeight - topPaddingAmount - * leftPaddingAmount = floor(totalPaddingWidth / 2) - * rightPaddingAmount = totalPaddingWidth - leftPaddingAmount - * - * If the mode is ``TOP_LEFT_HEAVY``: - * - * .. code:: - * - * bottomPaddingAmount = floor(totalPaddingHeight / 2) - * topPaddingAmount = totalPaddingHeight - bottomPaddingAmount - * rightPaddingAmount = floor(totalPaddingWidth / 2) - * leftPaddingAmount = totalPaddingWidth - rightPaddingAmount - * - * - * With Deconvolution: - * - * .. code:: - * - * H_out = H_in * stride[0] - * W_out = W_in * stride[1] - */ -message SamePadding { - - enum SamePaddingMode { - - BOTTOM_RIGHT_HEAVY = 0; - TOP_LEFT_HEAVY = 1; - - } - SamePaddingMode asymmetryMode = 1; - -} - -/** - * Specifies how grid points are sampled from an interval. - * Without the loss of generality, assume the interval to be [0, X-1] from which N points are to be sampled. - * Here X may correspond to an input image's height or width. - * All the methods can be expressed in terms of numpy's linspace function, along with the constraint that grid points have to lie in the interval [0, X-1]. - * Note: numpy.linspace(start = start, end = end, num = N, endpoint = True) corresponds to sampling - * N points uniformly from the interval [start, end], endpoints included. - * The methods vary in how the ``start`` and ``end`` values are computed. - */ -message SamplingMode { - - enum Method { - - /** - * start = 0, end = X-1 - * grid points = numpy.linspace(start, end) - */ - STRICT_ALIGN_ENDPOINTS_MODE = 0; - - /** - * if N == 1: start = end = (X-1)/2 - * otherwise, start = 0, end = X-1 - * grid points = numpy.linspace(start, end) - */ - ALIGN_ENDPOINTS_MODE = 1; - - /** - * start = 0, end = X - X/N - * grid points = min(X-1, numpy.linspace(start, end)) - * This is same as the mode used in the upsample layer in this specification, when used with bilinear interpolation. In that case N/X = upsample ratio. - */ - UPSAMPLE_MODE = 2; - - /** - * spacing = max(1, X-1)/N - * start = 0.5 * spacing - * end = start + (N-1) * spacing - * grid points = min(X-1, numpy.linspace(start, end)) - */ - ROI_ALIGN_MODE = 3; - - } - - Method samplingMethod = 1; - -} - -/** - * Specifies the convention used to specify four bounding box coordinates for an image of size (Height, Width). - * The (0,0) coordinate corresponds to the top-left corner of the image. - */ -message BoxCoordinatesMode { - - enum Coordinates { - - /** - * [h_start, w_start, h_end, w_end] - */ - CORNERS_HEIGHT_FIRST = 0; - - /** - * [w_start, h_start, w_end, h_end] - */ - CORNERS_WIDTH_FIRST = 1; - - /** - * [h_center, w_center, box_height, box_width] - */ - CENTER_SIZE_HEIGHT_FIRST = 2; - - /** - * [w_center, h_center, box_width, box_height] - */ - CENTER_SIZE_WIDTH_FIRST = 3; - - } - - Coordinates boxMode = 1; - -} - -/** - * Weights for layer parameters. - * Weights are stored as repeated floating point numbers - * using row-major ordering - * and can represent 1-, 2-, 3-, or 4-dimensional data. - */ -message WeightParams { - - /** - * Values specified in single / float / FP32 precision. - */ - repeated float floatValue = 1; - - /** - * Values in 16-bit half precision floating point. - */ - bytes float16Value = 2; - - /** - * Raw value specification for quantized lower precisions. - * - * This field is interpreted as uintN, where N is the number of bits in quantization. - * E.g. if n=8, the field is interpreted as an array of UINT8. - * Use this field for quantized parameters unless specifically noted to use - * int8RawValue. - */ - bytes rawValue = 30; - - /** - * Field to be used if int8DynamicQuantize is set in the parent layer. - * Cannot be set if rawValue is also set. - * The values in this field are interpreted as INT8. - * - * If this field is set, following conditions must hold true: - * * QuantizationType == LinearQuantizationParams, such that - * * size of the "scale" field is 1 and "bias" field is empty in "LinearQuantizationParams" - */ - bytes int8RawValue = 31; - - /** - * Quantization related parameters. - */ - QuantizationParams quantization = 40; - - bool isUpdatable = 50; - -} - -/** - * Quantization parameters. - */ -message QuantizationParams { - - uint64 numberOfBits = 1; - oneof QuantizationType { - LinearQuantizationParams linearQuantization = 101; - LookUpTableQuantizationParams lookupTableQuantization = 102; - } - -} - -message LinearQuantizationParams { - - /** - * Stores scale and bias values corresponding to the quantized weights. - * Must be an array of 1 element, or an array of C elements, where C - * is number of output channels. For recurrent layers it is equal to - * the output vector size. - * - * Relationship between quantized weights, unquantized weights, scale and bias: - * - * W_unquantized = W_quantized * scale + bias - * - */ - repeated float scale = 1; - repeated float bias = 2; - -} - -message LookUpTableQuantizationParams { - - /* Stores look-up table quantization values. Must be an array of - (2^numberOfBits) Elements. - */ - repeated float floatValue = 1; - -} - -/// Layers -/// ------ - -/** - * A layer that performs spatial convolution or deconvolution. - * - * .. code:: - * - * y = ConvolutionLayer(x) - * - * Requires 1 or 2 inputs and produces 1 output. - * - * Input - * First Input: - * A blob with rank greater than or equal to 4. - * Rank 4 blob represents [Batch, channels, height, width]. - * For ranks greater than 4, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * - * From Core ML specification version 4 onwards (iOS >= 13, macOS >= 10.15). - * convolution layer can have 2 inputs, in which case the second input is - * the blob representing the weights. This is allowed when "isDeconvolution" = False. - * The weight blob should have shape - * ``[outputChannels, kernelChannels, kernelHeight, kernelWidth]``, - * where kernelChannels == inputChannels / nGroups. - * - * Output - * Rank is same as the input. e.g.: for rank 4 input, output shape is [B, C_out, H_out, W_out] - * - * - * If ``dilationFactor`` is not 1, effective kernel size is - * modified as follows: - * - * .. code:: - * - * KernelSize[0] <-- (kernelSize[0]-1) * dilationFactor[0] + 1 - * KernelSize[1] <-- (kernelSize[1]-1) * dilationFactor[1] + 1 - * - * Type of padding can be ``valid`` or ``same``. Output spatial dimensions depend on the - * the type of padding. For details, refer to the descriptions of the messages "ValidPadding" - * and "SamePadding". Padded values are all zeros. - * - * For Deconvolution, ``ConvolutionPaddingType`` (``valid`` or ``same``) is ignored when ``outputShape`` is set. - * - * - */ -message ConvolutionLayerParams { - - /** - * The number of kernels. - * Same as ``C_out`` used in the layer description. - */ - uint64 outputChannels = 1; - - /** - * Channel dimension of the kernels. - * Must be equal to ``inputChannels / nGroups``, if isDeconvolution == False - * Must be equal to ``inputChannels``, if isDeconvolution == True - */ - uint64 kernelChannels = 2; - - /** - * Group convolution, i.e. weight reuse along channel axis. - * Input and kernels are divided into g groups - * and convolution / deconvolution is applied within the groups independently. - * If not set or 0, it is set to the default value 1. - */ - uint64 nGroups = 10; - - /** - * Must be length 2 in the order ``[H, W]``. - * If not set, default value ``[3, 3]`` is used. - */ - repeated uint64 kernelSize = 20; - - /** - * Must be length 2 in the order ``[H, W]``. - * If not set, default value ``[1, 1]`` is used. - */ - repeated uint64 stride = 30; - - /** - * Must be length 2 in order ``[H, W]``. - * If not set, default value ``[1, 1]`` is used. - * It is ignored if ``isDeconvolution == true``. - */ - repeated uint64 dilationFactor = 40; - - /** - * The type of padding. - */ - oneof ConvolutionPaddingType { - ValidPadding valid = 50; - SamePadding same = 51; - } - - /** - * Flag to specify whether it is a deconvolution layer. - */ - bool isDeconvolution = 60; - - /** - * Flag to specify whether a bias is to be added or not. - */ - bool hasBias = 70; - - /** - * Weights associated with this layer. - * If convolution (``isDeconvolution == false``), weights have the shape - * ``[outputChannels, kernelChannels, kernelHeight, kernelWidth]``, where kernelChannels == inputChannels / nGroups - * If deconvolution (``isDeconvolution == true``) weights have the shape - * ``[kernelChannels, outputChannels / nGroups, kernelHeight, kernelWidth]``, where kernelChannels == inputChannels - */ - WeightParams weights = 90; - WeightParams bias = 91; /// Must be of size [outputChannels]. - - /** - * The output shape, which has length 2 ``[H_out, W_out]``. - * This is used only for deconvolution (``isDeconvolution == true``). - * If not set, the deconvolution output shape is calculated - * based on ``ConvolutionPaddingType``. - */ - repeated uint64 outputShape = 100; - -} - -/** - * A layer that performs a 3-dimensional convolution. - * - * .. code:: - * - * y = Convolution3DLayer(x) - * - * Input - * A blob of rank 5. - * The input blob's shape should be ``[batch, channels, depth, height, width]``. - * - * Fields - * The bias field, if set, should have shape of ``[channelsOut]``. - * - * Output - * A blob of rank 5. - * The output blob's shape is ``[batch, channelsOut, depthOut, heightOut, widthOut]``. - * - * Type of padding can be ``custom``, ``valid``, or ``same``. Padded values are all zeros. - * Output spatial dimensions depend on the the type of padding. For details, refer to the - * descriptions of the ``PaddingType`` field of this ``Convolution3DLayerParams`` message. - * - * Example - * For example, given an input of size ``[1, 3, 3, 8, 8]``, a stride of 2 in each dimension, - * a kernel of 3 in each dimension, 2 output channels, and ``same`` padding, this layer will - * compute the total padding applied in the depth, height, and width dimensions to be 2, 1, and 1, - * respectively. The depth padding is even and will be applied equally to both sides of the depth - * dimension. Since the height and width padding values are odd, they'll be applied to the - * bottom/right of the height/width dimensions. Thus, the padding applied to the input will be - * ``[1, 1, 0, 1, 0, 1]`` (front, back, top, bottom, left, right). Finally, the output produced - * will have size ``[1, 2, 2, 4, 4]``. - * - */ -message Convolution3DLayerParams { - - /** - * The number of channels in the output (channelsOut). Must be a positive integer. - */ - int32 outputChannels = 1; - - /** - * The number of channels in the input (channels). Must be a positive integer. - */ - int32 inputChannels = 2; - - /** - * Group convolution, i.e., weight reuse along the channel axis. - * It must evenly divide both the number of input and output channels and be at most the number - * of input channels (a depthwise convolution). - * Input and kernels are divided into g groups and convolution is applied within the groups - * independently. - */ - int32 nGroups = 10; - - /* Depth of the convolution kernel. Must be a positive integer. - */ - int32 kernelDepth = 20; - - /* Height of the convolution kernel. Must be a positive integer. - */ - int32 kernelHeight = 21; - - /* Width of the convolution kernel. Must be a positive integer. - */ - int32 kernelWidth = 22; - - /* Stride along the depth direction. Must be a positive integer. - */ - int32 strideDepth = 31; - - /* Stride along the height direction. Must be a positive integer. - */ - int32 strideHeight = 32; - - /* Stride along the width direction. Must be a positive integer. - */ - int32 strideWidth = 33; - - /* Dilation along the depth direction. Must be a positive integer. - */ - int32 dilationDepth = 40; - - /* Dilation along the height direction. Must be a positive integer. - */ - int32 dilationHeight = 41; - - /* Dilation along the width direction. Must be a positive integer. - */ - int32 dilationWidth = 42; - - /** - * Flag to specify whether a bias is to be added or not. - * If false, then no bias is added. - */ - bool hasBias = 50; - - /** - * Weights associated with this layer. - * Weights have the shape - * if deconvolution == False - * ``[outputChannels, kernelChannels, kernelDepth, kernelHeight, kernelWidth]``, where - * kernelChannels == inputChannels / nGroups - * else if deconvolution == True - * ``[outputChannels / nGroups, kernelChannels, kernelDepth, kernelHeight, kernelWidth]``, where - */ - WeightParams weights = 60; - - /** - * Must be of size ``[outputChannels]``. - */ - WeightParams bias = 61; - - - /** - * The type of padding. - * All padding types pad the input shape with zeros. - * CUSTOM padding will add the custom padding values specified below to their respective - * dimensions, e.g., `customPaddingFront` number of zeros will be added to one side of the - * input's depth dimension and `customPaddingBack` number of zeros will be added to the other - * side of the input's depth dimension. - * VALID padding adds no padding to any dimension. In this case, the last convolution along - * each dimension will be dropped if the input dimension and the kernel size, stride, and - * dilation do not match. - * SAME padding adds enough padding to each dimension such that the output of the convolution - * has size ``Ceiling(inputShape / stride)``. Padding is added evenly to both sides of each - * dimension unless the total padding to add is odd, in which case it is added to the - * back/bottom/right side of the respective dimension. For example, if the total padding needed - * in the depth dimension is 3, 1 zero will be added to the front side of the depth dimension - * and 2 zeros will be added to the back side. - */ - enum PaddingType { - CUSTOM = 0; - VALID = 1; - SAME = 2; - } - PaddingType paddingType = 70; - - /* Padding before the input in the depth direction. Must be zero or a positive integer. - * Used when the `PaddingType` is `CustomPadding`, otherwise ignored by other padding types. - */ - int32 customPaddingFront = 80; - - /* Padding after the input in the depth direction. Must be zero or a positive integer. - * Used when the `PaddingType` is `CustomPadding`, otherwise ignored by other padding types. - */ - int32 customPaddingBack = 81; - - /* Padding before the input in the height direction. Must be zero or a positive integer. - * Used when the `PaddingType` is `CustomPadding`, otherwise ignored by other padding types. - */ - int32 customPaddingTop = 82; - - /* Padding after the input in the height direction. Must be zero or a positive integer. - * Used when the `PaddingType` is `CustomPadding`, otherwise ignored by other padding types. - */ - int32 customPaddingBottom = 83; - - /* Padding before the input in the width direction. Must be zero or a positive integer. - * Used when the `PaddingType` is `CustomPadding`, otherwise ignored by other padding types. - */ - int32 customPaddingLeft = 84; - - /* Padding after the input in the width direction. Must be zero or a positive integer. - * Used when the `PaddingType` is `CustomPadding`, otherwise ignored by other padding types. - */ - int32 customPaddingRight = 85; - - /* Flag to specify if this is Convolution Transpose or not. - */ - bool isDeconvolution = 86; - - /* - * The output shape, which has length 3 ``[D_out, H_out, W_out]``. - * This is used only for deconvolution (``isDeconvolution == true``). - * If not set, the deconvolution output shape is calculated - * based on ``PaddingType``. - */ - repeated uint64 outputShape = 87; - -} - -/** - * A layer that performs a matrix-vector or matrix-matrix product. - * This is equivalent to a fully-connected, or dense layer. - * The weight parameters correspond to a matrix of dimensions (inputChannels, outputChannels) i.e. (C_in, C_out) - * - * .. code:: - * - * y = InnerProductLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * Input can have rank 1 to rank 5. This is how it is reshaped in to the matrix (for rank > 1): - * rank 1 (x1) : in this case, the layer corresponds to a matrix-vector product. x1 must be equal to C_in - * rank 2 (x1, x2): x2 must be equal to C_in - * rank 3 (x1, x2, x3) --> (x1 * x2, x3). x3 must be equal to C_in - * rank 4 (x1, x2, x3, x4) ---> (x1, x2 * x3 * x4). x2 * x3 * x4 must be equal to C_in - * rank 5 (x1, x2, x3, x4, x5) ---> (x1 * x2, x3 * x4 * x5). x3 * x4 * x5 must be equal to C_in - * - * Output - * Output rank is same as the input rank - * rank 1: (C_out) - * rank 2: (x1, C_out) - * rank 3: (x1, x2, C_out) - * rank 4: (x1, C_out, 1, 1) - * rank 5: (x1, x2, C_out, 1, 1) - * - */ -message InnerProductLayerParams { - - uint64 inputChannels = 1; /// Input size: C_in. - uint64 outputChannels = 2; /// Output size: C_out. - - bool hasBias = 10; /// Whether a bias is added or not. - - WeightParams weights = 20; /// Weight matrix [C_out, C_in]. - WeightParams bias = 21; /// Bias vector [C_out]. - - /** - * If set, this layer, at runtime, quantizes the floating point input blob to int8 before applying an - * inner product using INT8 weight matrix parameters, as provided in weights->int8RawValue. The - * result is then dequantized. - * Requires: - * * hasBias == false - * * QuantizationType == LinearQuantizationParams, such that - * * size of the "scale" field is 1 and "bias" field is empty in "LinearQuantizationParams" - * * numberOfBits == 8 - * * weights->rawValue_size to be empty - */ - bool int8DynamicQuantize = 22; - -} - -/** - * A layer that performs a matrix lookup and optionally adds a bias. - * The weights matrix is stored with dimensions [outputChannels, inputDim]. - * - * .. code:: - * - * y = EmbeddingLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * Input values must be in the range ``[0, inputDim - 1]``. - * - * Input must have rank equal to 4 or 5, such that the last 3 dimensions are all 1. - * rank 4: shape (x1, 1, 1, 1). x1 is effectively the batch/sequence length. - * rank 5: shape (x1, x2 , 1, 1, 1). x1 * x2 is effectively the combined batch/sequence length. - * - * Output - * Output rank is same as the input rank. Please see input description above. - * rank 4: shape (x1, outputChannels, 1, 1) - * rank 5: shape (x1, x2, outputChannels, 1, 1) - * - */ -message EmbeddingLayerParams { - - uint64 inputDim = 1; /// Size of the input dictionary. - uint64 outputChannels = 2; /// Size of the output vectors. - - bool hasBias = 10; /// Whether a bias is added or not. - - WeightParams weights = 20; /// 2-D weights of dimensions [outputChannels, inputDim]. - WeightParams bias = 21; /// Bias of size [outputChannels]. - -} - -/** - * A layer that performs a matrix lookup and optionally adds a bias. - * The weights matrix is stored with dimensions [embeddingSize, vocabSize]. - * - * .. code:: - * - * y = EmbeddingNDLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * Input values must be in the range ``[0, vocabSize - 1]``. - * Input must have rank at least 2. The last dimension must always be 1. - * rank 2: shape (x1, 1). x1 is the batch/sequence length. - * rank 3: shape (x1, x2, 1). x1 * x2 is effectively the combined batch/sequence length. - * rank 4: shape (x1, x2, x3, 1). x1 * x2 * x2 is effectively the combined batch/sequence length. - * rank 5: shape (x1, x2 , x3, x4, 1). x1 * x2 * x3 * x4 is effectively the combined batch/sequence length. - * - * Output - * Output rank is same as the input rank. Please see input description above. - * rank 2: shape (x1, embeddingSize) - * rank 3: shape (x1, x2, embeddingSize) - * rank 4: shape (x1, x2, x3, embeddingSize) - * rank 5: shape (x1, x2, x3, x4, embeddingSize) - * - */ -message EmbeddingNDLayerParams { - - uint64 vocabSize = 1; /// Size of the input dictionary. - uint64 embeddingSize = 2; /// Size of the output vectors. - bool hasBias = 3; /// Whether a bias is added or not. - WeightParams weights = 20; /// 2-D weights of dimensions [embeddingSize, vocabSize]. - WeightParams bias = 21; /// Bias of size [embeddingSize]. - -} - -/** - * A layer that performs batch normalization, - * which is performed along axis = -3, - * and repeated along the other axes, if present. - * - * .. code:: - * - * y = BatchnormLayer(x) - * - * Requires 1 input and produces 1 output. - * - * This operation is described by the following formula: - * - * .. math:: - * y_i = \gamma_i \dfrac{ (x_i - \mu_i)}{\sqrt{\sigma_i^2 + \epsilon}} + \beta_i \;,\;i=1,....,C - * - * Input - * A blob with rank greater than equal to 3. - * Example: Rank 4 blob represents [Batch, channels, height, width] - * For ranks greater than 3, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * - * Output - * A blob with the same shape as the input. - */ -message BatchnormLayerParams { - - uint64 channels = 1; /// Size of the channel dimension in the input. - - /** - * If ``computeMeanVar == true``, - * the mean and variance are calculated from either - * the single input instance, if ``instanceNormalization == true``, - * or the whole batch, if ``instanceNormalization = false``. - * and the values provided in parameters "mean" and "variance" are ignored. - */ - bool computeMeanVar = 5; - bool instanceNormalization = 6; - - /** - * A small constant to avoid division by 0 while normalizing by variance. - * Defaults to ``1e-5`` if not set or set to ``0``. - */ - float epsilon = 10; - - WeightParams gamma = 15; /// Parameter of length [channels] - WeightParams beta = 16; /// Parameter of length [channels] - WeightParams mean = 17; /// Parameter of length [channels] - WeightParams variance = 18; /// Parameter of length [channels] - -} - -/** - * A spatial pooling layer. - * - * .. code:: - * - * y = PoolingLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with rank greater than equal to 4. - * Rank 4 blob represents [Batch, channels, height, width] - * For ranks greater than 4, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * - * Output - * Rank is same as the input. e.g.: for rank 4 input, output shape is [B, C, H_out, W_out] - * - * Padding options are similar to ``ConvolutionLayerParams`` - * with the additional option of ``ValidCompletePadding`` (``includeLastPixel``), - * which ensures that the last application of the kernel - * always includes the last pixel of the input image, if there is padding. - * - * .. code:: - * - * H_out = ceil(float(H_in + 2 * paddingAmounts[0] - kernelSize[0])/float(Stride[0])) + 1 - * if (paddingAmounts[0] > 0 or paddingAmounts[1] > 0) - * if ((H_out - 1) * Stride >= H_in + paddingAmounts[0]) { - * H_out = H_out - 1 - * } - * } - * - * The equivalent expressions hold true for ``W_out`` as well. - * Only symmetric padding is supported with this option. - */ -message PoolingLayerParams { - - enum PoolingType { - - MAX = 0; - AVERAGE = 1; - L2 = 2; - - } - PoolingType type = 1; /// Type of pooling operation. - - /** - * Must be length 2 in the order ``[H, W]``. - * If not set, default value ``[3, 3]`` is used. - */ - repeated uint64 kernelSize = 10; - - /** - * Must be length 2 in the order ``[H, W]``. - * If not set, default value ``[1, 1]`` is used. - */ - repeated uint64 stride = 20; - - message ValidCompletePadding { - - /** - * Must be length 2 in order ``[H, W]``. - * If not set, value ``[0, 0]`` is used. - */ - repeated uint64 paddingAmounts = 10; - - } - - oneof PoolingPaddingType { - ValidPadding valid = 30; - SamePadding same = 31; - ValidCompletePadding includeLastPixel = 32; - } - - /** - * If true, padded values are excluded from the count (denominator) - * when computing average pooling. - */ - bool avgPoolExcludePadding = 50; - - /** - * If true, global pooling is performed. - * Kernel size is inferred from the input data spatial dimensions. - */ - bool globalPooling = 60; - -} - -/* - * A layer to pool three spatial dimensions - * - * Input - * A blob with rank equal to 5, representing [Batch, channels, depth, height, width]. - * - * Output - * Rank is same as the input: A blob with rank equal to 5, representing [Batch, channels, depth, height, width]. - * - * Requires 1 input and produces 1 output. - * - * For example, given an input of shape (1,1,2,3,3): - * +----+----+----+ - * / | 10 | 11 | 12 | - * / +----+----+----+ - * / | 13 | 14 | 15 | - * / +----+----+----+ - * / | 16 | 17 | 18 | - * / +----+----+----+ - * +----+----+----+ / - * | 1 | 2 | 3 | / - * +----+----+----+ / - * | 4 | 5 | 6 | / - * +----+----+----+ / - * | 7 | 8 | 9 | / - * +----+----+----+ - * - * And applying MAX pooling using: - * Kernel: 2x2x2 - * Stride: 1x1x1 - * Valid Padding - * We expect to get an output with shape: (1,1,1,2,2) and value: - * +----+----+ - * | 14 | 15 | - * +----+----+ - * | 17 | 18 | - * +----+----+ - */ -message Pooling3DLayerParams { - - enum PoolingType3D { - MAX = 0; - AVERAGE = 1; - } - - // Whether to use Max or Average - PoolingType3D type = 1; - - // Depth of the pooling region. - int32 kernelDepth = 2; - - // Height of the pooling region. - int32 kernelHeight = 3; - - // Width of the pooling region. - int32 kernelWidth = 4; - - // Stride along the depth direction - int32 strideDepth = 5; - - // Stride along the height direction - int32 strideHeight = 6; - - // Stride along the width direction - int32 strideWidth = 7; - - /** - * The type of padding. - * All padding types pad the input shape with zeros. - * CUSTOM padding will add the custom padding values specified below to their respective - * dimensions, e.g., `customPaddingFront` number of zeros will be added to one side of the - * input's depth dimension and `customPaddingBack` number of zeros will be added to the other - * side of the input's depth dimension. - * VALID padding adds no padding to any dimension. In this case, the last pool along - * each dimension will be dropped if the input dimension and the kernel size, and stride do not match. - * SAME padding adds enough padding to each dimension such that the output - * has the same spatial dimensions as the input. Padding is added evenly to both - * sides of each dimension unless the total padding to add is odd, in which case the extra padding - * is added to the back/bottom/right side of the respective dimension. For example, if the the - * total horizontal padding is 3, then there will be 1 padding on the left, and 2 padding on the right. - */ - enum Pooling3DPaddingType { - CUSTOM = 0; - VALID = 1; - SAME = 2; - } - Pooling3DPaddingType paddingType = 15; - - // Padding before the input in the depth direction. - int32 customPaddingFront = 8; - - // Padding after the input in the depth direction. - int32 customPaddingBack = 9; - - // Padding before the input in the height direction. - int32 customPaddingTop = 10; - - // Padding after the input in the height direction. - int32 customPaddingBottom = 11; - - // Padding before the input in the width direction. - int32 customPaddingLeft = 12; - - // Padding after the input in the width direction. - int32 customPaddingRight = 13; - - // If true, exclude zeros from padding in Average pooling. Meaningless in Max Pooling. - bool countExcludePadding = 14; -} - -/* - * A layer to pool three spatial dimensions down to one value. - * This behaves like a special case of Pooling3DLayerParams in which - * the Kernel is the size of the input and there is no padding. - * - * Input - * A blob with rank equal to 5, representing [Batch, channels, depth, height, width]. - * - * Output - * Rank is same as the input: A blob with rank equal to 5, representing [Batch, channels, depth, height, width]. - * Depth, height, and width of the output will always be 1. - * - * Requires 1 input and produces 1 output. - * - * For example, given an input of shape (1,1,2,3,3): - * +----+----+----+ - * / | 10 | 11 | 12 | - * / +----+----+----+ - * / | 13 | 14 | 15 | - * / +----+----+----+ - * / | 16 | 17 | 18 | - * / +----+----+----+ - * +----+----+----+ / - * | 1 | 2 | 3 | / - * +----+----+----+ / - * | 4 | 5 | 6 | / - * +----+----+----+ / - * | 7 | 8 | 9 | / - * +----+----+----+ - * - * And applying MAX global 3d pooling, we expect to get an output with shape: (1,1,1,1,1) and value: - * +----+ - * | 18 | - * +----+ - */ -message GlobalPooling3DLayerParams { - - enum GlobalPoolingType3D { - MAX = 0; - AVERAGE = 1; - } - - // Whether to use Max or Average - GlobalPoolingType3D type = 1; -} - -/** - * A layer that performs padding along spatial dimensions. - * - * .. code:: - * - * y = PaddingLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with rank at least 2. - * e.g.: blob with shape ``[H_in, W_in]``. - * For ranks greater than 2, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch - * i.e. Padding is applied on last two dimensions. - * - * Output - * Same rank as the input. - * e.g.: blob with shape ``[H_out, W_out]``. - * - * Output dimensions are calculated as follows: - * - * .. code:: - * - * H_out = H_in + topPaddingAmount + bottomPaddingAmount - * W_out = W_in + leftPaddingAmount + rightPaddingAmount - * - * topPaddingAmount == Height startEdgeSize == borderAmounts[0].startEdgeSize - * bottomPaddingAmount == Height endEdgeSize == borderAmounts[0].endEdgeSize - * leftPaddingAmount == Width startEdgeSize == borderAmounts[1].startEdgeSize - * rightPaddingAmount == Width endEdgeSize == borderAmounts[1].endEdgeSize - * - * There are three types of padding: - * - * - ``PaddingConstant``, which fills a constant value at the border. - * - ``PaddingReflection``, which reflects the values at the border. - * - ``PaddingReplication``, which replicates the values at the border. - * - * Given the following input: - * - * .. code:: - * - * [1, 3, 4] : 1 2 3 4 - * 5 6 7 8 - * 9 10 11 12 - * - * Here is the output of applying the padding - * ``(top=2, left=2, bottom=0, right=0)`` - * with each of the supported types: - * - * - ``PaddingConstant`` (``value = 0``): - * .. code:: - * - * [1, 5, 6] : 0 0 0 0 0 0 - * 0 0 0 0 0 0 - * 0 0 1 2 3 4 - * 0 0 5 6 7 8 - * 0 0 9 10 11 12 - * - * - ``PaddingReflection``: - * .. code:: - * - * [1, 5, 6] : 11 10 9 10 11 12 - * 7 6 5 6 7 8 - * 3 2 1 2 3 4 - * 7 6 5 6 7 8 - * 11 10 9 10 11 12 - * - * - ``PaddingReplication``: - * .. code:: - * - * [1, 5, 6] : 1 1 1 2 3 4 - * 1 1 1 2 3 4 - * 1 1 1 2 3 4 - * 5 5 5 6 7 8 - * 9 9 9 10 11 12 - */ -message PaddingLayerParams { - - /** - * Fill a constant value in the padded region. - */ - message PaddingConstant { - float value = 1; - } - - /** - * Reflect the values at the border for padding. - */ - message PaddingReflection { - } - - /** - * Replicate the values at the border for padding. - */ - message PaddingReplication { - } - - oneof PaddingType { - PaddingConstant constant = 1; - PaddingReflection reflection = 2; - PaddingReplication replication = 3; - } - - BorderAmounts paddingAmounts = 10; /// Amounts to be padded to the input. - -} - -/** - * A layer that concatenates along the axis = -3 or -5. - * For general concatenation along any axis, see ConcatNDLayer. - * - * .. code:: - * - * y = ConcatLayer(x1,x2,....) - * - * Requires more than 1 input and produces 1 output. - * - * Input - * All input blobs must have same rank. - * If "sequenceConcat" = False, rank must be greater than equal to 3. In this case concatenation is along axis = -3 - * If "sequenceConcat" = True, rank must be greater than equal to 5. In this case concatenation is along axis = -5 - * - * Output - * Same rank as the input. - * - */ -message ConcatLayerParams { - - /** - * If true, concatenate along the axis = -5 instead of axis = -3. - */ - bool sequenceConcat = 100; - -} - -/** - * A layer that performs local response normalization (LRN). - * - * .. code:: - * - * y = LRNLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with rank greater than equal to 3. - * Example: Rank 4 blob represents [Batch, channels, height, width] - * For ranks greater than 3, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * Output - * A blob with the same shape as the input. - * - * This layer is described by the following formula: - * - * .. math:: - * x_i \leftarrow \dfrac{x_i}{\left ( k + \dfrac{\alpha}{\text{localSize}} \sum_j x_j^2 \right )^\beta} - * - * where the summation is done over a ``(localSize, 1, 1)`` neighborhood --- - * that is, over a window "across" channels in 1x1 spatial neighborhoods. - */ -message LRNLayerParams { - - float alpha = 1; - float beta = 2; - uint64 localSize = 3; /// Number of channels in the normalization window. - float k = 4; /// Defaults to 1 if not set or 0. Must be strictly positive. - -} - -/** - * Softmax Normalization Layer - * - * A layer that performs softmax normalization. - * Normalization is applied along axis = -3 or N-3 (where N is the rank of the input) - * For softmax layer that can operate on any axis, see SoftmaxNDLayer. - * - * - * .. code:: - * - * y = SoftmaxLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * Must be a blob with rank >= 3. - * Output - * A blob with the same shape as the input. - * - * This layer is described by the following formula: - * - * .. math:: - * x_i \leftarrow \dfrac{e^{x_i}}{\sum_i{e^{x_i}}} - */ -message SoftmaxLayerParams { - -} - -/** - * A layer that uniformly splits across axis = -3 to produce a specified number of outputs. - * For general split operation along any axis, see SplitNDLayer. - * - * .. code:: - * - * (y1,y2,...yN) = SplitLayer(x), where N = nOutputs - * - * Requires 1 input and produces multiple outputs. - * - * Input - * A blob with rank at least 3. - * e.g.: blob with shape ``[C, H, W]`` - * Output - * ``nOutputs`` blobs each with same rank as the input. - * e.g.: For input that is of shape ``[C, H, W]``, output shapes will be ``[C/nOutputs, H, W]`` - */ -message SplitLayerParams { - - uint64 nOutputs = 1; /// The number of outputs. - -} - -/** - * A layer that performs elementwise addition. - * This layer has limited broadcasting support. For general broadcasting see AddBroadcastableLayer. - * - * .. code:: - * - * y = AddLayer(x1,x2,...) - * - * Requires 1 or more than 1 input and produces 1 output. - * - * Input - * In general, there are no rank constraints. - * However, only certain set of shapes are broadcastable. For example: - * [B, 1, 1, 1], [B, C, 1, 1], [B, 1, H, W], [B, C, H, W] - * Output - * A blob with shape equal to the input blob. - * - * If only one input is provided, scalar addition is performed: - * - * .. math:: - * y = x + \alpha - * - */ -message AddLayerParams { - - /** - * Scalar to be added to the input. - * Only used if there is a single input. - */ - float alpha = 1; - -} - -/** - * A layer that performs elementwise multiplication. - * This layer has limited broadcasting support. For general broadcasting see MultiplyBroadcastableLayer. - * - * .. code:: - * - * y = MultiplyLayer(x1,x2,...) - * - * Requires 1 or more than 1 input and produces 1 output. - * - * Input - * In general, there are no rank constraints. - * However, only certain set of shapes are broadcastable. For example: - * [B, 1, 1, 1], [B, C, 1, 1], [B, 1, H, W], [B, C, H, W] - * Output - * A blob with shape equal to the first input blob. - * - * If only one input is provided, scalar multiplication is performed: - * - * .. math:: - * y = \alpha x - * - */ -message MultiplyLayerParams { - - /** - * Scalar to be multiplied with the input. - * Only used if there is a single input. - */ - float alpha = 1; - -} - -/** - * A layer that applies a unary function. - * - * .. code:: - * - * y = UnaryFunctionLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with no rank constraints. - * Output - * A blob with the same shape as the input. - * - * The input is first modified by shifting and scaling: - * - * .. math:: - * x \leftarrow \text{scale} \cdot x + \text{shift} - */ -message UnaryFunctionLayerParams { - - /** - * A unary operator. - * - * The following functions are supported: - * - * ``SQRT`` - * .. math:: f(x) = \sqrt{x} - * - * ``RSQRT`` - * .. math:: f(x) = \dfrac{1}{\sqrt{x + \epsilon}} - * - * ``INVERSE`` - * .. math:: f(x) = \dfrac{1}{x + \epsilon} - * - * ``POWER`` - * .. math:: f(x) = x^\alpha - * - * ``EXP`` - * .. math:: f(x) = e^x - * - * ``LOG`` - * .. math:: f(x) = \log x - * - * ``ABS`` - * .. math:: f(x) = |x| - * - * ``THRESHOLD`` - * .. math:: f(x) = \text{max}(\alpha, x) - */ - enum Operation { - SQRT = 0; - RSQRT = 1; - INVERSE = 2; - POWER = 3; - EXP = 4; - LOG = 5; - ABS = 6; - THRESHOLD = 7; - } - Operation type = 1; /// The type of unary function. - - /** - * A constant used in ``POWER`` and ``THRESHOLD`` functions. - */ - float alpha = 2; - - /** - * A small constant to avoid division by 0 while normalizing variance. - * Defaults to ``1e-6`` if not set or set to ``0``. - */ - float epsilon = 3; - - /** - * Input is shifted by this amount - * before the unary function is applied. - * Defaults to ``0.0`` if not set. - */ - float shift = 4; - - /** - * Input is scaled by this amount - * before the unary function is applied. - * Defaults to ``1.0`` if not set or set to ``0``. - */ - float scale = 5; - -} - -/** - * A layer that scales up spatial dimensions. - * It supports two modes: nearest neighbour (default) and bilinear. - * - * .. code:: - * - * y = UpsampleLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with rank at least 3. - * e.g.: blob with shape ``[C, H, W]``. - * For ranks greater than 3, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * - * Output - * Same rank as the input. - * e.g.: blob with shape ``[C, scalingFactor[0] * H, scalingFactor[1] * W]`` - */ -message UpsampleLayerParams { - - /** - * Scaling Factor. Mutually exclusive with fractionalScalingFactor. - * Must be length 2 in order ``[H, W]``. - * If not set, default value ``[1, 1]`` is used. - */ - repeated uint64 scalingFactor = 1; - - /** - * Fractional scaling factor. Mutually exclusive with scalingFactor. - * Must be length 2 in order ``[H, W]``. - * If not set, default value ``[1.0, 1.0]`` is used. - */ - repeated float fractionalScalingFactor = 7; - - /* - * Overall mode for interpolating new elements when upsampling. - * NN - Nearest Neighbors - simply pick the nearest true value for interpolated values. - * BILINEAR - Use bilinear interpolation. See LinearUpsamplingMode for behavior. - */ - enum InterpolationMode { - - NN = 0; /// Nearest Neighbour - BILINEAR = 1; /// Bilinear - - } - - InterpolationMode mode = 5; - - /** - * LinearUpsampleMode specifies the behavior for linear upsampling. Only valid when Interpolation Mode is BILINEAR. - * If input grid is [0, Xin-1] (corresponding to an input size of Xin), and if the output size is Xout, - * then the grid points are sampled in the following manner: - * DEFAULT: - * spacing = (Xin-Xin/Xout) / (Xout-1) - * grid_point[i] = min(Xin-1, max(0, i * spacing)), for i = 0,1,2,….,Xout-1 - * ALIGN_CORNERS_TRUE: - * spacing = (Xin-1) / (Xout-1) - * grid_point[i] = min(Xin-1, max(0, i * spacing)), for i = 0,1,2,….,Xout-1 - * ALIGN_CORNERS_FALSE: - * spacing = Xin / Xout - * grid_point[i] = min(Xin-1, max(0, i * spacing + 0.5 * spacing - 0.5)), for i = 0,1,2,….,Xout-1 - */ - enum LinearUpsampleMode { - - DEFAULT = 0; - ALIGN_CORNERS_TRUE = 1; - ALIGN_CORNERS_FALSE = 2; - - } - - LinearUpsampleMode linearUpsampleMode = 6; - -} - -/** -* A layer that resizes the input to a pre-specified spatial size using bilinear interpolation. -* -* .. code:: -* -* y = ResizeBilinearLayer(x) -* -* Requires 1 input and produces 1 output. -* -* Input -* A blob with rank at least 3. -* e.g.: blob with shape ``[C, H_in, W_in]``. -* For ranks greater than 3, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. -* -* Output -* Same rank as the input. -* e.g.: blob with shape ``[C, H_out, W_out]``. -* -*/ -message ResizeBilinearLayerParams { - - /** - * Target Spatial Size. - * Must be length 2 in order ``[Height, Width]``, i.e. ``[H_out, W_out]``. - * If not set, default value ``[1, 1]`` is used. - */ - repeated uint64 targetSize = 1; - - /** - * Mode used to compute the grid on which the spatial output values are evaluated. - * Same mode is applied to both the height and width axes. - */ - SamplingMode mode = 2; - -} - -/** -* A layer that extracts cropped spatial patches or RoIs (regions of interest) from the input and resizes them to a pre-specified size using -* bilinear interpolation. -* Note that RoI Align layer can be implemented with this layer followed by a pooling layer. -* -* .. code:: -* -* y = CropResizeLayer(x) -* -* Requires 2 inputs and produces 1 output. -* -* Input -* There are two inputs. -* First input represents an image feature map. -* Second input represents the bounding box coordinates for N patches or RoIs (region of interest). -* -* First input is rank 5: [1, Batch, C, H_in, W_in]. -* Second input is rank 5. Its shape can be either [N, 1, 4, 1, 1] or [N, 1, 5, 1, 1]. -* -* N: number of patches/RoIs to be extracted -* -* If RoI shape = ``[N, 1, 4, 1, 1]`` -* The axis=-3 corresponds to the four coordinates specifying the bounding box. -* All the N RoIs are extracted from all the batches of the input. -* -* If RoI shape = ``[N, 1, 5, 1, 1]`` -* The first element of the axis=-3 specifies the input batch id from which to extract the RoI and -* must be in the interval ``[0, Batch - 1]``. That is, n-th RoI is extracted from the RoI[n,0,0,0,0]-th -* input batch id. The last four elements of the axis=-3 specify the bounding box coordinates. -* -* Output -* A blob with rank 5. -* - Shape is [N, Batch, C, H_out, W_out] if input RoI shape is [N, 1, 4, 1, 1] -* - Shape is [N, 1, C, H_out, W_out] if input RoI shape is [N, 1, 5, 1, 1] -* -*/ -message CropResizeLayerParams { - - /** - * Target Spatial Size. - * Must be length 2 in order ``[Height, Width]``, i.e. ``[H_out, W_out]``. - * If not set, default value ``[1, 1]`` is used. - */ - repeated uint64 targetSize = 1; - - /** - * If true the bounding box coordinates must be in the interval [0, 1]. - * They are scaled by (H_in - 1), (W_in - 1), i.e. based on the input spatial dimensions. - * If false the bounding box coordinates must be in the interval - * [0, H_in -1] and [0, W_in - 1], respectively for height and width dimensions. - */ - bool normalizedCoordinates = 2; - - /** - * Mode used to compute the grid on which the spatial output values are evaluated. - * Same mode is applied to both the height and width axes. - */ - SamplingMode mode = 3; - - /** - * Representation used to express the bounding box coordinates. - * It determines how the values of the second input are interpreted. - */ - BoxCoordinatesMode boxIndicesMode = 4; - - /** - * Additional spatial scale that multiplies the bounding box coordinates. - * Generally used while implementing the RoI Align layer, - * which uses unnormalized RoI coordinates along with a spatial scale less than or equal to 1. - */ - float spatialScale = 5; - -} - -/** - * A layer that performs elementwise addition of a bias, - * which is broadcasted to match the input shape. - * - * .. code:: - * - * y = BiasLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with rank at least 3. - * e.g.: blob with shape ``[C, H, W]``. - * For ranks greater than 3, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * Output - * A blob with the same shape as the input. - */ -message BiasLayerParams { - - /** - * The shape of the bias. - * Must be one of the following: - * ``[1]``, ``[C]``, ``[1, H, W]`` or ``[C, H, W]``. - */ - repeated uint64 shape = 1; - - /** - * The bias values. - * The size must be equal to the product of the ``shape`` dimensions. - */ - WeightParams bias = 2; - -} - -/** - * A layer that performs elmentwise multiplication by a scale factor - * and optionally adds a bias; - * both the scale and bias are broadcasted to match the input shape. - * - * .. code:: - * - * y = ScaleLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with rank at least 3. - * e.g.: blob with shape ``[C, H, W]``. - * For ranks greater than 3, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * Output - * A blob with the same shape as the input. - */ -message ScaleLayerParams { - - /** - * The shape of the scale. - * Must be one of the following: - * ``[1]``, ``[C]``, ``[1, H, W]`` or ``[C, H, W]``. - */ - repeated uint64 shapeScale = 1; - - /** - * The scale values. - * The size must be equal to the product of the ``shape`` dimensions. - */ - WeightParams scale = 2; /// Scale values. Size must be equal to the product of dimensions specified in shapeScale. - - bool hasBias = 3; /// If true, a bias is added after scaling. - - /** - * The shape of the bias. - * Must be one of the following: - * ``[1]``, ``[C]``, ``[1, H, W]`` or ``[C, H, W]``. - */ - repeated uint64 shapeBias = 4; - - /** - * The bias values. - * The size must be equal to the product of the ``shape`` dimensions. - */ - WeightParams bias = 5; - -} - -/** - * A layer that loads data as a parameter and provides it as an output. - * The output is rank 5. For general rank, see LoadConstantNDLayer. - * - * .. code:: - * - * y = LoadConstantLayer() - * - * Requires no input and produces 1 output. - * - * Output: - * A blob with rank 5 and shape ``[1, 1, C, H, W]`` - */ -message LoadConstantLayerParams { - - /** - * The shape of the constant to be loaded, - * which must be``[C, H, W]``, that is length 3. - */ - repeated uint64 shape = 1; - - /** - * The data values, - * of size ``C * H * W``. - */ - WeightParams data = 2; - -} - -/** - * A layer that performs L2 normalization, i.e. divides by the - * the square root of the sum of squares of all elements of input. - * - * .. code:: - * - * y = L2NormalizeLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with rank greater than equal to 3. - * For ranks greater than 3, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * Output - * A blob with the same shape as the input. - * - * This layer is described by the following formula: - * - * .. math:: - * x_i \leftarrow \dfrac{x_i}{\sqrt{\sum{x_i^2} + \epsilon}} - */ -message L2NormalizeLayerParams { - - /** - * A small constant to avoid division by 0 while normalizing variance. - * Defaults to ``1e-6`` if not set or set to ``0``. - */ - float epsilon = 1; - -} - -/// Data Reorganization Layers -/// -------------------------- - -/** - * A layer that flattens the input. - * - * .. code:: - * - * y = FlattenLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with rank greater than equal to 3. - * e.g.: Rank 4 blob represents [Batch, C, H, W] - * For ranks greater than 3, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * Output - * Same rank as the input, such that last two dimensions are both 1. - * e.g.: For rank 4 input, output shape is ``[Batch, C * H * W, 1, 1]`` - * - * There are two X orders: ``CHANNEL_FIRST`` and ``CHANNEL_LAST``. - * ``CHANNEL_FIRST`` does not require data to be rearranged, - * because row major ordering is used by internal storage. - * ``CHANNEL_LAST`` requires data to be rearranged. - */ -message FlattenLayerParams { - - enum FlattenOrder { - - CHANNEL_FIRST = 0; - CHANNEL_LAST = 1; - - } - FlattenOrder mode = 1; - -} - -/** - * A layer that recasts the input into a new shape. - * - * .. code:: - * - * y = ReshapeLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with rank 5. - * e.g.: ``[1, 1, C, H, W]`` or ``[Seq, 1, C, H, W]``. - * Output - * A blob with rank 5. - * e.g.: ``[1, 1, C_out, H_out, W_out]`` or ``[Seq_out, 1, C_out, H_out, W_out]``. - * - * There are two reshape orders: ``CHANNEL_FIRST`` and ``CHANNEL_LAST``. - * ``CHANNEL_FIRST`` is equivalent to - * flattening the input to ``[Seq, 1, C * H * W, 1, 1]`` in channel first order - * and then reshaping it to the target shape; - * no data rearrangement is required. - * ``CHANNEL_LAST`` is equivalent to - * flattening the input to ``[Seq, 1, H * W * C, 1, 1]`` in channel last order, - * reshaping it to ``[Seq_out, 1, H_out, W_out, C_out]`` (it is now in "H_out-major"" order), - * and then permuting it to ``[C_out, H_out, W_out]``; - * both the flattening and permuting requires the data to be rearranged. - */ -message ReshapeLayerParams { - - /** - * The shape of the output. - * Must be of length 3 or 4. - * If set to 3, ``targetShape`` is interpreted as - * ``[1, 1, C_out, H_out, W_out]``, and sequence length of the input is preserved. - * If set to 4, ``targetShape`` is interpreted as - * ``[Seq_out, 1, C_out, H_out, W_out]``, - * where ``Seq_out`` is the new sequence length. - */ - repeated int64 targetShape = 1; - - enum ReshapeOrder { - - CHANNEL_FIRST = 0; - CHANNEL_LAST = 1; - - } - ReshapeOrder mode = 2; - -} - -/** - * A layer that rearranges the dimensions and data of an input. - * For generic transpose/permute operation see TransposeLayer. - * - * .. code:: - * - * y = PermuteLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * Must be a rank 5 blob. - * e.g.: shape ``[Seq, B, C, H, W]``. - * Output - * Rank 5 blob. Transposed version of the input, such that dimensions at axis=1 or axis=-4 is unchanged. - * - * - * Examples: - * - * Assume input shape is [Seq, B, C, H, W] - * - * - If ``axis`` is set to ``[0, 3, 1, 2]``, - * then the output has shape ``[Seq, B, W, C, H]`` - * - * - If ``axis`` is set to ``[3, 1, 2, 0]``, - * then the output has shape ``[W, B, C, H, Seq]`` - * - * - If ``axis`` is set to ``[0, 3, 2, 1]``, - * then the output has shape ``[Seq, B, W, H, C]`` - * - * - If ``axis`` is not set, or is set to ``[0, 1, 2, 3]``, - * the output is the same as the input. - */ -message PermuteLayerParams { - - /** - * The order in which to permute the dimensions. - * Must have length 4 and a permutation of ``[0, 1, 2, 3]``. - */ - repeated uint64 axis = 1; - -} - -/** - * A layer that reorganizes data in the input in specific ways. - * - * .. code:: - * - * y = ReorganizeDataLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with rank at least 3. - * e.g.: blob with shape ``[C, H, W]``. - * For ranks greater than 3, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * Output - * Same rank as the input. - * e.g.: blob with shape ``[C_out, H_out, W_out]``. - * - * mode == SPACE_TO_DEPTH - * ``[C_out, H_out, W_out]`` : ``[C * blockSize * blockSize, H/blockSize, W/blockSize]``. - * blockSize must divide H and W. - * Data is moved from the spatial dimensions to the channel dimension. Input is spatially divided into - * non-overlapping blocks of size blockSize X blockSize and data from each block is moved into the - * channel dimension. - * - * mode == DEPTH_TO_SPACE - * ``[C_out, H_out, W_out]`` : ``[C/(blockSize * blockSize), H * blockSize, W * blockSize]``. - * Square of blockSize must divide C. - * Reverse of SPACE_TO_DEPTH. Data is moved from the channel dimension to the spatial dimensions. - * - * mode == PIXEL_SHUFFLE - * ``[C_out, H_out, W_out]`` : ``[C/(blockSize * blockSize), H * blockSize, W * blockSize]``. - * Square of blockSize must divide C. - * Similar to DEPTH_TO_SPACE, but using the pixel-shuffle semantics for channel order in the output space. - * In both modes, elements along the channel dimension are collapsed into - * blocks in the spatial dimensions. The difference is in the arrangement of - * the input-channels' data in the output space. See below example for more - * detail. - * (Only available in Core ML Specification >= 5 (iOS >= 14, macOS >= 11.0) - * - * - * Examples: - * - * Assume input is the following [C = 8, H = 1, W = 2] tensor: - * - * .. code:: - * - * [[[1 2]] [[3 4]] [[5 6]] [[7 8]] [[9 10]] [[11 12]] [[13 14]] [[15 16]]] - * - * If block_size == 2 and mode == DEPTH_TO_SPACE, output will be the following - * [C = 2, H = 2, W = 4] tensor: - * - * .. code:: - * - * [[[ 1 5 2 6] - * [ 9 13 10 14]] - * - * [[ 3 7 4 8] - * [11 15 12 16]]] - * - * For mode == SPACE_TO_DEPTH, the behavior is the same as mode == - * DEPTH_TO_SPACE, but with the input and output swapped. - * - * If block_size == 2 and mode == PIXEL_SHUFFLE, output will be the following - * [C = 2, H = 2, W = 4] tensor: - * - * .. code:: - * - * [[[ 1 3 2 4] - * [ 5 7 6 8]] - * - * [[ 9 11 10 12] - * [13 15 14 16]]] - * - */ -message ReorganizeDataLayerParams { - - enum ReorganizationType { - - SPACE_TO_DEPTH = 0; - DEPTH_TO_SPACE = 1; - PIXEL_SHUFFLE = 2; - - } - ReorganizationType mode = 1; - uint64 blockSize = 2; /// must be greater than 1 - -} - -/** - * A layer that slices the input data along axis = -1 or -2 or -3. - * For general slice along any axis, please see SliceStaticLayer/SliceDynamicLayer. - * - * .. code:: - * - * y = SliceLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob that can, in general, have any rank. However, depending on the value of "axis" , - * there may be additional rank constraints. - * Output - * A blob with the same rank as the input. - * - * Sliced section is taken from the interval ``[startIndex, endIndex)``, i.e. - * startIndex is inclusive while endIndex is exclusive. - * stride must be positive and represents the step size for slicing. - * Negative indexing is supported for startIndex and endIndex. - * -1 denotes N-1, -2 denotes N-2 and so on, where N is the length of the dimension to be sliced. - * - */ -message SliceLayerParams { - - int64 startIndex = 1; /// start of the sliced section. Inclusive. - int64 endIndex = 2; /// end of sliced section. Exclusive. - uint64 stride = 3; /// The step size. Must be positive. - - enum SliceAxis { - - CHANNEL_AXIS = 0; - HEIGHT_AXIS = 1; - WIDTH_AXIS = 2; - - } - // The following mapping is used for interpreting this parameter: - // CHANNEL_AXIS => axis = -3, input must have rank at least 3. - // HEIGHT_AXIS => axis = -2, input must have rank at least 2. - // WIDTH_AXIS => axis = -1 - SliceAxis axis = 4; - -} - -/** - * A layer that reduces the input using a specified operation. - * - * .. code:: - * - * y = ReduceLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob that can, in general, have any rank. However, depending on the value of "axis" , - * there may be additional rank constraints. - * Output - * A blob with the same rank as the input, which has 1s on the dimensions specified in the parameter "axis" - * - * Values supported for axis are [-1], [-2], [-3], [-2,-1], [-3,-2,-1] - * and the equivalent positive values (depending on the rank of the input) - * For mode == 'ArgMax', axis must be [-1] or [-2] or [-3]. - */ -message ReduceLayerParams { - - /* - * The following reduction operations are supported - * and are applied on the specified axis of the input array: - * - * ``SUM`` - * Sum of all elements - * - * .. math:: \sum{x_i} - * - * ``AVG`` - * Sum of all elements divided by the number of elements - * - * .. math:: \dfrac{\sum^n{x_i}}{n} - * - * ``PROD`` - * Product of all elements - * - * .. math:: \prod{x_i} - * - * ``LOGSUM`` - * Sum of the natural logarithm of all elements - * - * .. math:: \sum{\ln{(x_i + \epsilon)}} - * - * ``SUMSQUARE`` - * Sum of squares of all elements - * - * .. math:: \sum{x^2} - * - * ``L1`` - * L1 normalization of all elements - * - * .. math:: ||x||_1 = \sum{|x_i|} - * - * ``L2`` - * L2 normalization of all elements - * - * .. math:: ||x||_2 = \sqrt{\sum{x_i^2}} - * - * ``MAX`` - * Maximum of all elements - * - * .. math:: \text{max}(x_i) - * - * ``MIN`` - * Minumum of all elements - * - * .. math:: \text{min}(x_i) - * - * ``ARGMAX`` - * Argument of the maximum of all elements - * - * .. math:: \text{argmax}(x_i) - * - */ - enum ReduceOperation { - - SUM = 0; - AVG = 1; - PROD = 2; - LOGSUM = 3; - SUMSQUARE = 4; - L1 = 5; - L2 = 6; - MAX = 7; - MIN = 8; - ARGMAX = 9; /// only supported with axis = C, H or W. - - } - ReduceOperation mode = 1; /// Specifies function used to reduce. - - /** - * Used if mode is ``LOGSUM``. - * Defaults to ``1e-6`` if not set or is set to ``0``. - */ - float epsilon = 2; - - enum ReduceAxis { - - CHW = 0; - HW = 1; - C = 2; - H = 3; - W = 4; - - } - - // The following mapping is used for interpreting this parameter: - // CHW = axis [-3, -2, -1], input must have rank at least 3. - // HW = axis [-2, -1], input must have rank at least 2. - // C = axis [-3] - // H = axis [-2] - // W = axis [-1] - ReduceAxis axis = 3; - -} - -/** - * A layer that crops the spatial dimensions of an input. - * If two inputs are provided, the shape of the second input is used as the reference shape. - * - * .. code:: - * - * y = CropLayer(x1) or y = CropLayer(x1,x2) - * - * Requires 1 or 2 inputs and produces 1 output. - * - * Input - * 1 or 2 tensors, each with rank at least 3, both inputs must have equal rank. - * Example: - * - 1 input case: A blob with shape ``[C, H_in, W_in]``. - * - 2 input case: 1st blob with shape ``[C, H_in, W_in]``, 2nd blob with shape ``[C, H_out, W_out]``. - * - * For ranks greater than 3, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * - * Output - * Same rank as the inputs. - * e.g.: A blob with shape ``[C, H_out, W_out]``. - * - * If one input is used, output is computed as follows: - * - * .. code:: - * - * y = x1[:, topCropAmount:H_in - bottomCropAmount, leftCropAmount:W_in - rightCropAmount] - * - * topCropAmount == Height startEdgeSize == borderAmounts[0].startEdgeSize - * bottomCropAmount == Height endEdgeSize == borderAmounts[0].endEdgeSize - * leftCropAmount == Width startEdgeSize == borderAmounts[1].startEdgeSize - * rightCropAmount == Width endEdgeSize == borderAmounts[1].endEdgeSize - * - * H_out = H_in - topCropAmount - bottomCropAmount - * W_out = W_in - leftCropAmount - rightCropAmount - * - * If two inputs are used, output is computed as follows: - * - * .. code:: - * - * y = x1[:, offset[0]:offset[0] + H_out, offset[1]:offset[1] + W_out] - */ -message CropLayerParams { - - /** - * The amounts to be cropped from the input. - * Used only if a single input is provided. - */ - BorderAmounts cropAmounts = 1; - - /** - * The offset amounts. - * Used only if two inputs are provided. - * Must be of length 2, in order ``[H, W]``. - */ - repeated uint64 offset = 5; - -} - -/** - * A layer that computes the elementwise average of the inputs. - * This layer has limited broadcasting support. For general broadcasting see AddBroadcastableLayer. - * - * .. code:: - * - * y = AverageLayer(x1,x2,...) - * - * Requires multiple inputs and produces 1 output. - * - * Input - * In general, there are no rank constraints. - * However, only certain set of shapes are broadcastable. For example: - * [B, 1, 1, 1], [B, C, 1, 1], [B, 1, H, W], [B, C, H, W] - * Output - * A blob with the same shape as each input. - */ -message AverageLayerParams { - -} - -/** - * A layer that computes the elementwise maximum over the inputs. - * - * .. code:: - * - * y = MaxLayer(x1,x2,...) - * - * Requires multiple inputs and produces 1 output. - * - * Input - * In general, there are no rank constraints. - * However, only certain set of shapes are broadcastable. For example: - * [B, C, 1, 1], [B, C, H, W] - * Output - * A blob with the same shape as each input. - */ -message MaxLayerParams { - -} - -/** - * A layer that computes the elementwise minimum over the inputs. - * - * .. code:: - * - * y = MinLayer(x1,x2,...) - * - * Requires multiple inputs and produces 1 output. - * - * Input - * In general, there are no rank constraints. - * However, only certain set of shapes are broadcastable. For example: - * [B, C, 1, 1], [B, C, H, W] - * Output - * A blob with the same shape as each input. - */ -message MinLayerParams { - -} - -/** - * A layer that computes the dot product of two vectors. - * - * .. code:: - * - * y = DotProductLayer(x1,x2) - * - * Requires 2 inputs and produces 1 output. - * - * Input - * Two blobs with rank at least 3, such that the last two dimensions must be 1. - * e.g.: blobs with shape ``[B, C, 1, 1]``. - * For ranks greater than 3, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * - * Output - * Same rank as the input. - * e.g. for rank 4 inputs, output shape: [B, 1, 1, 1] - */ -message DotProductLayerParams { - - /** - * If true, inputs are normalized first, - * thereby computing the cosine similarity. - */ - bool cosineSimilarity = 1; - -} - -/** - * A layer that performs mean variance normalization, along axis = -3. - * - * .. code:: - * - * y = MeanVarianceNormalizeLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with rank greater than equal to 3. - * Example: Rank 4 blob represents [Batch, channels, height, width] - * For ranks greater than 3, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch. - * - * Output - * A blob with the same shape as the input. - * - * If ``acrossChannels == true`` - * normalization is performed on flattened input, i.e. the input is reshaped to (Batch,C), where "Batch" contains - * all dimensions from 0 to -4 (inclusive), and C contains dimensions -1, -2, -3. - * - * If ``acrossChannels == false`` - * normalization is performed within a channel, - * across spatial dimensions (i.e. last two dimensions). - */ -message MeanVarianceNormalizeLayerParams { - - /** - * If true, mean and variance are computed across channels. - */ - bool acrossChannels = 1; - - /** - * If false, only mean is subtracted. - */ - bool normalizeVariance = 2; - - /** - * A small constant to avoid division by 0 while normalizing variance. - * Defaults to ``1e-6`` if not set or set to ``0``. - */ - float epsilon = 3; - -} - -/** - * A layer that repeats a sequence or the dimension sitting at axis = -5 - * - * .. code:: - * - * y = SequenceRepeatLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A blob with rank at least 5. - * e.g: shape ``[Seq, B, C, H, W]`` - * Output - * A blob with the same rank as the input. - * e.g.: for input shape ``[Seq, B, C, H, W]``, output shape is ``[nRepetitions * Seq, B, C, H, W]``. - */ -message SequenceRepeatLayerParams { - - /** - * Number of repetitions. - * Defaults to ``1`` if not set or set to ``0``. - */ - uint64 nRepetitions = 1; - -} - -/// Recurrent Layers -/// ---------------- - -/* - * The following activations are supported with recurrent layers: - * - Linear - * - Sigmoid - * - Tanh - * - ReLU - * - Scaled Hyperbolic Tangent: alpha * tanh(beta * x), currently only supported for alpha = 1.7159, beta = 2/3 - * - Hard Sigmoid: min(max(alpha * x + beta, 0), 1), currently only supported for alpha = 0.2, beta = 0.5 - */ - -/** - * A simple recurrent layer. - * - * .. code:: - * - * y_t = SimpleRecurrentLayer(x_t, y_{t-1}) - * - * Input - * A blob of rank 5, with shape `[Seq, Batch, inputVectorSize, 1, 1]``. - * This represents a sequence of vectors of size ``inputVectorSize``. - * Output - * Same rank as the input. - * Represents a vector of size ``outputVectorSize``. It is either the final output or a sequence of outputs at all time steps. - * - * - Output Shape: ``[1, Batch, outputVectorSize, 1, 1]`` , if ``sequenceOutput == false`` - * - Output Shape: ``[Seq, Batch, outputVectorSize, 1, 1]`` , if ``sequenceOutput == true`` - * - * This layer is described by the following equation: - * - * .. math:: - * \boldsymbol{y_t} = f(\mathrm{clip}(W \boldsymbol{x_t} + \ - * R \boldsymbol{y_{t-1}} + b)) - * - * - ``W`` is a 2-dimensional weight matrix - * (``[outputVectorSize, inputVectorSize]``, row-major) - * - ``R`` is a 2-dimensional recursion matrix - * (``[outputVectorSize, outputVectorSize]``, row-major) - * - ``b`` is a 1-dimensional bias vector (``[outputVectorSize]``) - * - ``f()`` is an activation - * - ``clip()`` is a function that constrains values between ``[-50.0, 50.0]`` - */ -message SimpleRecurrentLayerParams { - - uint64 inputVectorSize = 1; /// The size of the input vectors. - uint64 outputVectorSize = 2; /// The size of the output vectors. - - /** - * Activations supported are Linear, Sigmoid, Tanh, ReLU, Scaled Tanh (alpha = 1.71, beta = 2/3), Hard sigmoid (alpha = 0.2, beta = 0.5) - */ - ActivationParams activation = 10; /// The activation function. - - /** - If false output is just the result after final state update. - If true, output is a sequence, containing outputs at all time steps. - */ - bool sequenceOutput = 15; - - bool hasBiasVector = 20; /// If false, no bias is added. - - WeightParams weightMatrix = 30; /// Weight matrix W. - WeightParams recursionMatrix = 31; /// Recursion Weight matrix R. - WeightParams biasVector = 32; /// Bias vector b. - - bool reverseInput = 100; - // If true, then the node processes the input sequence from right to left - -} - -/** - * Gated-Recurrent Unit (GRU) Layer - * - * .. code:: - * - * y_t = GRULayer(x_t, y_{t-1}) - * - * Input - * A blob of rank 5, with shape `[Seq, Batch, inputVectorSize, 1, 1]``. - * This represents a sequence of vectors of size ``inputVectorSize``. - * Output - * Same rank as the input. - * Represents a vector of size ``outputVectorSize``. It is either the final output or a sequence of outputs at all time steps. - * - * - Output Shape: ``[1, Batch, outputVectorSize, 1, 1]`` , if ``sequenceOutput == false`` - * - Output Shape: ``[Seq, Batch, outputVectorSize, 1, 1]`` , if ``sequenceOutput == true`` - * - * This layer is described by the following equations: - * - * Update Gate - * .. math:: - * \boldsymbol{z_t} = \ - * f(\mathrm{clip}(W_z \boldsymbol{x_t} + \ - * R_z \boldsymbol{y_{t-1}} + b_z) - * - * Reset Gate - * .. math:: - * \boldsymbol{r_t} = \ - * f(\mathrm{clip}(W_r \boldsymbol{x_t} + \ - * R_r \boldsymbol{y_{t-1}} + b_r)) - * - * Cell Memory State - * .. math:: - * \boldsymbol{c_t} = \ - * \boldsymbol{y_{t-1}} \odot \boldsymbol{r_t} - * - * Output Gate - * .. math:: - * \boldsymbol{o_t} = \ - * g(\mathrm{clip}(W_o \boldsymbol{x_t} + \ - * R_o \boldsymbol{c_t} + b_o)) - * - * Output - * .. math:: - * \boldsymbol{y_t} = \ - * (1 - \boldsymbol{z_t}) \odot \boldsymbol{o_t} + \ - * \boldsymbol{z_t} \odot \boldsymbol{y_{t-1}} - * - * - ``W_z``, ``W_r``, ``W_o`` are 2-dimensional input weight matrices - * (``[outputVectorSize, inputVectorSize]``, row-major) - * - ``R_z``, ``R_r``, ``R_o`` are 2-dimensional recursion matrices - * (``[outputVectorSize, outputVectorSize]``, row-major) - * - ``b_z``, ``b_r``, ``b_o`` are 1-dimensional bias vectors - * (``[outputVectorSize]``) - * - ``f()``, ``g()`` are activations - * - ``clip()`` is a function that constrains values between ``[-50.0, 50.0]`` - * - ``⊙`` denotes the elementwise product of matrices - */ -message GRULayerParams { - - uint64 inputVectorSize = 1; /// Size of the input vectors. - uint64 outputVectorSize = 2; /// Size of the output vectors. - - /** - * 2 element array representing activations [f(), g()] in that order. - * Typical values used = [sigmoid, tanh]. - * Activations supported are Linear, Sigmoid, Tanh, ReLU, Scaled Tanh (alpha = 1.71, beta = 2/3), Hard sigmoid (alpha = 0.2, beta = 0.5) - */ - repeated ActivationParams activations = 10; - - /** - * If false output is just the result after final state update. - * If true, output is a sequence, containing outputs at all time steps. - */ - bool sequenceOutput = 15; - - /** - * If false, no biases (``b_z``, ``b_r``, ``b_o``) are added. - */ - bool hasBiasVectors = 20; - - WeightParams updateGateWeightMatrix = 30; /// Weight Matrix W_z. - WeightParams resetGateWeightMatrix = 31; /// Weight Matrix W_r. - WeightParams outputGateWeightMatrix = 32; /// Weight Matrix W_o. - - WeightParams updateGateRecursionMatrix = 50; /// Recursion Weight Matrix R_z. - WeightParams resetGateRecursionMatrix = 51; /// Recursion Weight Matrix R_r. - WeightParams outputGateRecursionMatrix = 52; /// Recursion Weight Matrix R_o. - - WeightParams updateGateBiasVector = 70; /// Bias vector b_z. - WeightParams resetGateBiasVector = 71; /// Bias vector b_r. - WeightParams outputGateBiasVector = 72; /// Bias vector b_o. - - /// If true, then the node processes the input sequence from right to left - bool reverseInput = 100; - -} - -/** - * Long short-term memory (LSTM) parameters. - * - * This is described by the following equations: - * - * Input Gate - * .. math:: - * \boldsymbol{i_t} = \ - * f(\mathrm{clip}(W_i \boldsymbol{x_t} + \ - * R_i \boldsymbol{y_{t-1}} + \ - * p_i \odot c_{t-1} + b_i)) - * - * Forget Gate - * .. math:: - * \boldsymbol{f_t} = \ - * f(\mathrm{clip}(W_f \boldsymbol{x_t} + \ - * R_f \boldsymbol{y_{t-1}} + \ - * p_f \odot c_{t-1} + b_f)) - * - * Block Input - * .. math:: - * \boldsymbol{z_t} = \ - * g(\mathrm{clip}(W_z \boldsymbol{x_t} + \ - * R_z \boldsymbol{y_{t-1}} + b_z)) - * - * Cell Memory State - * .. math:: - * \boldsymbol{c_t} = \ - * \boldsymbol{c_{t-1}} \odot \boldsymbol{f_t} + \ - * \boldsymbol{i_t} \odot \boldsymbol{z_t} - * - * Output Gate - * .. math:: - * \boldsymbol{o_t} = \ - * f(\mathrm{clip}(W_o \boldsymbol{x_t} + \ - * R_o \boldsymbol{y_{t-1}} + \ - * p_o \odot c_t + b_o)) - * - * Output - * .. math:: - * \boldsymbol{y_t} = \ - * h(\boldsymbol{c_t}) \odot \boldsymbol{o_t} - * - * - ``W_i``, ``W_f``, ``W_z``, ``W_o`` are 2-dimensional input weight matrices - * (``[outputVectorSize, inputVectorSize]``, row-major) - * - ``R_i``, ``R_f``, ``R_z``, ``R_o`` are 2-dimensional recursion matrices - * (``[outputVectorSize, outputVectorSize]``, row-major) - * - ``b_i``, ``b_f``, ``b_z``, ``b_o`` are 1-dimensional bias vectors - * (``[outputVectorSize]``) - * - ``p_``, ``p_f``, ``p_o`` are 1-dimensional peephole vectors - * (``[outputVectorSize]``) - * - ``f()``, ``g()``, ``h()`` are activations - * - ``clip()`` is a function that constrains values between ``[-50.0, 50.0]`` - * - ``⊙`` denotes the elementwise product of matrices - */ -message LSTMParams { - - /** - * If true, output is a sequence, containing outputs at all time steps. - * If false, output is just the result after final state update. - */ - bool sequenceOutput = 10; - - /** - * If false, no biases (``b_i``, ``b_f``, ``b_z``, ``b_o``) are added. - */ - bool hasBiasVectors = 20; - - /** - * If true, a vector of ``1`` values is added to ``b_f``. - */ - bool forgetBias = 30; - - /** - * If true, peephole vectors are included. - */ - bool hasPeepholeVectors = 40; - - /** - * If the coupled Input and Forget flag is on, the behaviour of - * ``c_t`` is changed to the following (i.e. forget gate is not used): - * - * .. math:: - * \boldsymbol{c_t} = \ - * \boldsymbol{c_{t-1}} \odot (1 - \boldsymbol{i_t}) + \ - * \boldsymbol{i_t} \odot \boldsymbol{z_t} - * - */ - bool coupledInputAndForgetGate = 50; - - /** - * Places a limit on the maximum and minimum values of ``c_t``. - * c_t = min(c_t, cellClipThreshold) - * c_t = max(c_t, -cellClipThreshold) - * If 0, it is set to its default value = 50.0. - */ - float cellClipThreshold = 60; - -} - -/** - * Weights for long short-term memory (LSTM) layers - */ -message LSTMWeightParams { - - WeightParams inputGateWeightMatrix = 1; /// Weight Matrix W_i. - WeightParams forgetGateWeightMatrix = 2; /// Weight Matrix W_f. - WeightParams blockInputWeightMatrix = 3; /// Weight Matrix W_z. - WeightParams outputGateWeightMatrix = 4; /// Weight Matrix W_o. - - WeightParams inputGateRecursionMatrix = 20; /// Recursion Weight Matrix R_i. - WeightParams forgetGateRecursionMatrix = 21; /// Recursion Weight Matrix R_f. - WeightParams blockInputRecursionMatrix = 22; /// Recursion Weight Matrix R_z. - WeightParams outputGateRecursionMatrix = 23; /// Recursion Weight Matrix R_o. - - //biases: - WeightParams inputGateBiasVector = 40; /// Bias vector b_i. - WeightParams forgetGateBiasVector = 41; /// Bias vector b_f. - WeightParams blockInputBiasVector = 42; /// Bias vector b_z. - WeightParams outputGateBiasVector = 43; /// Bias vector b_o. - - //peepholes: - WeightParams inputGatePeepholeVector = 60; /// Peephole vector p_i. - WeightParams forgetGatePeepholeVector = 61; /// Peephole vector p_f. - WeightParams outputGatePeepholeVector = 62; /// Peephole vector p_o. - -} - -/** - * A unidirectional long short-term memory (LSTM) layer. - * - * .. code:: - * - * (y_t, c_t) = UniDirectionalLSTMLayer(x_t, y_{t-1}, c_{t-1}) - * - * Input - * A blob of rank 5, with shape `[Seq, Batch, inputVectorSize, 1, 1]``. - * This represents a sequence of vectors of size ``inputVectorSize``. - * Output - * Same rank as the input. - * Represents a vector of size ``outputVectorSize``. It is either the final output or a sequence of outputs at all time steps. - * - * - Output Shape: ``[1, Batch, outputVectorSize, 1, 1]`` , if ``sequenceOutput == false`` - * - Output Shape: ``[Seq, Batch, outputVectorSize, 1, 1]`` , if ``sequenceOutput == true`` - * - */ -message UniDirectionalLSTMLayerParams { - - uint64 inputVectorSize = 1; /// Size of the input vectors. - uint64 outputVectorSize = 2; /// Size of the output vectors. - - /** - * 3 element array representing activations [f(),g(),h()] in that order. - * Typical values used = [sigmoid, tanh, tanh]. - * Activations supported are Linear, Sigmoid, Tanh, ReLU, Scaled Tanh (alpha = 1.71, beta = 2/3), Hard sigmoid (alpha = 0.2, beta = 0.5) - */ - repeated ActivationParams activations = 10; - - LSTMParams params = 15; - - LSTMWeightParams weightParams = 20; /// Weights, biases and peepholes. - - /// If true, then the node processes the input sequence from right to left - bool reverseInput = 100; - -} - -/** - * Bidirectional long short-term memory (LSTM) layer - * - * .. code:: - * - * (y_t, c_t, y_t_reverse, c_t_reverse) = BiDirectionalLSTMLayer(x_t, y_{t-1}, c_{t-1}, y_{t-1}_reverse, c_{t-1}_reverse) - * - * Input - * A blob of rank 5, with shape `[Seq, Batch, inputVectorSize, 1, 1]``. - * This represents a sequence of vectors of size ``inputVectorSize``. - * Output - * Same rank as the input. - * Represents a vector of size ``2 * outputVectorSize``. It is either the final output or a sequence of outputs at all time steps. - * - * - Output Shape: ``[1, Batch, 2 * outputVectorSize, 1, 1]`` , if ``sequenceOutput == false`` - * - Output Shape: ``[Seq, Batch, 2 * outputVectorSize, 1, 1]`` , if ``sequenceOutput == true`` - * - * - * The first LSTM operates on the input sequence in the forward direction. - * The second LSTM operates on the input sequence in the reverse direction. - * - * Example: given the input sequence ``[x_1, x_2, x_3]``, - * where ``x_i`` are vectors at time index ``i``: - * - * The forward LSTM output is ``[yf_1, yf_2, yf_3]``, - * - * where ``yf_i`` are vectors of size ``outputVectorSize``: - * - * - ``yf_1`` is the output at the end of sequence {``x_1``} - * - ``yf_2`` is the output at the end of sequence {``x_1``, ``x_2``} - * - ``yf_3`` is the output at the end of sequence {``x_1``, ``x_2``, ``x_3``} - * - * The backward LSTM output: ``[yb_1, yb_2, yb_3]``, - * - * where ``yb_i`` are vectors of size ``outputVectorSize``: - * - * - ``yb_1`` is the output at the end of sequence {``x_3``} - * - ``yb_2`` is the output at the end of sequence {``x_3``, ``x_2``} - * - ``yb_3`` is the output at the end of sequence {``x_3``, ``x_2``, ``x_1``} - * - * Output of the bi-dir layer: - * - * - if ``sequenceOutput = True`` : { ``[yf_1, yb_3]``, ``[yf_2, yb_2]``, ``[yf_3, yb_1]`` } - * - if ``sequenceOutput = False`` : { ``[yf_3, yb_3]`` } - */ -message BiDirectionalLSTMLayerParams { - - /** - * Size of the input vectors. - */ - uint64 inputVectorSize = 1; - /** - * Size of the outputs vectors. - * It is same for both forward and backward LSTMs. - */ - uint64 outputVectorSize = 2; - - /** - * 3 element array representing activations [f(),g(),h()] in that order. - * Typical values used = [sigmoid, tanh, tanh]. - * Activations supported are Linear, Sigmoid, Tanh, ReLU, Scaled Tanh (alpha = 1.71, beta = 2/3), Hard sigmoid (alpha = 0.2, beta = 0.5) - */ - repeated ActivationParams activationsForwardLSTM = 10; - /** - * Currently, backward LSTM activations - * must be same as the ones for the forward LSTM. - */ - repeated ActivationParams activationsBackwardLSTM = 11; - - /** - * Common parameters shared by the forward and backward LSTMs. - */ - LSTMParams params = 15; - - /** - * Weights and biases. - * Must be a length 2 message, - * for the forward and backward LSTM respectively. - */ - repeated LSTMWeightParams weightParams = 20; - -} - -message CustomLayerParams { - - message CustomLayerParamValue { - oneof value { - double doubleValue = 10; - string stringValue = 20; - int32 intValue = 30; - int64 longValue = 40; - bool boolValue = 50; - } - } - - string className = 10; // The name of the class (conforming to MLCustomLayer) corresponding to this layer - repeated WeightParams weights = 20; // Any weights -- these are serialized in binary format and memmapped at runtime - map parameters = 30; // these may be handled as strings, so this should not be large - string description = 40; // An (optional) description of the layer provided by the model creator. This information is displayed when viewing the model, but does not affect the model's execution on device. - -} - -/** - * A layer that rearranges the dimensions and data of an input. - * - * .. code:: - * - * y = TransposeLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * A N-Dimensional tensor. - * Output - * A N-Dimensional tensor of the same rank but with dimensions and data permuted according to axes. - * Shape: ``[InputShape[axis[0]], InputShape[axis[1]], ... , InputShape[axis[N-1]]]`` - * - * Examples: - * - * - If ``axes`` is set to ``[3, 1, 2, 0]`` and the input shape is ``[6,7,8,9]``, - * then the output has shape ``[9,7,8,6]`` - */ - -message TransposeLayerParams { - - /** - * Length of "axes" should match the rank of input & output tensor - * "axes" should be a permutation of "[0,1,2,...,N-1]" where N is the rank. - */ - repeated uint64 axes = 1; // - -} - -/** - * A layer that computes the matrix multiplication of two tensors with numpy-like broadcasting - * where the matrices reside in the last two indices of the tensor. - * - * .. code:: - * - * y = BatchedMatMul(a,b) - * - * Requires 1 or 2 inputs and produces 1 output. - * - * The first tensor, "a", must be provided as an input. The second tensor can either be an input or provided as a weight matrix parameter. - * - * Input - * - a: First N-Dimensional tensor - * - b: Second N-Dimensional tensor (either a rank-N input or a matrix, i.e. N=2, provided as a layer parameter) - * - * Output - * A tensor containing the matrix product of two tensors. - * When there are two inputs: rank is max(2, rank(a), rank(b)) - * When there is one input: rank is same as that of the input. - * - * This operation behaves as following: - * - * When there are two inputs: - * - If N >= 2 for both tensors, it is treated as a batch of matrices residing in the last two indices. - * All the indices, except for the last two, are broadcasted using conventional rules. - * - If the first tensor is 1-D, it is converted to a 2-D tensor by prepending a 1 to its shape. Eg. (D) -> (1,D) - * - If the second tensor is 1-D, it is converted to a 2-D tensor by appending a 1 to its shape. Eg. (D) -> (D,1) - * - * When there is one input: - * - The weight matrix corresponds to a matrix, of shape (X1, X2). Values of X1, X2 must be provided as layer parameters. - * - The input, "a", is reshaped into a matrix by combining all the leading dimensions, except the last, into a batch dimension. eg: - * - if "a" is rank 1 (X1,) --> (1, X1). Output shape will be (X2,) - * - if "a" is rank 2 (B1, X1) --> no need to reshape. Output shape will be (B1, X2) - * - if "a" is rank 3 (B1, B2, X1) --> (B1 * B2, X1). Output shape will be (B1, B2, X2) - * - etc - */ -message BatchedMatMulLayerParams { - - /** - * If transposeA is true, it transposes the left matrix on the fly before matrix multiplication. - * (is ignored when there is one input) - */ - bool transposeA = 1; - /** - * If transposeB is true, it transposes the right matrix on the fly before matrix multiplication. - * (is ignored when there is one input) - */ - bool transposeB = 2; - - /* - * Following parameters are ignored when there are two inputs. - */ - - uint64 weightMatrixFirstDimension = 5; /// X1: same as the last dimension of the input tensor - uint64 weightMatrixSecondDimension = 6; /// X2: same as the last dimension of the output tensor - - bool hasBias = 7; /// Whether a bias is added or not. Supported only when there is one input. - - /* - * Weight matrix representing shape [X1, X2]. - * Values are however stored in column major order, - * in the "repeated float" or "bytes" fields of the message "WeightParams" - */ - WeightParams weights = 8; - WeightParams bias = 9; /// Bias vector [X2]. Supported only when there is one input. - - /** - * If set, this layer, at runtime, quantizes the floating point input blob to int8 before applying the - * matrix multiplication using the INT8 weight parameters provided in weights->int8RawValue. The - * result is then dequantized. - * Requires: - * * number of inputs to be 1 - * * hasBias == false - * * QuantizationType == LinearQuantizationParams, such that - * * size of the "scale" field is 1 and "bias" field is empty in "LinearQuantizationParams" - * * numberOfBits == 8 - * * weights->rawValue_size to be empty - */ - bool int8DynamicQuantize = 10; - -} - -/** - * A layer that concatenates a list of tensors along a specified axis. - * - * .. code:: - * - * y = ConcatNDLayer(x1,x2,....) - * - * Requires at least 2 input and produces 1 output. - * - * Input - * The rank of the input tensors must match and all dimensions also must match, except for the dimension 'axis'. - * - * - * Output - * Same rank as the input. The dimension along "axis", is the sum of the dimensions of the inputs. - * - * example: - * - * in1 : shape (3, 2), value = [[1, 2], [3, 4], [5, 6]] - * in2 : shape (3, 2), value = [[7, 8], [9, 10], [11, 12]] - * axis = 0 - * - * if interleave = False (default) - * output : shape (6, 2) - * output[0:3, :] = in1 - * output[3:6, :] = in2 - * value = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]] - * - * if interleave = True - * output : shape (6, 2) - * output[0::2, :] = in1 - * output[1::2, :] = in2 - * value = [[1, 2], [7, 8], [3, 4], [9, 10], [5, 6], [11, 12]] - * - */ -message ConcatNDLayerParams { - - /** - * Dimension along which to concatenate. Supports negative values of the parameter 'axis'. - */ - int64 axis = 1; - - /** - * (Only available in Core ML Specification >= 5 (iOS >= 14, macOS >= 11.0) - * Interleave option. If True, concatenation is done via interleaving the inputs. - * This requires all inputs to have the exact same shape. - */ - bool interleave = 2; - - -} - -/** - * A layer that performs softmax normalization along a specified axis. - * - * .. code:: - * - * y = SoftmaxNDLayer(x) - * - * Requires 1 input and produces 1 output. - * - * Output shape is same as the input. - */ -message SoftmaxNDLayerParams { - - /** - * Dimension on which the softmax would be performed. Supports negative values of the parameter 'axis'. - */ - int64 axis = 1; - -} - -/** - * A layer that reverses specific dimensions of the input tensor. - * It is similar in functionality to the numpy.flip method. - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - */ -message ReverseLayerParams { - - /** - * Reverses each dimension of the input tensor for which corresponding reverseDim is set to True. - * Requires len(reverseDim) == rank(inputTensor) - */ - repeated bool reverseDim = 1; - -} - -/** - * A layer that reverses variable length slices. - * - * Requires 2 inputs and produces 1 output. - * - * 2 inputs, in order are denoted by "data", "seq_lengths". - * "seq_lenghts" must be a rank 1 tensor, i.e. seq_lengths.shape = (B,) - * which contains the lengths of the amount of sequence to be reversed, for each element of the batch. - * Dimension "batchAxis" in "data" must be equal to B, i.e, - * data.shape[batchAxis] = B. - * - * According to the batch axis, input "data" is first divided into a batch of B inputs, - * each of which is flipped along the dimension "sequenceAxis", by the amount specified in - * "seq_lengths", the second input. - * - * e.g.: - * - * data [shape = (2,4)]: - * [0 1 2 3] - * [4 5 6 7] - * seq_lengths [shape = (2,)]: - * [3, 0] - * batchAxis = 0 - * sequenceAxis = 1 - * - * output [shape = (2,4)]: - * [2 1 0 3] - * [4 5 6 7] - * - * - * data [shape = (2,3,2)]: - * [0 1] - * [2 3] - * [4 5] (slice = 0) - * [6 7] - * [8 9] - * [10 11] (slice = 1) - * seq_lengths [shape = (2,)]: - * [2, 3] - * batchAxis = 0 - * sequenceAxis = 1 - * - * output [shape = (2,3,2)]: - * [2 3] - * [0 1] - * [4 5] (slice = 0) - * [10 11] - * [8 9] - * [6 7] (slice = 1) - * - * Output shape is same as the input. - */ -message ReverseSeqLayerParams { - - int64 batchAxis = 1; // batch axis has to be strictly less than seq_axis - int64 sequenceAxis = 2; - -} - -/** - * A layer that loads data as a parameter and provides it as an output. - * - * .. code:: - * - * y = LoadConstantNDLayer() - * - * Requires no input and produces 1 output. - * - * Output: A tensor with shape as provided in the parameter "shape" - */ -message LoadConstantNDLayerParams { - - /** - * The shape of the constant to be loaded. - */ - repeated uint64 shape = 1; - WeightParams data = 2; - -} - -/** - * A layer that generates an output tensor with a constant value. - * Input is only used to determine the shape of the output. - * This layer is used to allocate a tensor with a dynamic shape (that of the input) and constant value. - * - * Requires 1 input and produces 1 output. - * - * .. code:: - * - * y = FillLikeLayer(x) - * - * Input - * A N-Dimensional tensor, whose values are ignored. Only the shape is used to - * infer the shape of the output. - * - * Output - * A N-Dimensional tensor with the same shape as the input tensor. - * - */ -message FillLikeLayerParams { - - float value = 1; - -} - -/** - * A layer that generates an output tensor with a constant value. - * This layer is used to allocate a tensor with a static shape and constant value. - * - * Requires no input and produces 1 output. - * - * .. code:: - * - * y = FillStaticLayer(x) - * - * Output - * A N-Dimensional tensor of shape "targetShape". - * - */ -message FillStaticLayerParams { - - float value = 1; - repeated uint64 targetShape = 2; - -} - -/** - * A layer that generates an output tensor with a constant value. - * This layer is used to allocate a tensor with a dynamic shape (as specified by the input) and constant value. - * - * Requires 1 input and produces 1 output. - * - * .. code:: - * - * y = FillDynamicLayer(x) - * - * Input - * A rank 1 tensor specifying the shape of the output - * - * Output - * An N-Dimensional tensor with the shape specified by the values in the input tensor. - * - */ -message FillDynamicLayerParams { - - float value = 1; - -} - -/** - * A layer that returns the elements either from tensor x or tensor y, - * depending on the value in the condition tensor. - * It is similar in functionality to the numpy.where method with 3 inputs. - * - * Requires 3 inputs and produces 1 output. - * Inputs, in order, are the condition tensor, x and y. - * - * for each vector index (i,...,j): - * output[i,...,j] = x[i,...,j] if condition[i,...,j] = True - * y[i,...,j] if condition[i,...,j] = False - * - * All the 3 inputs are first broadcasted to a common shape. - * (the shapes must be broadcastable) - * - * output.rank = max(input[0].rank, input[1].rank, input[2].rank) - * - */ -message WhereBroadcastableLayerParams { - -} - -/** - * A layer that computes elementwise trigonometric sine function. - * - * - * .. code:: - * - * y = SinLayer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message SinLayerParams { - -} - -/** - * A layer that computes elementwise trigonometric cosine function. - * - * - * .. code:: - * - * y = CosLayer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message CosLayerParams { - -} - -/** - * A layer that computes elementwise trigonometric tangent function. - * - * - * .. code:: - * - * y = TanLayer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message TanLayerParams { - -} - -/** - * A layer that computes elementwise trigonometric arcsine function. - * - * - * .. code:: - * - * y = AsinLayer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message AsinLayerParams { - -} - -/** - * A layer that computes elementwise trigonometric arccosine function. - * - * - * .. code:: - * - * y = AcosLayer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message AcosLayerParams { - -} - -/** - * A layer that computes elementwise trigonometric arctangent function. - * - * - * .. code:: - * - * y = AtanLayer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message AtanLayerParams { - -} - -/** - * A layer that computes elementwise trigonometric hyperbolic sine function. - * - * - * .. code:: - * - * y = SinhLayer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message SinhLayerParams { - -} - -/** - * A layer that computes elementwise trigonometric hyperbolic cosine function. - * - * - * .. code:: - * - * y = CoshLayer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message CoshLayerParams { - -} - -/** - * A layer that computes elementwise trigonometric hyperbolic tangent function. - * - * - * .. code:: - * - * y = TanhLayer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message TanhLayerParams { - -} - -/** - * A layer that computes elementwise trigonometric hyperbolic arcsine function. - * - * - * .. code:: - * - * y = AsinhLayer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message AsinhLayerParams { - -} - -/** - * A layer that computes elementwise trigonometric hyperbolic arccosine function. - * - * - * .. code:: - * - * y = AcoshLayer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message AcoshLayerParams { - -} - -/** - * A layer that computes elementwise trigonometric hyperbolic arctangent function. - * - * - * .. code:: - * - * y = AtanhLayer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message AtanhLayerParams { - -} -/** - * A layer that raises each element in first tensor to the power of - * corresponding element in the second tensor. - * Supports conventional numpy-like broadcasting. - * - * .. code:: - * - * y = PowBroadcastableLayer(x) - * - * Requires 2 inputs and produces 1 output. - * - * Input - * - First N-Dimensional tensor - * - Second N-Dimensional tensor - * - * Output - * An N-Dimensional tensor with the broadcast shape. - * - */ -message PowBroadcastableLayerParams { - -} - -/** - * A layer that computes the exponential of all elements in the input tensor, with the base 2. - * - * - * .. code:: - * - * y = Exp2Layer(x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message Exp2LayerParams { - -} - -/** - * A layer that returns a tensor containing the indices of all non-zero - * elements of input tensor. - * It is similar in functionality to the numpy.where method with 1 input. - * - * Requires 1 input and produces 1 output. - * Output is of rank 2, of shape (N,R), - * where N is the number of non-zero elements in the input and R is the rank of the input. - * - * Output contains indices represented in the multi-index form - * - * e.g.: - * input {shape = (4,)}: - * [0 1 0 2] - * output {shape = (2,1)}: - * [1] - * [3] - * - * - * input {shape = (3, 3)}: - * [1 2 1] - * [0 2 2] - * [2 1 0] - * output {shape = (7,1)}: - * [0. 0.] - * [0. 1.] - * [0. 2.] - * [1. 1.] - * [1. 2.] - * [2. 0.] - * [2. 1.] - * - */ -message WhereNonZeroLayerParams { - -} - -/** - * A layer that copies a tensor setting everything outside a central band in - * each inner-most matrix to zero. - * - * Requires 1 input and produces 1 output. - * - * Parameters for matrix_band_part layer - * band(m, n) = (num_lower < 0 || (m-n) <= num_lower) && (num_upper < 0 || (n-m) <= num_upper). - * output[i, j, k, ..., m, n] = band(m, n) * input[i, j, k, ..., m, n] - * - * - * Output shape is same as the input shape. - * Rank of the input must be at least 2. - * For rank higher than 2, the last 2 dimensions are treated as the matrix, while the rest are treated as batch. - */ -message MatrixBandPartLayerParams { - - int64 numLower = 1; - int64 numUpper = 2; - -} - -/** - * A layer that copies a tensor setting everything outside upper triangular to zero. - * - * Requires 1 input and produces 1 output. - * - * Output shape is same as the input shape. - * Rank of the input must be at least 2. - * For rank higher than 2, the last 2 dimensions are treated as the matrix, while the rest are treated as batch. - */ -message UpperTriangularLayerParams { - - int64 k = 1; // Diagonal below which to zero elements. k = 0 (the default) is the main diagonal, k < 0 is below it and k > 0 is above - -} - -/** - * A layer that copies a tensor setting everything outside lower triangular to zero. - * - * Requires 1 input and produces 1 output. - * - * Output shape is same as the input shape. - * Rank of the input must be at least 2. - * For rank higher than 2, the last 2 dimensions are treated as the matrix, while the rest are treated as batch. - */ -message LowerTriangularLayerParams { - - int64 k = 1; // Diagonal above which to zero elements. k = 0 (the default) is the main diagonal, k < 0 is below it and k > 0 is above - -} - -/** - * - * A layer that broadcasts a tensor to a new shape. - * - * Requires 2 inputs and produces 1 output. - * - * First input is broadcast to produce the output, while the second input is only - * used to determine the shape of the output. Values of second input are not used. - * - * Output is a tensor with the same shape as the second input. - * - */ -message BroadcastToLikeLayerParams { - -} - -/** - * - * A layer that broadcasts a tensor to a new shape. - * - * Requires 1 input and produces 1 output. - * - * Output tensor is the broadcasted version of the input and has shape as specified in the - * parameter "targetShape". - */ -message BroadcastToStaticLayerParams { - - repeated uint64 targetShape = 1; - -} - -/** - * - * A layer that broadcasts a tensor to a new shape. - * - * Requires 2 inputs and produces 1 output. - * - * First input is the one that is broadcasted to produce the output. - * Second input is a rank 1 tensor specifying the shape of the output. - * Output tensor has shape as specified by the values in the 2nd input tensor. - */ -message BroadcastToDynamicLayerParams { - -} - -/** - * A layer that performs element-wise addition operation with broadcast support. - * - * Requires 2 inputs and produces 1 output. - */ -message AddBroadcastableLayerParams { - -} - -/** - * A layer that performs element-wise maximum operation with broadcast support. - * - * Requires 2 inputs and produces 1 output. - */ -message MaxBroadcastableLayerParams { - -} - -/** - * A layer that performs element-wise minimum operation with broadcast support. - * - * Requires 2 inputs and produces 1 output. - */ -message MinBroadcastableLayerParams { - -} - -/** - * A layer that performs element-wise modular operation with broadcast support. - * - * Requires 2 inputs and produces 1 output. - */ -message ModBroadcastableLayerParams { - -} - -/** - * A layer that performs element-wise floor division operation with broadcast support. - * - * Requires 2 inputs and produces 1 output. - */ -message FloorDivBroadcastableLayerParams { - -} - -/** - * A layer that performs element-wise subtract operation with broadcast support. - * - * Requires 2 inputs and produces 1 output. - */ -message SubtractBroadcastableLayerParams { - -} - -/** - * A layer that performs element-wise multiply operation with broadcast support. - * - * Requires 2 inputs and produces 1 output. - */ -message MultiplyBroadcastableLayerParams { - -} - -/** - * A layer that performs element-wise division operation with broadcast support. - * - * Requires 2 inputs and produces 1 output. - */ -message DivideBroadcastableLayerParams { - -} - -/** - * Gather layer that gathers elements from the first input, along a specified axis, - * at indices specified in the second input. - * It is similar in functionality to the numpy.take method. - * - * Requires 2 inputs and produces 1 output. - * - * Given two inputs, 'data' and 'indices', gather the slices of 'data' - * and store into output. - * e.g. - * for i in [0, length(indices) - 1] - * output[i] = data[indices[i]] (1-D case, axis=0) - * - * if axis = 0: - * for each vector index (i,...,j) - * output[i,...,j,:,..,:] = data[indices[i,...,j],:,..,:] - * - * output.rank = (data.rank - 1) + indices.rank - * - * Negative indices and negative axis are supported. - * - * e.g: - * - * data shape = (2, 3) - * indices shape = (6, 8) - * axis = 0 - * output shape = (6, 8) + (3,) = (6, 8, 3) - * - * data shape = (2, 3, 5) - * indices shape = (6, 8) - * axis = 1 - * output shape = (2,) + (6, 8) + (5,) = (2, 6, 8, 5) - * - */ -message GatherLayerParams { - - int64 axis = 1; - -} - -/* - * Scatter accumulation mode. - */ -enum ScatterMode { - - SCATTER_UPDATE = 0; - SCATTER_ADD = 1; /// add - SCATTER_SUB = 2; /// subtract - SCATTER_MUL = 3; /// multiply - SCATTER_DIV = 4; /// divide - SCATTER_MAX = 5; /// maximum - SCATTER_MIN = 6; /// minimum - -} - -/* - * A layer that scatters data into a new tensor according to indices from the input. - * This is the inverse operation of Gather. - * - * Requires 3 inputs and produces 1 output. - * - * Output is initialized with the first input. - * Then updated with the values in the third input, at indices specified by the second input. - * - * An example when axis=0: - * Given three inputs, in order, "container", "indices", "updates", where - * - * - "container" is a rank R+1 tensor of shape [D_0, D_1, ..., D_R], which - * contains D_0 number of tensors, each with shape [D_1, ..., D_R]. - * - * - "indices" is a rank 1 tensor with shape [N], where N is the number of updates. - * The values in this tensor must be in the range [0, D_0 - 1]. (negative indexing is supported) - * - * - "updates" is a rank R+1 tensor with shape [N, D_1, ..., D_R], which represents - * a total number of N tensors, each of shape [D_1, ..., D_R]. - * - * The effect of this operation is as follows: - * - * output = container; - * For each i in 0, ..., N - 1 - * output[indices[i], :, ..., :] = updates[i, :, ..., :] // if mode == "SCATTER_UPDATE" - * - * or - * For each i in 0, ..., N - 1 - * output[indices[i], :, ..., :] += updates[i, :, ..., :] // if mode == "SCATTER_ADD" - * - * etc - * - * When "indices" is a tensor of rank greater than 1, the equation becomes (for axis=0): - * For each vector index (i,...,j) - * output[indices[i,...,j],...] -= updates[i,...,j,...] // if mode == "SCATTER_SUB" - * - * - * The output has the same shape as the first input. - * "indices" input must have rank less than or equal to the "updates" input and its shape - * must be a subset of the the shape of the "updates" input. - * - * e.g: - * - * container shape = (4, 3) - * indices shape = (5, 2, 3) - * updates shape = (4, 5, 2, 3) - * axis = 1 - * output shape = (4, 3) - * - * container shape = (4, 4, 3) - * indices shape = (6,) - * updates shape = (4, 6, 3) - * axis = -2 - * output shape = (4, 4, 3) - * - * container shape = (5,) - * indices shape = (5, 7, 5, 6) - * updates shape = (5, 7, 5, 6) - * axis = -1 - * output shape = (5,) - */ - -message ScatterLayerParams { - - int64 axis = 1; - ScatterMode mode = 2; /// mode of accumulation. - -} - -/** - * A layer that gathers elements from the first input, 'params', at the multi-indices specified - * by the second input, 'indices'. - * - * Requires 2 inputs and produces 1 output. - * - * 'params' = input[0], 'indices' = input[1] - * - * 'indices' is a rank K+1 tensor of shape [I_0, I_1, .., I_(K-1), I_K] which is viewed as a collection of - * indices of (I_0 * I_1 * ... * I_(K-1)) points in the I_K dimensional space. For instance, the multi-index of the first point - * is indices[0,0,...,0,:]. - * - * Here is how the output is constructed: - * - * for i = 0,1,...,(I_0-1) - * ... - * for j = 0,1,....,(I_(K-1)-1) - * output[i,....,j,:,:,..,:] = params[indices[i,...,j,:], :,:,..,:] - * - * Hence, output shape is [I_0, I_1,...,I(K-1)] + params.shape[I_K:] - * - * output.rank = indices.rank - 1 + params.rank - indices.shape[-1] - * - * e.g: - * - * input[0] shape = (4, 2, 3, 4) - * input[1] shape = (6, 2) - * output shape = (6,) + (3, 4) = (6, 3, 4) - * - * input[0] shape = (3, 3, 3, 4, 7) - * input[1] shape = (3, 5) - * output shape = (3,) + () = (3,) - * - * input[0] shape = (5, 3, 2, 5) - * input[1] shape = (2, 7, 3, 2) - * output shape = (2, 7, 3) + (2, 5) = (2, 7, 3, 2, 5) - * - */ -message GatherNDLayerParams { - -} - -/* - * A layer that scatters data into a new tensor according to multi-indices from the input. - * This is the inverse operation of GatherND. - * - * Requires 3 inputs and produces 1 output. - * 3 inputs, in order are denoted as "container", "indices", "updates". - * - * 'indices' is a rank K+1 tensor of shape [I_0, I_1, .., I_(K-1), I_K] which is viewed as a collection of - * indices of (I_0 * I_1 * ... * I_(K-1)) points in the I_K dimensional space. For instance, the multi-index of the first point - * is indices[0,0,...,0,:]. - * - * container.rank >= I_K - * updates.rank = K + (container.rank - I_K) - * shape of 'updates' = [I_0, I_1,...,I(K-1)] + container.shape[I_K:] - * - * output = container - * For each vector index (i,...,j) s.t. 0<=i shape: (3,) - * reps = N/A [Ignored] - * output shape = (2, 8, 12) - * - */ -message TileLayerParams { - - repeated uint64 reps = 1; - -} - -/** - * A layer that returns the shape of an input tensor. - * - * Requires 1 input and produces 1 output. - * - * Input: a tensor. - * Output: a vector of length R, where R is the rank of the input tensor - * Output is always a rank 1 tensor. - */ -message GetShapeLayerParams { - -} - -/** - * A layer that computes the Gauss error function, - * which is defined as: - * - * .. math:: - * f(x) = \dfrac{1}{\sqrt{\pi}}\int_{-x}^{x}{e^{-t^2}dt} - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - */ -message ErfLayerParams { - -} - -/** - * A layer that evaluates the Gaussian Error Linear Unit (GELU) activation. - * Following equations are used to compute the activation based on the value of the "mode" parameter: - * - * mode == 'EXACT': - * .. math:: - * f(x) = 0.5x\left ( 1+\rm{erf}\left ( \frac{x}{\sqrt{2}} \right ) \right ) - * - * mode == 'TANH_APPROXIMATION': - * .. math:: - * f(x) = 0.5x\left ( 1+\rm{tanh}\left ( \sqrt{2/\pi}\left ( x + 0.044715x^3 \right ) \right ) \right ) - * - * mode == 'SIGMOID_APPROXIMATION': - * .. math:: - * f(x) = x*\rm{sigmoid}(1.702x) - * - * Requires 1 input and produces 1 output. - * Output shape is same as the input. - * - */ -message GeluLayerParams { - - enum GeluMode { - - EXACT = 0; - TANH_APPROXIMATION = 1; - SIGMOID_APPROXIMATION = 2; - - } - - GeluMode mode = 1; /// mode of GELU operation. - -} - -/** - * RangeStatic layer that returns a tensor that contains evenly spaced values. - * It is similar in functionality to the numpy.arange method. - * - * Requires no input and produces 1 output. - * Output is a rank 1 tensor. - */ -message RangeStaticLayerParams { - - float endValue = 1; - float startValue = 2; - float stepSizeValue = 3; - -} - -/** - * A layer that returns a tensor that contains evenly spaced values. - * Its functionality is similar to the numpy.arange method. - * - * Requires at least 1 input, up to a maximum of 3 inputs. - * Produces 1 output, which is a rank 1 tensor. - * - * Each input must be a scalar, or rank 1 and shape (1,). - * - * The first input represents the "endValue". - * The second input, if present, corresponds to "startValue". In this case the value of the "startValue" parameter is ignored. - * The third input, if present, corresponds to "stepSizeValue". In this case the value of the "stepSizeValue" parameter is ignored. - * - */ -message RangeDynamicLayerParams { - - float startValue = 2; - float stepSizeValue = 3; - -} - -/** - * A layer that returns a tensor containing all windows of size ``windowSize`` - * separated by ``step`` along the dimension ``axis``. - * - * .. code:: - * - * y = SlidingWindows(x) - * - * Requires 1 input and produces 1 output. - * - * Input - * An N-Dimensional tensor. - * - * Output - * An (N+1)-Dimensional tensor. - * - * This operation behaves as following: - * - if axis = 0 & input is rank 1 (L,). Output shape will be (M, W). - * - if axis = 1 & input is rank 3 (B1, L, C1). Output shape will be (B1, M, W, C1) - * - if axis = 2 & input is rank 5 (B1, B2, L, C1, C2) --> (B1 * B2, L, C1 * C2) --> (B1 * B2, M, W, C1 * C2). Output shape will be (B1, B2, M, W, C1, C2) - * - etc. - * where - * - L, C, B refer to input length, feature dimension length & batch size respectively - * - W is the window size. - * - M is the number of windows/slices calculated as M = (L - W) / step + 1 - */ -message SlidingWindowsLayerParams { - - int64 axis = 1; - uint64 windowSize = 2; - uint64 step = 3; - -} - -/** - * A layer that applies layer normalization over the input tensor. - * - * Requires 1 input and produces 1 output. - * - * output = gamma * (input - computed_mean) / (sqrt(computed_variance + eps)) + beta - * - * Parameters - * normalizedShape: subset of the input shape, along with layer norm is performed, rest of the input shape is treated as the batch dimension. The mean and variance are computed for the input, over the last few dimensions as specified by the normalizedShape parameter. - * gamma: must have shape = "normalizedShape" - * beta: must have shape = "normalizedShape" - * eps: small constant to avoid division by 0 - * - * Output shape is same as the input. - * - * e.g.: - * input shape = (10,5) - * normalized shape = (5,) or (10,5) - * - * input shape = (10,5,6,7) - * normalized shape = (7,) or (6,7) or (5,6,7) or (10,5,6,7) - */ -message LayerNormalizationLayerParams { - - repeated int64 normalizedShape = 1; - float eps = 2; - WeightParams gamma = 3; - WeightParams beta = 4; - -} - -/** - * Non maximum suppression (NMS) layer. - * Applies the non maximum suppression algorithm to input bounding box coordinates. - * The effect of this layer is similar to the functionality of the "NonMaximumSuppression" - * model type (for details please see NonMaximumSuppression.proto) with a couple of differences. - * One, this is a layer in a neural network model, whereas that is a different model type. Second, - * this layer supports a batch of bounding boxes. - * - * The NMS layer requires at least 2 inputs, and up to a maximum of 5 inputs. It produces 4 outputs. - * Following is the description of inputs and outputs: - * - * input 1, shape (B,N,4): coordinates of N boxes, for a batch size B. - * input 2, shape (B,N,C): class scores for each box. C can be 1 when there is only 1 score per box, i.e., no class specific score. - * - * input 3, optional, shape (1,): IoU threshold. When present, it overwrites the value provided in layer parameter "iouThreshold". - * input 4, optional, shape (1,): Score threshold. When present, it overwrites the value provided in layer parameter "scoreThreshold". - * input 5, optional, shape (1,): Maximum number of boxes. When present, it overwrites the value provided in layer parameter "maxBoxes". - * - * output 1, shape (B,maxBoxes,4): box coordinates, corresponding to the surviving boxes. - * output 2, shape (B,maxBoxes,C): box scores, corresponding to the surviving boxes. - * output 3, shape (B,maxBoxes): indices of the surviving boxes. Hence it will have values in the range [0,N-1], except for padding. - * output 4, shape (B,): number of boxes selected after the NMS algorithm, for each batch. - * - * When surviving boxes are less than "maxBoxes", the first 3 outputs are padded. - * For the first two outputs, the padding is done using values 0, whereas for the third output the - * padding value used is -1, since the output values represent indices. - * - * If no box survives, that is, all the scores are below the "scoreThreshold", - * then for that batch, number of boxes (value of the fourth output) will be 1. The first 3 outputs will - * correspond to the box with the highest score. This is to avoid generating an "empty" output. - * - * The four values that describe the box dimensions are (in order): - * - * - x (center location of the box along the horizontal axis) - * - y (center location of the box along the vertical axis) - * - width (size of box along the horizontal axis) - * - height (size of box on along the vertical axis) - * - * In each batch, - * the N scores for N boxes, used for suppression, are generated by taking the max of the matrix (N,C) - * along the columns. - * If "perClassSuppression" flag is false, suppression happens across all classes. - * If "perClassSuppression" flag is true, each box is assigned to the class with the highest - * score and then the suppression happens separately for boxes within the same class. - * - * Note that the 4th output can be used to dynamically slice the first 3 outputs, in case - * the padded outputs are not required. - * - */ -message NonMaximumSuppressionLayerParams { - /** - * The intersection over union (IoU) threshold over which boxes are suppressed. - */ - float iouThreshold = 1; - - /** - * Before IoU suppression is performed, boxes with class scores below this threshold are rejected. - */ - float scoreThreshold = 2; - - /** - * The maximum number of boxes to be given out as output. - * If the number of surviving boxes are less, output is padded up to this number. - */ - uint64 maxBoxes = 3; - - /** - * If true, suppression is performed independently within boxes of each class. - */ - bool perClassSuppression = 4; -} - -/** - * A layer that performs element-wise clamped ReLU operation. - * - * Requires 1 input and produces 1 output. - * - * This function has the following formula: - * - * .. math:: - * f(x) = \begin{cases} - * \text{min}(\text{beta},x) \;\; \text{if} \;\; x \geq 0\\ - * \text{min}(\text{beta} ,\text{alpha}\cdot x) \;\; \text{if} \;\; x<0 - * \end{cases} - * - * Output shape is same as the input. - * - * Available (iOS >= 14, macOS >= 11.0, watchOS >= 7) - */ -message ClampedReLULayerParams { - - float alpha = 1; - float beta = 2; - -} - -/** -* A layer that returns the indices that would sort the input tensor, along a specified axis. -* -* Requires 1 input and produces 1 output. -* -* Output has the same rank and shape as the input. -* -* Value of "axis" must be positive and less than the rank of the input. -* -* e.g.: -* -* input shape = (5,) -* axis = 0 -* input values = [3.1, 5.4, 32.9, 3.2, 77.0] -* output shape = (5,) -* output values = [0, 3, 1, 2, 4], descending = False -* output values = [4, 2, 1, 3, 0], descending = True -* -* input shape = (2,3) -* axis = 1 -* input values = [[3, 5, 32], [3, 77, 6]] -* output shape = (2,3) -* output values = [[0, 1, 2], [0, 2, 1]], descending = False -* output values = [[2, 1, 0], [1, 2, 0]], descending = True -* -*/ -message ArgSortLayerParams { - - int64 axis = 1; /// must be between [0, input_rank - 1] - bool descending = 2; - -} - -/** - * A layer that does slice operation by providing size to be extracted - * from the given input tensor. - * - * Requires 2 inputs and produces 1 output. - * Rank of the output is same as the rank of the first input. - * - * The 1st input represents the tensor to be sliced. - * The 2nd input represents the beginning index to be sliced from. - * - * Example: - * Input 1: x (x.shape = (2, 3, 4)) - * Input 2: begin - * size: 2 - * axis: 1 - * - * Output: x[:, begin:begin+2, :] - * - */ -message SliceBySizeLayerParams { - - int64 size = 2; - int64 axis = 3; - -} - - -/// Neural Network Specializations -/// ------------------------------ - -/** - * A neural network specialized as a classifier. - */ -message NeuralNetworkClassifier { - - repeated NeuralNetworkLayer layers = 1; - repeated NeuralNetworkPreprocessing preprocessing = 2; - - // use this enum value to determine the input tensor shapes to the neural network, for multiarray inputs - NeuralNetworkMultiArrayShapeMapping arrayInputShapeMapping = 5; - - // use this enum value to determine the input tensor shapes to the neural network, for image inputs - NeuralNetworkImageShapeMapping imageInputShapeMapping = 6; - - NetworkUpdateParameters updateParams = 10; - - // The set of labels for every possible class. - oneof ClassLabels { - StringVector stringClassLabels = 100; - Int64Vector int64ClassLabels = 101; - } - - // The name of the output blob containing the probability of each class. - // In other words, the score vector. Must be a 1-D tensor with the same - // number and order of elements as ClassLabels. - string labelProbabilityLayerName = 200; -} - - -/** - * A layer that computes the one hot representation of the input. - * - * Requires 1 or 2 inputs and produces 1 output. - * Rank of the output is one more than the first input. - * If the second input is present, it is used to determine the value of "oneHotVectorSize" and the parameter "oneHotVectorSize" is ignored. - * - * Input values correspond to indices and should typically be in the range [0,"oneHotVectorSize" -1]. If it is outside this range, a vector of all "offValue" will be chosen. - * - * Typically one hot vectors contain 0s everywhere, except 1 at the index that the input corresponds to. - * However, instead of 0, any float value could be generated by using the "offValue" parameter. - * Similarly, instead of 1, any other value can be used by employing the "onValue" parameter. - * - * e.g.: - * input shape: (10,), "oneHotVectorSize" : 32, axis=-1, then output shape will be (10,32) - * input shape: (10,23), "oneHotVectorSize" : 32, axis=1, then output shape will be (10,32,23) - * input shape: (10,), "oneHotVectorSize" : 32, axis=0, then output shape will be (32,10) - * - * input shape: (2,), "oneHotVectorSize" : 4, axis=-1, then output shape will be (2,4) - * say input values = [2, 0], and "onValue" = 5, and "offValue" = -1, then output will be: - * [-1, -1, 5, -1 - * 5, -1, -1, -1] - * - * say input values = [2, -1], and "onValue" = 5, and "offValue" = -1, then output will be: - * [-1, -1, 5, -1 - * -1, -1, -1, -1] - * - * Available (iOS >= 14, macOS >= 11.0, watchOS >= 7) - */ - -message OneHotLayerParams { - - uint64 oneHotVectorSize = 1; /// size of the one hot vector - int64 axis = 2; /// negative indexing is supported. It refers to the axis in the output tensor. - float onValue = 3; - float offValue = 4; -} - - -/** - * A layer that computes the cumsum values of the input along a given axis. - * - * Requires 1 or 2 inputs and produces 1 output. - * - * Output shape and rank is same as the first input. - * If the second input is present, it is used to determine the value of "axis" and the parameter "axis" is ignored. - * - * e.g.: - * Input shape = (3,), values it has: [4, 6, 7] - * - * Then output values will be: - * - * if "excludeFinalSum" = False and "reverse" = False: - * output values : [4, 10, 17] - * - * if "excludeFinalSum" = True and "reverse" = False: - * output values : [0, 4, 10] - * - * if "excludeFinalSum" = False and "reverse" = True: - * output values : [17, 13, 7] - * - * if "excludeFinalSum" = True and "reverse" = True: - * output values : [13, 7, 0] - * - * - * Available (iOS >= 14, macOS >= 11.0, watchOS >= 7) - */ - - -message CumSumLayerParams { - - int64 axis = 1; /// negative indexing is supported - - /// if true, the first element of the output is 0, and the last element contains the sum of the input up to the penultimate value - /// if false, the first element of the output is same as the input and the last element is the sum of all the input values - /// (this behavior is reversed when "reverse" flag is True) - bool excludeFinalSum = 2; - - bool reverse = 3; /// if true, cumsum is performed in the opposite direction -} - - -/** - * A neural network specialized as a regressor. - */ -message NeuralNetworkRegressor { - - repeated NeuralNetworkLayer layers = 1; - repeated NeuralNetworkPreprocessing preprocessing = 2; - - // use this enum value to determine the input tensor shapes to the neural network, for multiarray inputs - NeuralNetworkMultiArrayShapeMapping arrayInputShapeMapping = 5; - - // use this enum value to determine the input tensor shapes to the neural network, for image inputs - NeuralNetworkImageShapeMapping imageInputShapeMapping = 6; - - NetworkUpdateParameters updateParams = 10; - -} - -/// --------------------------------------------------------- -/// On-device Training related messages -/// --------------------------------------------------------- - -/** - * Details on how the network will be updated - */ -message NetworkUpdateParameters { - - repeated LossLayer lossLayers = 1; - Optimizer optimizer = 2; - Int64Parameter epochs = 3; - - /** - * Describes whether to shuffle the batch of data between epochs. - */ - BoolParameter shuffle = 10; - - /** - * The seed to be used in an associated random number generator. - */ - Int64Parameter seed = 20; -} - -/** - * Loss layer - categorical cross entropy and mean squared error are the only supported loss functions currently - */ -message LossLayer { - - string name = 1; - oneof LossLayerType { - - CategoricalCrossEntropyLossLayer categoricalCrossEntropyLossLayer = 10; - MeanSquaredErrorLossLayer meanSquaredErrorLossLayer = 11; - - } - -} - -/** - * Categorical cross entropy loss layer - * Categorical cross entropy is used for single label categorization (only one category is applicable for each data point). - * - * The input is a vector of length N representing the distribution over N categories. It must be the output of a softmax. - * - * The target is a single value representing the true category or class label. If the target is the predictedFeatureName of a neural network classifier it will be inverse mapped to the corresponding categorical index for you. - * - * math: - * Loss_{CCE}(input, target) = -\sum_{i=1}^{N} (target == i) log( input[i] ) = - log (input[target]) - */ -message CategoricalCrossEntropyLossLayer { - - string input = 1; - string target = 2; - -} - -/** - * Mean squared error loss layer, - * specifying input and target - */ -message MeanSquaredErrorLossLayer { - - string input = 1; - string target = 2; - -} - -/** - * Optimizer - stochastic gradient descent and adam are the only supported optimizers currently - */ -message Optimizer { - - oneof OptimizerType { - - SGDOptimizer sgdOptimizer = 10; - AdamOptimizer adamOptimizer = 11; - - } - -} - -/** - * Stochastic gradient descent optimizer, - * specifying configurable learning rate, mini batch size, and momentum - */ -message SGDOptimizer { - - DoubleParameter learningRate = 1; - Int64Parameter miniBatchSize = 2; - DoubleParameter momentum = 3; - -} - -/** - * Adam optimizer, - * specifying configurable learning rate, mini batch size, betas, and eps - */ -message AdamOptimizer { - - DoubleParameter learningRate = 1; - Int64Parameter miniBatchSize = 2; - DoubleParameter beta1 = 3; - DoubleParameter beta2 = 4; - DoubleParameter eps = 5; - -} diff --git a/third_party/proto/coreml/Parameters.proto b/third_party/proto/coreml/Parameters.proto deleted file mode 100644 index ed1ebe52..00000000 --- a/third_party/proto/coreml/Parameters.proto +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2017, Apple Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-3-clause license that can be -// found in LICENSE.txt or at https://opensource.org/licenses/BSD-3-Clause - -syntax = "proto3"; -option optimize_for = LITE_RUNTIME; - -import public "DataStructures.proto"; - -package CoreML.Specification; - -/** - * Int64 parameter, - * consisting of a default int64 value, and allowed range or set of values - * value is unbounded if AllowedValues is not set. - */ -message Int64Parameter { - int64 defaultValue = 1; - oneof AllowedValues { - Int64Range range = 10; - Int64Set set = 11; - } -} - -/** - * Double parameter, - * consisting of a default double value, and allowed range of values - * value is unbounded if AllowedValues is not set. - */ -message DoubleParameter { - double defaultValue = 1; - oneof AllowedValues { - DoubleRange range = 10; - } -} - -/** - * String parameter, - * A default string value must be provided - */ -message StringParameter { - string defaultValue = 1; -} - -/** - * String parameter, - * A default bool value must be provided - */ -message BoolParameter { - bool defaultValue = 1; -} diff --git a/third_party/proto/onnx/LICENSE b/third_party/proto/onnx/LICENSE deleted file mode 100644 index 7a4a3ea2..00000000 --- a/third_party/proto/onnx/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/third_party/proto/onnx/onnx.proto b/third_party/proto/onnx/onnx.proto deleted file mode 100644 index 6f296326..00000000 --- a/third_party/proto/onnx/onnx.proto +++ /dev/null @@ -1,569 +0,0 @@ -// -// WARNING: This file is automatically generated! Please edit onnx.in.proto. -// - - -// Copyright (c) ONNX Project Contributors. -// Licensed under the MIT license. - -syntax = "proto2"; - -package onnx; - -// Overview -// -// ONNX is an open specification that is comprised of the following components: -// -// 1) A definition of an extensible computation graph model. -// 2) Definitions of standard data types. -// 3) Definitions of built-in operators. -// -// This document describes the syntax of models and their computation graphs, -// as well as the standard data types. Together, they are referred to as the ONNX -// Intermediate Representation, or 'IR' for short. -// -// The normative semantic specification of the ONNX IR is found in docs/IR.md. -// Definitions of the built-in neural network operators may be found in docs/Operators.md. - -// Notes -// -// Release -// -// We are still in the very early stage of defining ONNX. The current -// version of ONNX is a starting point. While we are actively working -// towards a complete spec, we would like to get the community involved -// by sharing our working version of ONNX. -// -// Protobuf compatibility -// -// To simplify framework compatibility, ONNX is defined using the subset of protobuf -// that is compatible with both protobuf v2 and v3. This means that we do not use any -// protobuf features that are only available in one of the two versions. -// -// Here are the most notable contortions we have to carry out to work around -// these limitations: -// -// - No 'map' (added protobuf 3.0). We instead represent mappings as lists -// of key-value pairs, where order does not matter and duplicates -// are not allowed. - - -// Versioning -// -// ONNX versioning is specified in docs/IR.md and elaborated on in docs/Versioning.md -// -// To be compatible with both proto2 and proto3, we will use a version number -// that is not defined by the default value but an explicit enum number. -enum Version { - // proto3 requires the first enum value to be zero. - // We add this just to appease the compiler. - _START_VERSION = 0; - // The version field is always serialized and we will use it to store the - // version that the graph is generated from. This helps us set up version - // control. - // For the IR, we are using simple numbers starting with with 0x00000001, - // which was the version we published on Oct 10, 2017. - IR_VERSION_2017_10_10 = 0x0000000000000001; - - // IR_VERSION 2 published on Oct 30, 2017 - // - Added type discriminator to AttributeProto to support proto3 users - IR_VERSION_2017_10_30 = 0x0000000000000002; - - // IR VERSION 3 published on Nov 3, 2017 - // - For operator versioning: - // - Added new message OperatorSetIdProto - // - Added opset_import in ModelProto - // - For vendor extensions, added domain in NodeProto - IR_VERSION_2017_11_3 = 0x0000000000000003; - - // IR VERSION 4 published on Jan 22, 2019 - // - Relax constraint that initializers should be a subset of graph inputs - // - Add type BFLOAT16 - IR_VERSION_2019_1_22 = 0x0000000000000004; - - // IR VERSION 5 published on March 18, 2019 - // - Add message TensorAnnotation. - // - Add quantization annotation in GraphProto to map tensor with its scale and zero point quantization parameters. - IR_VERSION_2019_3_18 = 0x0000000000000005; - - // IR VERSION 6 published on Sep 19, 2019 - // - Add support for sparse tensor constants stored in model. - // - Add message SparseTensorProto - // - Add sparse initializers - IR_VERSION = 0x0000000000000006; -} - -// Attributes -// -// A named attribute containing either singular float, integer, string, graph, -// and tensor values, or repeated float, integer, string, graph, and tensor values. -// An AttributeProto MUST contain the name field, and *only one* of the -// following content fields, effectively enforcing a C/C++ union equivalent. -message AttributeProto { - - // Note: this enum is structurally identical to the OpSchema::AttrType - // enum defined in schema.h. If you rev one, you likely need to rev the other. - enum AttributeType { - UNDEFINED = 0; - FLOAT = 1; - INT = 2; - STRING = 3; - TENSOR = 4; - GRAPH = 5; - SPARSE_TENSOR = 11; - - FLOATS = 6; - INTS = 7; - STRINGS = 8; - TENSORS = 9; - GRAPHS = 10; - SPARSE_TENSORS = 12; - } - - // The name field MUST be present for this version of the IR. - optional string name = 1; // namespace Attribute - - // if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function. - // In this case, this AttributeProto does not contain data, and it's a reference of attribute - // in parent scope. - // NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph. - optional string ref_attr_name = 21; - - // A human-readable documentation for this attribute. Markdown is allowed. - optional string doc_string = 13; - - // The type field MUST be present for this version of the IR. - // For 0.0.1 versions of the IR, this field was not defined, and - // implementations needed to use has_field hueristics to determine - // which value field was in use. For IR_VERSION 0.0.2 or later, this - // field MUST be set and match the f|i|s|t|... field in use. This - // change was made to accomodate proto3 implementations. - optional AttributeType type = 20; // discriminator that indicates which field below is in use - - // Exactly ONE of the following fields must be present for this version of the IR - optional float f = 2; // float - optional int64 i = 3; // int - optional bytes s = 4; // UTF-8 string - optional TensorProto t = 5; // tensor value - optional GraphProto g = 6; // graph - optional SparseTensorProto sparse_tensor = 22; // sparse tensor value - // Do not use field below, it's deprecated. - // optional ValueProto v = 12; // value - subsumes everything but graph - - repeated float floats = 7; // list of floats - repeated int64 ints = 8; // list of ints - repeated bytes strings = 9; // list of UTF-8 strings - repeated TensorProto tensors = 10; // list of tensors - repeated GraphProto graphs = 11; // list of graph - repeated SparseTensorProto sparse_tensors = 23; // list of sparse tensors -} - -// Defines information on value, including the name, the type, and -// the shape of the value. -message ValueInfoProto { - // This field MUST be present in this version of the IR. - optional string name = 1; // namespace Value - // This field MUST be present in this version of the IR for - // inputs and outputs of the top-level graph. - optional TypeProto type = 2; - // A human-readable documentation for this value. Markdown is allowed. - optional string doc_string = 3; -} - -// Nodes -// -// Computation graphs are made up of a DAG of nodes, which represent what is -// commonly called a "layer" or "pipeline stage" in machine learning frameworks. -// -// For example, it can be a node of type "Conv" that takes in an image, a filter -// tensor and a bias tensor, and produces the convolved output. -message NodeProto { - repeated string input = 1; // namespace Value - repeated string output = 2; // namespace Value - - // An optional identifier for this node in a graph. - // This field MAY be absent in ths version of the IR. - optional string name = 3; // namespace Node - - // The symbolic identifier of the Operator to execute. - optional string op_type = 4; // namespace Operator - // The domain of the OperatorSet that specifies the operator named by op_type. - optional string domain = 7; // namespace Domain - - // Additional named attributes. - repeated AttributeProto attribute = 5; - - // A human-readable documentation for this node. Markdown is allowed. - optional string doc_string = 6; -} - -// Models -// -// ModelProto is a top-level file/container format for bundling a ML model and -// associating its computation graph with metadata. -// -// The semantics of the model are described by the associated GraphProto. -message ModelProto { - // The version of the IR this model targets. See Version enum above. - // This field MUST be present. - optional int64 ir_version = 1; - - // The OperatorSets this model relies on. - // All ModelProtos MUST have at least one entry that - // specifies which version of the ONNX OperatorSet is - // being imported. - // - // All nodes in the ModelProto's graph will bind against the operator - // with the same-domain/same-op_type operator with the HIGHEST version - // in the referenced operator sets. - repeated OperatorSetIdProto opset_import = 8; - - // The name of the framework or tool used to generate this model. - // This field SHOULD be present to indicate which implementation/tool/framework - // emitted the model. - optional string producer_name = 2; - - // The version of the framework or tool used to generate this model. - // This field SHOULD be present to indicate which implementation/tool/framework - // emitted the model. - optional string producer_version = 3; - - // Domain name of the model. - // We use reverse domain names as name space indicators. For example: - // `com.facebook.fair` or `com.microsoft.cognitiveservices` - // - // Together with `model_version` and GraphProto.name, this forms the unique identity of - // the graph. - optional string domain = 4; - - // The version of the graph encoded. See Version enum below. - optional int64 model_version = 5; - - // A human-readable documentation for this model. Markdown is allowed. - optional string doc_string = 6; - - // The parameterized graph that is evaluated to execute the model. - optional GraphProto graph = 7; - - // Named metadata values; keys should be distinct. - repeated StringStringEntryProto metadata_props = 14; -}; - -// StringStringEntryProto follows the pattern for cross-proto-version maps. -// See https://developers.google.com/protocol-buffers/docs/proto3#maps -message StringStringEntryProto { - optional string key = 1; - optional string value= 2; -}; - -message TensorAnnotation { - optional string tensor_name = 1; - // pairs to annotate tensor specified by above. - // The keys used in the mapping below must be pre-defined in ONNX spec. - // For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as - // quantization parameter keys. - repeated StringStringEntryProto quant_parameter_tensor_names = 2; -} - - - -// Graphs -// -// A graph defines the computational logic of a model and is comprised of a parameterized -// list of nodes that form a directed acyclic graph based on their inputs and outputs. -// This is the equivalent of the "network" or "graph" in many deep learning -// frameworks. -message GraphProto { - // The nodes in the graph, sorted topologically. - repeated NodeProto node = 1; - - // The name of the graph. - optional string name = 2; // namespace Graph - - // A list of named tensor values, used to specify constant inputs of the graph. - // Each TensorProto entry must have a distinct name (within the list) that - // MAY also appear in the input list. - repeated TensorProto initializer = 5; - - // Initializers (see above) stored in sparse format. - repeated SparseTensorProto sparse_initializer = 15; - - // A human-readable documentation for this graph. Markdown is allowed. - optional string doc_string = 10; - - // The inputs and outputs of the graph. - repeated ValueInfoProto input = 11; - repeated ValueInfoProto output = 12; - - // Information for the values in the graph. The ValueInfoProto.name's - // must be distinct. It is optional for a value to appear in value_info list. - repeated ValueInfoProto value_info = 13; - - // This field carries information to indicate the mapping among a tensor and its - // quantization parameter tensors. For example: - // For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated, - // which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model. - repeated TensorAnnotation quantization_annotation = 14; - - // DO NOT USE the following fields, they were deprecated from earlier versions. - // repeated string input = 3; - // repeated string output = 4; - // optional int64 ir_version = 6; - // optional int64 producer_version = 7; - // optional string producer_tag = 8; - // optional string domain = 9; -} - -// Tensors -// -// A serialized tensor value. -message TensorProto { - enum DataType { - UNDEFINED = 0; - // Basic types. - FLOAT = 1; // float - UINT8 = 2; // uint8_t - INT8 = 3; // int8_t - UINT16 = 4; // uint16_t - INT16 = 5; // int16_t - INT32 = 6; // int32_t - INT64 = 7; // int64_t - STRING = 8; // string - BOOL = 9; // bool - - // IEEE754 half-precision floating-point format (16 bits wide). - // This format has 1 sign bit, 5 exponent bits, and 10 mantissa bits. - FLOAT16 = 10; - - DOUBLE = 11; - UINT32 = 12; - UINT64 = 13; - COMPLEX64 = 14; // complex with float32 real and imaginary components - COMPLEX128 = 15; // complex with float64 real and imaginary components - - // Non-IEEE floating-point format based on IEEE754 single-precision - // floating-point number truncated to 16 bits. - // This format has 1 sign bit, 8 exponent bits, and 7 mantissa bits. - BFLOAT16 = 16; - - // Future extensions go here. - } - - // The shape of the tensor. - repeated int64 dims = 1; - - // The data type of the tensor. - // This field MUST have a valid TensorProto.DataType value - optional int32 data_type = 2; - - // For very large tensors, we may want to store them in chunks, in which - // case the following fields will specify the segment that is stored in - // the current TensorProto. - message Segment { - optional int64 begin = 1; - optional int64 end = 2; - } - optional Segment segment = 3; - - // Tensor content must be organized in row-major order. - // - // Depending on the data_type field, exactly one of the fields below with - // name ending in _data is used to store the elements of the tensor. - - // For float and complex64 values - // Complex64 tensors are encoded as a single array of floats, - // with the real components appearing in odd numbered positions, - // and the corresponding imaginary component apparing in the - // subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i] - // is encoded as [1.0, 2.0 ,3.0 ,4.0] - // When this field is present, the data_type field MUST be FLOAT or COMPLEX64. - repeated float float_data = 4 [packed = true]; - - // For int32, uint8, int8, uint16, int16, bool, and float16 values - // float16 values must be bit-wise converted to an uint16_t prior - // to writing to the buffer. - // When this field is present, the data_type field MUST be - // INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16 - repeated int32 int32_data = 5 [packed = true]; - - // For strings. - // Each element of string_data is a UTF-8 encoded Unicode - // string. No trailing null, no leading BOM. The protobuf "string" - // scalar type is not used to match ML community conventions. - // When this field is present, the data_type field MUST be STRING - repeated bytes string_data = 6; - - // For int64. - // When this field is present, the data_type field MUST be INT64 - repeated int64 int64_data = 7 [packed = true]; - - // Optionally, a name for the tensor. - optional string name = 8; // namespace Value - - // A human-readable documentation for this tensor. Markdown is allowed. - optional string doc_string = 12; - - // Serializations can either use one of the fields above, or use this - // raw bytes field. The only exception is the string case, where one is - // required to store the content in the repeated bytes string_data field. - // - // When this raw_data field is used to store tensor value, elements MUST - // be stored in as fixed-width, little-endian order. - // Floating-point data types MUST be stored in IEEE 754 format. - // Complex64 elements must be written as two consecutive FLOAT values, real component first. - // Complex128 elements must be written as two consecutive DOUBLE values, real component first. - // Boolean type MUST be written one byte per tensor element (00000001 for true, 00000000 for false). - // - // Note: the advantage of specific field rather than the raw_data field is - // that in some cases (e.g. int data), protobuf does a better packing via - // variable length storage, and may lead to smaller binary footprint. - // When this field is present, the data_type field MUST NOT be STRING or UNDEFINED - optional bytes raw_data = 9; - - // Data can be stored inside the protobuf file using type-specific fields or raw_data. - // Alternatively, raw bytes data can be stored in an external file, using the external_data field. - // external_data stores key-value pairs describing data location. Recognized keys are: - // - "location" (required) - POSIX filesystem path relative to the directory where the ONNX - // protobuf model was stored - // - "offset" (optional) - position of byte at which stored data begins. Integer stored as string. - // Offset values SHOULD be multiples 4096 (page size) to enable mmap support. - // - "length" (optional) - number of bytes containing data. Integer stored as string. - // - "checksum" (optional) - SHA1 digest of file specified in under 'location' key. - repeated StringStringEntryProto external_data = 13; - - // Location of the data for this tensor. MUST be one of: - // - DEFAULT - data stored inside the protobuf message. Data is stored in raw_data (if set) otherwise in type-specified field. - // - EXTERNAL - data stored in an external location as described by external_data field. - enum DataLocation { - DEFAULT = 0; - EXTERNAL = 1; - } - - // If value not set, data is stored in raw_data (if set) otherwise in type-specified field. - optional DataLocation data_location = 14; - - // For double - // Complex128 tensors are encoded as a single array of doubles, - // with the real components appearing in odd numbered positions, - // and the corresponding imaginary component apparing in the - // subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i] - // is encoded as [1.0, 2.0 ,3.0 ,4.0] - // When this field is present, the data_type field MUST be DOUBLE or COMPLEX128 - repeated double double_data = 10 [packed = true]; - - // For uint64 and uint32 values - // When this field is present, the data_type field MUST be - // UINT32 or UINT64 - repeated uint64 uint64_data = 11 [packed = true]; -} - -// A serialized sparse-tensor value -message SparseTensorProto { - // The sequence of non-default values are encoded as a tensor of shape [NNZ]. - // The default-value is zero for numeric tensors, and empty-string for string tensors. - optional TensorProto values = 1; - - // The indices of the non-default values, which may be stored in one of two formats. - // (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value - // corresponding to the j-th index of the i-th value (in the values tensor). - // (b) Indices can be a tensor of shape [NNZ], in which case the i-th value - // must be the linearized-index of the i-th value (in the values tensor). - // The linearized-index can be converted into an index tuple (k_1,...,k_rank) - // using the shape provided below. - // The indices must appear in ascending order without duplication. - // In the first format, the ordering is lexicographic-ordering: - // e.g., index-value [1,4] must appear before [2,1] - optional TensorProto indices = 2; - - // The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank] - repeated int64 dims = 3; -} - -// Defines a tensor shape. A dimension can be either an integer value -// or a symbolic variable. A symbolic variable represents an unknown -// dimension. -message TensorShapeProto { - message Dimension { - oneof value { - int64 dim_value = 1; - string dim_param = 2; // namespace Shape - }; - // Standard denotation can optionally be used to denote tensor - // dimensions with standard semantic descriptions to ensure - // that operations are applied to the correct axis of a tensor. - // Refer to https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition - // for pre-defined dimension denotations. - optional string denotation = 3; - }; - repeated Dimension dim = 1; -} - -// Types -// -// The standard ONNX data types. -message TypeProto { - - message Tensor { - // This field MUST NOT have the value of UNDEFINED - // This field MUST have a valid TensorProto.DataType value - // This field MUST be present for this version of the IR. - optional int32 elem_type = 1; - optional TensorShapeProto shape = 2; - } - - // repeated T - message Sequence { - // The type and optional shape of each element of the sequence. - // This field MUST be present for this version of the IR. - optional TypeProto elem_type = 1; - }; - - // map - message Map { - // This field MUST have a valid TensorProto.DataType value - // This field MUST be present for this version of the IR. - // This field MUST refer to an integral type ([U]INT{8|16|32|64}) or STRING - optional int32 key_type = 1; - // This field MUST be present for this version of the IR. - optional TypeProto value_type = 2; - }; - - - oneof value { - // The type of a tensor. - Tensor tensor_type = 1; - - // NOTE: DNN-only implementations of ONNX MAY elect to not support non-tensor values - // as input and output to graphs and nodes. These types are needed to naturally - // support classical ML operators. DNN operators SHOULD restrict their input - // and output types to tensors. - - // The type of a sequence. - Sequence sequence_type = 4; - - // The type of a map. - Map map_type = 5; - - } - - // An optional denotation can be used to denote the whole - // type with a standard semantic description as to what is - // stored inside. Refer to https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition - // for pre-defined type denotations. - optional string denotation = 6; -} - -// Operator Sets -// -// OperatorSets are uniquely identified by a (domain, opset_version) pair. -message OperatorSetIdProto { - // The domain of the operator set being identified. - // The empty string ("") or absence of this field implies the operator - // set that is defined as part of the ONNX specification. - // This field MUST be present in this version of the IR when referring to any other operator set. - optional string domain = 1; - - // The version of the operator set being identified. - // This field MUST be present in this version of the IR. - optional int64 version = 2; -} \ No newline at end of file diff --git a/third_party/proto/tensorflow/LICENSE b/third_party/proto/tensorflow/LICENSE deleted file mode 100644 index 40f8c347..00000000 --- a/third_party/proto/tensorflow/LICENSE +++ /dev/null @@ -1,203 +0,0 @@ -Copyright 2019 The TensorFlow Authors. All rights reserved. - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/third_party/proto/tensorflow/attr_value.proto b/third_party/proto/tensorflow/attr_value.proto deleted file mode 100644 index ddf134b2..00000000 --- a/third_party/proto/tensorflow/attr_value.proto +++ /dev/null @@ -1,64 +0,0 @@ -syntax = "proto3"; - -package tensorflow; - -import "tensor.proto"; -import "tensor_shape.proto"; -import "types.proto"; - -option cc_enable_arenas = true; -option java_outer_classname = "AttrValueProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/attr_value_go_proto"; - -// Protocol buffer representing the value for an attr used to configure an Op. -// Comment indicates the corresponding attr type. Only the field matching the -// attr type may be filled. -message AttrValue { - // LINT.IfChange - message ListValue { - repeated bytes s = 2; // "list(string)" - repeated int64 i = 3 [packed = true]; // "list(int)" - repeated float f = 4 [packed = true]; // "list(float)" - repeated bool b = 5 [packed = true]; // "list(bool)" - repeated DataType type = 6 [packed = true]; // "list(type)" - repeated TensorShapeProto shape = 7; // "list(shape)" - repeated TensorProto tensor = 8; // "list(tensor)" - repeated NameAttrList func = 9; // "list(attr)" - } - // LINT.ThenChange(https://www.tensorflow.org/code/tensorflow/c/c_api.cc) - - oneof value { - bytes s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - DataType type = 6; // "type" - TensorShapeProto shape = 7; // "shape" - TensorProto tensor = 8; // "tensor" - ListValue list = 1; // any "list(...)" - - // "func" represents a function. func.name is a function's name or - // a primitive op's name. func.attr.first is the name of an attr - // defined for that function. func.attr.second is the value for - // that attr in the instantiation. - NameAttrList func = 10; - - // This is a placeholder only used in nodes defined inside a - // function. It indicates the attr value will be supplied when - // the function is instantiated. For example, let us suppose a - // node "N" in function "FN". "N" has an attr "A" with value - // placeholder = "foo". When FN is instantiated with attr "foo" - // set to "bar", the instantiated node N's attr A will have been - // given the value "bar". - string placeholder = 9; - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NameAttrList { - string name = 1; - map attr = 2; -} diff --git a/third_party/proto/tensorflow/function.proto b/third_party/proto/tensorflow/function.proto deleted file mode 100644 index 8502ae5c..00000000 --- a/third_party/proto/tensorflow/function.proto +++ /dev/null @@ -1,126 +0,0 @@ -syntax = "proto3"; - -package tensorflow; - -import "attr_value.proto"; -import "node_def.proto"; -import "op_def.proto"; - -option cc_enable_arenas = true; -option java_outer_classname = "FunctionProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/function_go_proto"; - -// A library is a set of named functions. -message FunctionDefLibrary { - repeated FunctionDef function = 1; - repeated GradientDef gradient = 2; -} - -// A function can be instantiated when the runtime can bind every attr -// with a value. When a GraphDef has a call to a function, it must -// have binding for every attr defined in the signature. -// -// TODO(zhifengc): -// * device spec, etc. -message FunctionDef { - // The definition of the function's name, arguments, return values, - // attrs etc. - OpDef signature = 1; - - // Attributes specific to this function definition. - map attr = 5; - - // Attributes for function arguments. These attributes are the same set of - // valid attributes as to _Arg nodes. - message ArgAttrs { - map attr = 1; - } - map arg_attr = 7; - - // Unique IDs for each resource argument, used to track aliasing resources. If - // Argument A and Argument B alias each other, then - // resource_arg_unique_ids[A.index] == resource_arg_unique_ids[B.index]. - // - // If this field is empty, none of the arguments could alias; otherwise, every - // resource argument should have an entry in this field. - // - // When instantiated, the unique IDs will be attached to the _Arg nodes' - // "_resource_arg_unique_id" attribute. - map resource_arg_unique_id = 8; - - // NOTE: field id 2 deleted on Jan 11, 2017, GraphDef version 21. - reserved 2; - - // In both of the following fields, there is the need to specify an - // output that is used as either the input to another node (in - // `node_def`) or as a return value of the function (in `ret`). - // Unlike the NodeDefs in GraphDef, we need to be able to specify a - // list in some cases (instead of just single outputs). Also, we - // need to be able to deal with lists of unknown length (so the - // output index may not be known at function definition time). So - // we use the following format instead: - // * "fun_in" where "fun_in" is the name of a function input arg in - // the `signature` field above. This represents that input, whether - // it is a single tensor or a list. - // * "fun_in:0" gives the first element of a function input arg (a - // non-list input is considered a list of length 1 for these - // purposes). - // * "node:out" where "node" is the name of a node in `node_def` and - // "out" is the name one of its op's output arguments (the name - // comes from the OpDef of the node's op). This represents that - // node's output, whether it is a single tensor or a list. - // Note: We enforce that an op's output arguments are never - // renamed in the backwards-compatibility test. - // * "node:out:0" gives the first element of a node output arg (a - // non-list output is considered a list of length 1 for these - // purposes). - // - // NOT CURRENTLY SUPPORTED (but may be in the future): - // * "node:out:-1" gives last element in a node output list - // * "node:out:1:" gives a list with all but the first element in a - // node output list - // * "node:out::-1" gives a list with all but the last element in a - // node output list - - // The body of the function. Unlike the NodeDefs in a GraphDef, attrs - // may have values of type `placeholder` and the `input` field uses - // the "output" format above. - - // By convention, "op" in node_def is resolved by consulting with a - // user-defined library first. If not resolved, "func" is assumed to - // be a builtin op. - repeated NodeDef node_def = 3; - - // A mapping from the output arg names from `signature` to the - // outputs from `node_def` that should be returned by the function. - map ret = 4; - - // A mapping from control output names from `signature` to node names in - // `node_def` which should be control outputs of this function. - map control_ret = 6; -} - -// GradientDef defines the gradient function of a function defined in -// a function library. -// -// A gradient function g (specified by gradient_func) for a function f -// (specified by function_name) must follow the following: -// -// The function 'f' must be a numerical function which takes N inputs -// and produces M outputs. Its gradient function 'g', which is a -// function taking N + M inputs and produces N outputs. -// -// I.e. if we have -// (y1, y2, ..., y_M) = f(x1, x2, ..., x_N), -// then, g is -// (dL/dx1, dL/dx2, ..., dL/dx_N) = g(x1, x2, ..., x_N, -// dL/dy1, dL/dy2, ..., dL/dy_M), -// where L is a scalar-value function of (x1, x2, ..., xN) (e.g., the -// loss function). dL/dx_i is the partial derivative of L with respect -// to x_i. -message GradientDef { - string function_name = 1; // The function name. - string gradient_func = 2; // The gradient function's name. -} diff --git a/third_party/proto/tensorflow/graph.proto b/third_party/proto/tensorflow/graph.proto deleted file mode 100644 index 13a05d89..00000000 --- a/third_party/proto/tensorflow/graph.proto +++ /dev/null @@ -1,58 +0,0 @@ -syntax = "proto3"; - -package tensorflow; - -import "function.proto"; -import "node_def.proto"; -import "versions.proto"; - -option cc_enable_arenas = true; -option java_outer_classname = "GraphProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/graph_go_proto"; - -// Represents the graph of operations -message GraphDef { - repeated NodeDef node = 1; - - // Compatibility versions of the graph. See core/public/version.h for version - // history. The GraphDef version is distinct from the TensorFlow version, and - // each release of TensorFlow will support a range of GraphDef versions. - VersionDef versions = 4; - - // Deprecated single version field; use versions above instead. Since all - // GraphDef changes before "versions" was introduced were forward - // compatible, this field is entirely ignored. - int32 version = 3 [deprecated = true]; - - // EXPERIMENTAL. DO NOT USE OR DEPEND ON THIS YET. - // - // "library" provides user-defined functions. - // - // Naming: - // * library.function.name are in a flat namespace. - // NOTE: We may need to change it to be hierarchical to support - // different orgs. E.g., - // { "/google/nn", { ... }}, - // { "/google/vision", { ... }} - // { "/org_foo/module_bar", { ... }} - // map named_lib; - // * If node[i].op is the name of one function in "library", - // node[i] is deemed as a function call. Otherwise, node[i].op - // must be a primitive operation supported by the runtime. - // - // - // Function call semantics: - // - // * The callee may start execution as soon as some of its inputs - // are ready. The caller may want to use Tuple() mechanism to - // ensure all inputs are ready in the same time. - // - // * The consumer of return values may start executing as soon as - // the return values the consumer depends on are ready. The - // consumer may want to use Tuple() mechanism to ensure the - // consumer does not start until all return values of the callee - // function are ready. - FunctionDefLibrary library = 2; -} diff --git a/third_party/proto/tensorflow/lite/schema.fbs b/third_party/proto/tensorflow/lite/schema.fbs deleted file mode 100644 index a8bdf5e0..00000000 --- a/third_party/proto/tensorflow/lite/schema.fbs +++ /dev/null @@ -1,1094 +0,0 @@ -// Copyright 2017 The TensorFlow Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Revision History -// Version 0: Initial version. -// Version 1: Add subgraphs to schema. -// Version 2: Rename operators to conform to NN API. -// Version 3: Move buffer data from Model.Subgraph.Tensors to Model.Buffers. - -namespace tflite; - -// This corresponds to the version. -file_identifier "TFL3"; -// File extension of any written files. -file_extension "tflite"; - -// IMPORTANT: All new members of tables, enums and unions must be added at the -// end to ensure backwards compatibility. - -// The type of data stored in a tensor. -enum TensorType : byte { - FLOAT32 = 0, - FLOAT16 = 1, - INT32 = 2, - UINT8 = 3, - INT64 = 4, - STRING = 5, - BOOL = 6, - INT16 = 7, - COMPLEX64 = 8, - INT8 = 9, - FLOAT64 = 10, -} - -// Custom quantization parameters for experimenting with new quantization -// techniques. -table CustomQuantization { - custom:[ubyte] (force_align: 16); -} - -// Represents a specific quantization technique's parameters. -union QuantizationDetails { - CustomQuantization, -} - -// Parameters for converting a quantized tensor back to float. -table QuantizationParameters { - // These four parameters are the asymmetric linear quantization parameters. - // Given a quantized value q, the corresponding float value f should be: - // f = scale * (q - zero_point) - // For other quantization types, the QuantizationDetails below is used. - min:[float]; // For importing back into tensorflow. - max:[float]; // For importing back into tensorflow. - scale:[float]; // For dequantizing the tensor's values. - zero_point:[long]; - - // If this is not none, the other quantization parameters (i.e. min, max, - // scale, zero_point fields above) are ignored and the value of the - // QuantizationDetails union should be used. - details:QuantizationDetails; - - // Specifies the dimension of the Tensor's shape that the scales and - // zero_points correspond to. For example, a tensor t, with dims=[4, 3, 2, 1] - // with quantization params: - // scale=[1.0, 2.0, 3.0], zero_point=[1, 2, 3], quantization_dimension=1 - // will be quantized across the second dimension of t. - // t[:, 0, :, :] will have scale[0]=1.0, zero_point[0]=1 - // t[:, 1, :, :] will have scale[1]=2.0, zero_point[0]=2 - // t[:, 2, :, :] will have scale[2]=3.0, zero_point[0]=3 - quantized_dimension:int; -} - -// Sparse tensors. -// We use a modification of the TACO format. -// Reference: http://tensor-compiler.org/kjolstad-oopsla17-tensor-compiler.pdf -// -// To encode a conceptual n-dimensional dense tensor with dims (d0, ..., dn-1), -// potentially with a k-dimensional block (0 <= k <= n) with dims -// (dn, ..., dn+k-1), the format needs to specify: -// 1. In what order to traverse these dimensions. For example, to store a 2-D -// matrix in row major order, the traversal order would be (d0, d1), -// whereas to store it in column major order, the traversal order would be -// (d1, d0). If the 2-D matrix has a 2-D inner block, the traversal order -// could be (d0, d1, d2, d3). -// 2. How each block dimension in (dn, ..., dn+k-1) maps to the original -// tensor dimension in (d0, ..., dn-1). -// 3. In the traversal order defined above, the format (dense vs. sparse) and -// index metadata for each dimension. For a dense dimension, this is just -// the size of that dimension. For a sparse dimension, it's the same as -// the compressed index defined in the Compressed Sparse Row (CSR) format. -// (http://scipy-lectures.org/advanced/scipy_sparse/csr_matrix.html) - -// The storage type for a dimension. Currently we support: -// 1. DENSE: each coordinate in this dimension is stored implicitly. -// 2. SPARSE_CSR: only the coordinates with non-zero elements are stored. The -// compression technique is the same what CSR uses. -// More types like a sparse dimension with a different compression technique -// could be added to the list in the future. -enum DimensionType : byte { - DENSE = 0, - SPARSE_CSR = 1, -} - -table Int32Vector { - values:[int]; -} - -table Uint16Vector { - values:[ushort] (force_align: 4); -} - -table Uint8Vector { - values:[ubyte] (force_align: 4); -} - -// Variable-typed buffer to store the index metadata for a sparse dimension. -// The widest type is Int32 instead of UInt32 because tensor's shape is a int32 -// vector. We don't want the per-dimensional index to overflow that range. -union SparseIndexVector { - Int32Vector, - Uint16Vector, - Uint8Vector -} - -table DimensionMetadata { - // Whether a dimension is dense or sparse. - format:DimensionType; - // Index metadata used for a dimension. - // - If format is DimensionType.DENSE then we use the dense_size field to - // store the size of that dimension. Each index in that dimension is - // stored implicitly. - // - If format is DimensionType.SPARSE_CSR then we use array_segments and - // array_indices to encode that dimension. array_segments represents how - // to segment the indices array, each segment corresponds to one element - // in the previous dimension. array_indices represents the index of the - // non-zero elements within this dimension (as those in the CSR matrix - // format, where the first array is row pointers and the second array is - // column indices). - dense_size:int; - array_segments:SparseIndexVector; - array_indices:SparseIndexVector; -} - -// Parameters to encode a sparse TfLite tensor. -table SparsityParameters { - // The traversal order of the dimensions defined in the `shape` field of the - // conceptual dense tensor. For a n-dimensional tensors with dims (d0, d1, - // ..., dn-1), - // - if not block sparse, the traversal_order is just a permutation of (d0, - // ..., dn-1). For example, a 2-D matrix stored in row-major order would - // have traversal_order = (d0, d1). - // - if block sparse with a k-dimensional block (0 <= k <= n), the - // traversal_order has n + k elements. The first n elements are still a - // permutation of (d0, ..., dn-1). The lask k elements are a permutation - // of (dn, ..., dn+k-1), defining how to traverse a block internally. For - // example, a 2-D matrix with 2-D blocks, both stored in row-major order - // would have traversal_order = (d0, d1, d2, d3). - traversal_order:[int]; - // For an n-dimensional tensor with a k-dimensional block (0 <= k <= n), - // stores how a block dimension in (dn, ..., dn+k-1) maps to the original - // tensor dimension in (d0, ..., dn). - // It's stored in the order of (dn, ..., dn+k-1). - // If not block-sparse, this field is NULL. - block_map:[int]; - // In the traversal order defined above, the metadata needed for - // each dimension to locate the non-zero values in the original dense tensor. - // The size of the dim_metadata array = the size of the traversal_order array - // = n + k. - dim_metadata:[DimensionMetadata]; -} - -table Tensor { - // The tensor shape. The meaning of each entry is operator-specific but - // builtin ops use: [batch size, height, width, number of channels] (That's - // Tensorflow's NHWC). - shape:[int]; - type:TensorType; - // An index that refers to the buffers table at the root of the model. Or, - // if there is no data buffer associated (i.e. intermediate results), then - // this is 0 (which refers to an always existent empty buffer). - // - // The data_buffer itself is an opaque container, with the assumption that the - // target device is little-endian. In addition, all builtin operators assume - // the memory is ordered such that if `shape` is [4, 3, 2], then index - // [i, j, k] maps to data_buffer[i*3*2 + j*2 + k]. - buffer:uint; - name:string; // For debugging and importing back into tensorflow. - quantization:QuantizationParameters; // Optional. - - is_variable:bool = false; - - // Parameters to encode a sparse tensor. See the example in - // tensorflow/lite/testdata/sparse_tensor.json. - sparsity:SparsityParameters; // Optional. - - // Encodes `shape` with unknown dimensions. Unknown dimensions are - // represented with -1. - shape_signature:[int]; // Optional. -} - -// A list of builtin operators. Builtin operators are slightly faster than custom -// ones, but not by much. Moreover, while custom operators accept an opaque -// object containing configuration parameters, builtins have a predetermined -// set of acceptable options. - -enum BuiltinOperator : byte { - ADD = 0, - AVERAGE_POOL_2D = 1, - CONCATENATION = 2, - CONV_2D = 3, - DEPTHWISE_CONV_2D = 4, - DEPTH_TO_SPACE = 5, - DEQUANTIZE = 6, - EMBEDDING_LOOKUP = 7, - FLOOR = 8, - FULLY_CONNECTED = 9, - HASHTABLE_LOOKUP = 10, - L2_NORMALIZATION = 11, - L2_POOL_2D = 12, - LOCAL_RESPONSE_NORMALIZATION = 13, - LOGISTIC = 14, - LSH_PROJECTION = 15, - LSTM = 16, - MAX_POOL_2D = 17, - MUL = 18, - RELU = 19, - // NOTE(aselle): RELU_N1_TO_1 used to be called RELU1, but it was renamed - // since different model developers use RELU1 in different ways. Never - // create another op called RELU1. - RELU_N1_TO_1 = 20, - RELU6 = 21, - RESHAPE = 22, - RESIZE_BILINEAR = 23, - RNN = 24, - SOFTMAX = 25, - SPACE_TO_DEPTH = 26, - SVDF = 27, - TANH = 28, - // Consider rename to CONCATENATE_EMBEDDINGS - CONCAT_EMBEDDINGS = 29, - SKIP_GRAM = 30, - CALL = 31, - CUSTOM = 32, - EMBEDDING_LOOKUP_SPARSE = 33, - PAD = 34, - UNIDIRECTIONAL_SEQUENCE_RNN = 35, - GATHER = 36, - BATCH_TO_SPACE_ND = 37, - SPACE_TO_BATCH_ND = 38, - TRANSPOSE = 39, - MEAN = 40, - SUB = 41, - DIV = 42, - SQUEEZE = 43, - UNIDIRECTIONAL_SEQUENCE_LSTM = 44, - STRIDED_SLICE = 45, - BIDIRECTIONAL_SEQUENCE_RNN = 46, - EXP = 47, - TOPK_V2 = 48, - SPLIT = 49, - LOG_SOFTMAX = 50, - // DELEGATE is a special op type for the operations which are delegated to - // other backends. - // WARNING: Experimental interface, subject to change - DELEGATE = 51, - BIDIRECTIONAL_SEQUENCE_LSTM = 52, - CAST = 53, - PRELU = 54, - MAXIMUM = 55, - ARG_MAX = 56, - MINIMUM = 57, - LESS = 58, - NEG = 59, - PADV2 = 60, - GREATER = 61, - GREATER_EQUAL = 62, - LESS_EQUAL = 63, - SELECT = 64, - SLICE = 65, - SIN = 66, - TRANSPOSE_CONV = 67, - SPARSE_TO_DENSE = 68, - TILE = 69, - EXPAND_DIMS = 70, - EQUAL = 71, - NOT_EQUAL = 72, - LOG = 73, - SUM = 74, - SQRT = 75, - RSQRT = 76, - SHAPE = 77, - POW = 78, - ARG_MIN = 79, - FAKE_QUANT = 80, - REDUCE_PROD = 81, - REDUCE_MAX = 82, - PACK = 83, - LOGICAL_OR = 84, - ONE_HOT = 85, - LOGICAL_AND = 86, - LOGICAL_NOT = 87, - UNPACK = 88, - REDUCE_MIN = 89, - FLOOR_DIV = 90, - REDUCE_ANY = 91, - SQUARE = 92, - ZEROS_LIKE = 93, - FILL = 94, - FLOOR_MOD = 95, - RANGE = 96, - RESIZE_NEAREST_NEIGHBOR = 97, - LEAKY_RELU = 98, - SQUARED_DIFFERENCE = 99, - MIRROR_PAD = 100, - ABS = 101, - SPLIT_V = 102, - UNIQUE = 103, - CEIL = 104, - REVERSE_V2 = 105, - ADD_N = 106, - GATHER_ND = 107, - COS = 108, - WHERE = 109, - RANK = 110, - ELU = 111, - REVERSE_SEQUENCE = 112, - MATRIX_DIAG = 113, - QUANTIZE = 114, - MATRIX_SET_DIAG = 115, - ROUND = 116, - HARD_SWISH = 117, - IF = 118, - WHILE = 119, - NON_MAX_SUPPRESSION_V4 = 120, - NON_MAX_SUPPRESSION_V5 = 121, - SCATTER_ND = 122, - SELECT_V2 = 123, - DENSIFY = 124, - SEGMENT_SUM = 125, - BATCH_MATMUL = 126 -} - - -// Options for the builtin operators. -union BuiltinOptions { - Conv2DOptions, - DepthwiseConv2DOptions, - ConcatEmbeddingsOptions, - LSHProjectionOptions, - Pool2DOptions, - SVDFOptions, - RNNOptions, - FullyConnectedOptions, - SoftmaxOptions, - ConcatenationOptions, - AddOptions, - L2NormOptions, - LocalResponseNormalizationOptions, - LSTMOptions, - ResizeBilinearOptions, - CallOptions, - ReshapeOptions, - SkipGramOptions, - SpaceToDepthOptions, - EmbeddingLookupSparseOptions, - MulOptions, - PadOptions, - GatherOptions, - BatchToSpaceNDOptions, - SpaceToBatchNDOptions, - TransposeOptions, - ReducerOptions, - SubOptions, - DivOptions, - SqueezeOptions, - SequenceRNNOptions, - StridedSliceOptions, - ExpOptions, - TopKV2Options, - SplitOptions, - LogSoftmaxOptions, - CastOptions, - DequantizeOptions, - MaximumMinimumOptions, - ArgMaxOptions, - LessOptions, - NegOptions, - PadV2Options, - GreaterOptions, - GreaterEqualOptions, - LessEqualOptions, - SelectOptions, - SliceOptions, - TransposeConvOptions, - SparseToDenseOptions, - TileOptions, - ExpandDimsOptions, - EqualOptions, - NotEqualOptions, - ShapeOptions, - PowOptions, - ArgMinOptions, - FakeQuantOptions, - PackOptions, - LogicalOrOptions, - OneHotOptions, - LogicalAndOptions, - LogicalNotOptions, - UnpackOptions, - FloorDivOptions, - SquareOptions, - ZerosLikeOptions, - FillOptions, - BidirectionalSequenceLSTMOptions, - BidirectionalSequenceRNNOptions, - UnidirectionalSequenceLSTMOptions, - FloorModOptions, - RangeOptions, - ResizeNearestNeighborOptions, - LeakyReluOptions, - SquaredDifferenceOptions, - MirrorPadOptions, - AbsOptions, - SplitVOptions, - UniqueOptions, - ReverseV2Options, - AddNOptions, - GatherNdOptions, - CosOptions, - WhereOptions, - RankOptions, - ReverseSequenceOptions, - MatrixDiagOptions, - QuantizeOptions, - MatrixSetDiagOptions, - HardSwishOptions, - IfOptions, - WhileOptions, - DepthToSpaceOptions, - NonMaxSuppressionV4Options, - NonMaxSuppressionV5Options, - ScatterNdOptions, - SelectV2Options, - DensifyOptions, - SegmentSumOptions, - BatchMatMulOptions -} - -enum Padding : byte { SAME, VALID } - -enum ActivationFunctionType : byte { - NONE = 0, - RELU = 1, - RELU_N1_TO_1 = 2, - RELU6 = 3, - TANH = 4, - SIGN_BIT = 5, -} - -table Conv2DOptions { - padding:Padding; - stride_w:int; - stride_h:int; - fused_activation_function:ActivationFunctionType; - dilation_w_factor:int = 1; - dilation_h_factor:int = 1; -} - -table Pool2DOptions { - padding:Padding; - stride_w:int; - stride_h:int; - filter_width:int; - filter_height:int; - fused_activation_function:ActivationFunctionType; -} - -table DepthwiseConv2DOptions { - // Parameters for DepthwiseConv version 1 or above. - padding:Padding; - stride_w:int; - stride_h:int; - // `depth_multiplier` is redundant. It's used by CPU kernels in - // TensorFlow 2.0 or below, but ignored in versions above. - // See comments in lite/c/builtin_op_data.h for more details. - depth_multiplier:int; - fused_activation_function:ActivationFunctionType; - // Parameters for DepthwiseConv version 2 or above. - dilation_w_factor:int = 1; - dilation_h_factor:int = 1; -} - -table ConcatEmbeddingsOptions { - num_channels:int; - num_columns_per_channel:[int]; - embedding_dim_per_channel:[int]; // This could be inferred from parameters. -} - -enum LSHProjectionType: byte { - UNKNOWN = 0, - SPARSE = 1, - DENSE = 2, -} - -table LSHProjectionOptions { - type: LSHProjectionType; -} - -table SVDFOptions { - rank:int; - fused_activation_function:ActivationFunctionType; - // For weights-only quantization, use asymmetric quantization for non - // constant inputs at evaluation time. - asymmetric_quantize_inputs:bool; -} - -// An implementation of TensorFlow RNNCell. -table RNNOptions { - fused_activation_function:ActivationFunctionType; - asymmetric_quantize_inputs:bool; -} - -// An implementation of TensorFlow dynamic_rnn with RNNCell. -table SequenceRNNOptions { - time_major:bool; - fused_activation_function:ActivationFunctionType; - asymmetric_quantize_inputs:bool; -} - -// An implementation of TensorFlow bidrectional_dynamic_rnn with RNNCell. -table BidirectionalSequenceRNNOptions { - time_major:bool; - fused_activation_function:ActivationFunctionType; - merge_outputs: bool; - asymmetric_quantize_inputs:bool; -} - -enum FullyConnectedOptionsWeightsFormat: byte { - DEFAULT = 0, - SHUFFLED4x16INT8 = 1, -} - -// An implementation of TensorFlow fully_connected (a.k.a Dense) layer. -table FullyConnectedOptions { - // Parameters for FullyConnected version 1 or above. - fused_activation_function:ActivationFunctionType; - - // Parameters for FullyConnected version 2 or above. - weights_format:FullyConnectedOptionsWeightsFormat = DEFAULT; - - // Parameters for FullyConnected version 5 or above. - // If set to true, then the number of dimension is preserved. Furthermore, - // all but the last dimension of the input and output shapes will be equal. - keep_num_dims: bool; - - // Parameters for FullyConnected version 7 or above. - // If set to true, then weights-only op will use asymmetric quantization for - // inputs. - asymmetric_quantize_inputs: bool; -} - -table SoftmaxOptions { - beta: float; -} - -// An implementation of TensorFlow concat. -table ConcatenationOptions { - axis:int; - fused_activation_function:ActivationFunctionType; -} - -table AddOptions { - fused_activation_function:ActivationFunctionType; -} - -table MulOptions { - fused_activation_function:ActivationFunctionType; -} - -table L2NormOptions { - fused_activation_function:ActivationFunctionType; -} - -table LocalResponseNormalizationOptions { - radius:int; - bias:float; - alpha:float; - beta:float; -} - -enum LSTMKernelType : byte { - // Full LSTM kernel which supports peephole and projection. - FULL = 0, - // Basic LSTM kernels. Equivalent to TensorFlow BasicLSTMCell. - BASIC = 1, -} - -// An implementation of TensorFlow LSTMCell and CoupledInputForgetGateLSTMCell -table LSTMOptions { - // Parameters for LSTM version 1 or above. - fused_activation_function:ActivationFunctionType; - cell_clip: float; // Optional, 0.0 means no clipping - proj_clip: float; // Optional, 0.0 means no clipping - - // Parameters for LSTM version 2 or above. - // Basic kernel is only supported in version 2 or above. - kernel_type: LSTMKernelType = FULL; - - // Parameters for LSTM version 4 or above. - asymmetric_quantize_inputs: bool; -} - -// An implementation of TensorFlow dynamic_rnn with LSTMCell. -table UnidirectionalSequenceLSTMOptions { - fused_activation_function:ActivationFunctionType; - cell_clip: float; // Optional, 0.0 means no clipping - proj_clip: float; // Optional, 0.0 means no clipping - - // If true then first dimension is sequence, otherwise batch. - time_major:bool; - - // Parameter for Unidirectional Sequence LSTM version 4. - asymmetric_quantize_inputs:bool; -} - -table BidirectionalSequenceLSTMOptions { - // Parameters supported by version 1: - fused_activation_function:ActivationFunctionType; - cell_clip: float; // Optional, 0.0 means no clipping - proj_clip: float; // Optional, 0.0 means no clipping - - // If true, store the outputs of both directions into the first output. - merge_outputs: bool; - - // Parameters supported by version 2: - // If true then first dimension is sequence, otherwise batch. - // Version 1 implementations assumed time_major to be true, so this default - // value should never change. - time_major: bool = true; - - // Parameters for version 3 or above. - asymmetric_quantize_inputs:bool; -} - -table ResizeBilinearOptions { - new_height: int (deprecated); - new_width: int (deprecated); - align_corners: bool; - half_pixel_centers: bool; -} - -table ResizeNearestNeighborOptions { - align_corners: bool; - half_pixel_centers: bool; -} - -// A call operation options -table CallOptions { - // The subgraph index that needs to be called. - subgraph:uint; -} - -table PadOptions { -} - -table PadV2Options { -} - -table ReshapeOptions { - new_shape:[int]; -} - -table SpaceToBatchNDOptions { -} - -table BatchToSpaceNDOptions { -} - -table SkipGramOptions { - ngram_size: int; - max_skip_size: int; - include_all_ngrams: bool; -} - -table SpaceToDepthOptions { - block_size: int; -} - -table DepthToSpaceOptions { - block_size: int; -} - -table SubOptions { - fused_activation_function:ActivationFunctionType; -} - -table DivOptions { - fused_activation_function:ActivationFunctionType; -} - -table TopKV2Options { -} - -enum CombinerType : byte { - SUM = 0, - MEAN = 1, - SQRTN = 2, -} - -table EmbeddingLookupSparseOptions { - combiner:CombinerType; -} - -table GatherOptions { - axis: int; -} - -table TransposeOptions { -} - -table ExpOptions { -} - -table CosOptions { -} - -table ReducerOptions { - keep_dims: bool; -} - -table SqueezeOptions { - squeeze_dims:[int]; -} - -table SplitOptions { - num_splits: int; -} - -table SplitVOptions { - num_splits: int; -} - -table StridedSliceOptions { - begin_mask: int; - end_mask: int; - ellipsis_mask: int; - new_axis_mask: int; - shrink_axis_mask: int; -} - -table LogSoftmaxOptions { -} - -table CastOptions { - in_data_type: TensorType; - out_data_type: TensorType; -} - -table DequantizeOptions { -} - -table MaximumMinimumOptions { -} - -table TileOptions { -} - -table ArgMaxOptions { - output_type : TensorType; -} - -table ArgMinOptions { - output_type : TensorType; -} - -table GreaterOptions { -} - -table GreaterEqualOptions { -} - -table LessOptions { -} - -table LessEqualOptions { -} - -table NegOptions { -} - -table SelectOptions { -} - -table SliceOptions { -} - -table TransposeConvOptions { - padding:Padding; - stride_w:int; - stride_h:int; -} - -table ExpandDimsOptions { -} - -table SparseToDenseOptions { - validate_indices:bool; -} - -table EqualOptions { -} - -table NotEqualOptions { -} - -table ShapeOptions { - // Optional output type of the operation (int32 or int64). Defaults to int32. - out_type : TensorType; -} - -table RankOptions { -} - -table PowOptions { -} - -table FakeQuantOptions { - // Parameters supported by version 1: - min:float; - max:float; - num_bits:int; - - // Parameters supported by version 2: - narrow_range:bool; -} - -table PackOptions { - values_count:int; - axis:int; -} - -table LogicalOrOptions { -} - -table OneHotOptions { - axis:int; -} - -table AbsOptions { -} - - -table HardSwishOptions { -} - -table LogicalAndOptions { -} - -table LogicalNotOptions { -} - -table UnpackOptions { - num:int; - axis:int; -} - -table FloorDivOptions { -} - -table SquareOptions { -} - -table ZerosLikeOptions { -} - -table FillOptions { -} - -table FloorModOptions { -} - -table RangeOptions { -} - -table LeakyReluOptions { - alpha:float; -} - -table SquaredDifferenceOptions { -} - -enum MirrorPadMode : byte { - // Doesn't include borders. - REFLECT = 0, - // Includes borders. - SYMMETRIC = 1, -} - -table MirrorPadOptions { - mode:MirrorPadMode; -} - -table UniqueOptions { - idx_out_type:TensorType = INT32; -} - -table ReverseV2Options { -} - -table AddNOptions { -} - -table GatherNdOptions { -} - -table WhereOptions { -} - -table ReverseSequenceOptions { - seq_dim:int; - batch_dim:int = 0; -} - -table MatrixDiagOptions { -} - -table QuantizeOptions { -} - -table MatrixSetDiagOptions { -} - -table IfOptions { - then_subgraph_index:int; - else_subgraph_index:int; -} - -table WhileOptions { - cond_subgraph_index:int; - body_subgraph_index:int; -} - -table NonMaxSuppressionV4Options { -} - -table NonMaxSuppressionV5Options { -} - -table ScatterNdOptions { -} - -table SelectV2Options { -} - -table DensifyOptions { -} - -table SegmentSumOptions { -} - -table BatchMatMulOptions { - adj_x:bool; - adj_y:bool; -} - -// An OperatorCode can be an enum value (BuiltinOperator) if the operator is a -// builtin, or a string if the operator is custom. -table OperatorCode { - builtin_code:BuiltinOperator; - custom_code:string; - - // The version of the operator. The version need to be bumped whenever new - // parameters are introduced into an op. - version:int = 1; -} - -enum CustomOptionsFormat : byte { - FLEXBUFFERS = 0, -} - -// An operator takes tensors as inputs and outputs. The type of operation being -// performed is determined by an index into the list of valid OperatorCodes, -// while the specifics of each operations is configured using builtin_options -// or custom_options. -table Operator { - // Index into the operator_codes array. Using an integer here avoids - // complicate map lookups. - opcode_index:uint; - - // Optional input are indicated by -1. - inputs:[int]; - outputs:[int]; - - builtin_options:BuiltinOptions; - custom_options:[ubyte]; - custom_options_format:CustomOptionsFormat; - - // A list of booleans indicating the input tensors which are being mutated by - // this operator.(e.g. used by RNN and LSTM). - // For example, if the "inputs" array refers to 5 tensors and the second and - // fifth are mutable variables, then this list will contain - // [false, true, false, false, true]. - // - // If the list is empty, no variable is mutated in this operator. - // The list either has the same length as `inputs`, or is empty. - mutating_variable_inputs:[bool]; - - // A list of indices to the subgraph's "tensors" that are internal to an Op. - // Internal tensors are those that do not flow in or out of the operation, - // but instead are part of internal computation. As such, the operation's - // implementation may manage its memory more efficiently. They are needed - // however (i.e. not just an implementation detail) since they are part of the - // computation, which may require relevant metadata such as quantization - // parameters. - intermediates:[int]; -} - -// The root type, defining a subgraph, which typically represents an entire -// model. -table SubGraph { - // A list of all tensors used in this subgraph. - tensors:[Tensor]; - - // Indices of the tensors that are inputs into this subgraph. Note this is - // the list of non-static tensors that feed into the subgraph for inference. - inputs:[int]; - - // Indices of the tensors that are outputs out of this subgraph. Note this is - // the list of output tensors that are considered the product of the - // subgraph's inference. - outputs:[int]; - - // All operators, in execution order. - operators:[Operator]; - - // Name of this subgraph (used for debugging). - name:string; -} - -// Table of raw data buffers (used for constant tensors). Referenced by tensors -// by index. The generous alignment accommodates mmap-friendly data structures. -table Buffer { - data:[ubyte] (force_align: 16); -} - -table Metadata { - // A human readable string to uniquely identify a Metadata. - name:string; - // An index to the buffers table. - buffer:uint; -} - -table Model { - // Version of the schema. - version:uint; - - // A list of all operator codes used in this model. This is - // kept in order because operators carry an index into this - // vector. - operator_codes:[OperatorCode]; - - // All the subgraphs of the model. The 0th is assumed to be the main - // model. - subgraphs:[SubGraph]; - - // A description of the model. - description:string; - - // Buffers of the model. - // Note the 0th entry of this array must be an empty buffer (sentinel). - // This is a convention so that tensors without a buffer can provide 0 as - // their buffer. - buffers:[Buffer]; - - // Metadata about the model. Indirects into the existings buffers list. - // Deprecated, prefer to use metadata field. - metadata_buffer:[int]; - - // Metadata about the model. - metadata:[Metadata]; -} - -root_type Model; diff --git a/third_party/proto/tensorflow/lite/schema_2.4.1.fbs b/third_party/proto/tensorflow/lite/schema_2.4.1.fbs deleted file mode 100644 index 62045344..00000000 --- a/third_party/proto/tensorflow/lite/schema_2.4.1.fbs +++ /dev/null @@ -1,1146 +0,0 @@ -// Copyright 2017 The TensorFlow Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Revision History -// Version 0: Initial version. -// Version 1: Add subgraphs to schema. -// Version 2: Rename operators to conform to NN API. -// Version 3: Move buffer data from Model.Subgraph.Tensors to Model.Buffers. -// Version 3a: Add new builtin op code field. Has backward compatibility with -// version 3. - -namespace tflite; - -// This corresponds to the version. -file_identifier "TFL3"; -// File extension of any written files. -file_extension "tflite"; - -// IMPORTANT: All new members of tables, enums and unions must be added at the -// end to ensure backwards compatibility. - -// The type of data stored in a tensor. -enum TensorType : byte { - FLOAT32 = 0, - FLOAT16 = 1, - INT32 = 2, - UINT8 = 3, - INT64 = 4, - STRING = 5, - BOOL = 6, - INT16 = 7, - COMPLEX64 = 8, - INT8 = 9, - FLOAT64 = 10, - COMPLEX128 = 11, -} - -// Custom quantization parameters for experimenting with new quantization -// techniques. -table CustomQuantization { - custom:[ubyte] (force_align: 16); -} - -// Represents a specific quantization technique's parameters. -union QuantizationDetails { - CustomQuantization, -} - -// Parameters for converting a quantized tensor back to float. -table QuantizationParameters { - // These four parameters are the asymmetric linear quantization parameters. - // Given a quantized value q, the corresponding float value f should be: - // f = scale * (q - zero_point) - // For other quantization types, the QuantizationDetails below is used. - min:[float]; // For importing back into tensorflow. - max:[float]; // For importing back into tensorflow. - scale:[float]; // For dequantizing the tensor's values. - zero_point:[long]; - - // If this is not none, the other quantization parameters (i.e. min, max, - // scale, zero_point fields above) are ignored and the value of the - // QuantizationDetails union should be used. - details:QuantizationDetails; - - // Specifies the dimension of the Tensor's shape that the scales and - // zero_points correspond to. For example, a tensor t, with dims=[4, 3, 2, 1] - // with quantization params: - // scale=[1.0, 2.0, 3.0], zero_point=[1, 2, 3], quantization_dimension=1 - // will be quantized across the second dimension of t. - // t[:, 0, :, :] will have scale[0]=1.0, zero_point[0]=1 - // t[:, 1, :, :] will have scale[1]=2.0, zero_point[0]=2 - // t[:, 2, :, :] will have scale[2]=3.0, zero_point[0]=3 - quantized_dimension:int; -} - -// Sparse tensors. -// We use a modification of the TACO format. -// Reference: http://tensor-compiler.org/kjolstad-oopsla17-tensor-compiler.pdf -// -// To encode a conceptual n-dimensional dense tensor with dims (d0, ..., dn-1), -// potentially with a k-dimensional block (0 <= k <= n) with dims -// (dn, ..., dn+k-1), the format needs to specify: -// 1. In what order to traverse these dimensions. For example, to store a 2-D -// matrix in row major order, the traversal order would be (d0, d1), -// whereas to store it in column major order, the traversal order would be -// (d1, d0). If the 2-D matrix has a 2-D inner block, the traversal order -// could be (d0, d1, d2, d3). -// 2. How each block dimension in (dn, ..., dn+k-1) maps to the original -// tensor dimension in (d0, ..., dn-1). -// 3. In the traversal order defined above, the format (dense vs. sparse) and -// index metadata for each dimension. For a dense dimension, this is just -// the size of that dimension. For a sparse dimension, it's the same as -// the compressed index defined in the Compressed Sparse Row (CSR) format. -// (http://scipy-lectures.org/advanced/scipy_sparse/csr_matrix.html) - -// The storage type for a dimension. Currently we support: -// 1. DENSE: each coordinate in this dimension is stored implicitly. -// 2. SPARSE_CSR: only the coordinates with non-zero elements are stored. The -// compression technique is the same what CSR uses. -// More types like a sparse dimension with a different compression technique -// could be added to the list in the future. -enum DimensionType : byte { - DENSE = 0, - SPARSE_CSR = 1, -} - -table Int32Vector { - values:[int]; -} - -table Uint16Vector { - values:[ushort] (force_align: 4); -} - -table Uint8Vector { - values:[ubyte] (force_align: 4); -} - -// Variable-typed buffer to store the index metadata for a sparse dimension. -// The widest type is Int32 instead of UInt32 because tensor's shape is a int32 -// vector. We don't want the per-dimensional index to overflow that range. -union SparseIndexVector { - Int32Vector, - Uint16Vector, - Uint8Vector -} - -table DimensionMetadata { - // Whether a dimension is dense or sparse. - format:DimensionType; - // Index metadata used for a dimension. - // - If format is DimensionType.DENSE then we use the dense_size field to - // store the size of that dimension. Each index in that dimension is - // stored implicitly. - // - If format is DimensionType.SPARSE_CSR then we use array_segments and - // array_indices to encode that dimension. array_segments represents how - // to segment the indices array, each segment corresponds to one element - // in the previous dimension. array_indices represents the index of the - // non-zero elements within this dimension (as those in the CSR matrix - // format, where the first array is row pointers and the second array is - // column indices). - dense_size:int; - array_segments:SparseIndexVector; - array_indices:SparseIndexVector; -} - -// Parameters to encode a sparse TfLite tensor. -table SparsityParameters { - // The traversal order of the dimensions defined in the `shape` field of the - // conceptual dense tensor. For a n-dimensional tensors with dims (d0, d1, - // ..., dn-1), - // - if not block sparse, the traversal_order is just a permutation of (d0, - // ..., dn-1). For example, a 2-D matrix stored in row-major order would - // have traversal_order = (d0, d1). - // - if block sparse with a k-dimensional block (0 <= k <= n), the - // traversal_order has n + k elements. The first n elements are still a - // permutation of (d0, ..., dn-1). The lask k elements are a permutation - // of (dn, ..., dn+k-1), defining how to traverse a block internally. For - // example, a 2-D matrix with 2-D blocks, both stored in row-major order - // would have traversal_order = (d0, d1, d2, d3). - traversal_order:[int]; - // For an n-dimensional tensor with a k-dimensional block (0 <= k <= n), - // stores how a block dimension in (dn, ..., dn+k-1) maps to the original - // tensor dimension in (d0, ..., dn). - // It's stored in the order of (dn, ..., dn+k-1). - // If not block-sparse, this field is NULL. - block_map:[int]; - // In the traversal order defined above, the metadata needed for - // each dimension to locate the non-zero values in the original dense tensor. - // The size of the dim_metadata array = the size of the traversal_order array - // = n + k. - dim_metadata:[DimensionMetadata]; -} - -table Tensor { - // The tensor shape. The meaning of each entry is operator-specific but - // builtin ops use: [batch size, height, width, number of channels] (That's - // Tensorflow's NHWC). - shape:[int]; - type:TensorType; - // An index that refers to the buffers table at the root of the model. Or, - // if there is no data buffer associated (i.e. intermediate results), then - // this is 0 (which refers to an always existent empty buffer). - // - // The data_buffer itself is an opaque container, with the assumption that the - // target device is little-endian. In addition, all builtin operators assume - // the memory is ordered such that if `shape` is [4, 3, 2], then index - // [i, j, k] maps to data_buffer[i*3*2 + j*2 + k]. - buffer:uint; - name:string; // For debugging and importing back into tensorflow. - quantization:QuantizationParameters; // Optional. - - is_variable:bool = false; - - // Parameters to encode a sparse tensor. See the example in - // tensorflow/lite/testdata/sparse_tensor.json. - sparsity:SparsityParameters; // Optional. - - // Encodes `shape` with unknown dimensions. Unknown dimensions are - // represented with -1. - shape_signature:[int]; // Optional. -} - -// A list of builtin operators. Builtin operators are slightly faster than custom -// ones, but not by much. Moreover, while custom operators accept an opaque -// object containing configuration parameters, builtins have a predetermined -// set of acceptable options. - -enum BuiltinOperator : int32 { - ADD = 0, - AVERAGE_POOL_2D = 1, - CONCATENATION = 2, - CONV_2D = 3, - DEPTHWISE_CONV_2D = 4, - DEPTH_TO_SPACE = 5, - DEQUANTIZE = 6, - EMBEDDING_LOOKUP = 7, - FLOOR = 8, - FULLY_CONNECTED = 9, - HASHTABLE_LOOKUP = 10, - L2_NORMALIZATION = 11, - L2_POOL_2D = 12, - LOCAL_RESPONSE_NORMALIZATION = 13, - LOGISTIC = 14, - LSH_PROJECTION = 15, - LSTM = 16, - MAX_POOL_2D = 17, - MUL = 18, - RELU = 19, - // NOTE(aselle): RELU_N1_TO_1 used to be called RELU1, but it was renamed - // since different model developers use RELU1 in different ways. Never - // create another op called RELU1. - RELU_N1_TO_1 = 20, - RELU6 = 21, - RESHAPE = 22, - RESIZE_BILINEAR = 23, - RNN = 24, - SOFTMAX = 25, - SPACE_TO_DEPTH = 26, - SVDF = 27, - TANH = 28, - CONCAT_EMBEDDINGS = 29, - SKIP_GRAM = 30, - CALL = 31, - CUSTOM = 32, - EMBEDDING_LOOKUP_SPARSE = 33, - PAD = 34, - UNIDIRECTIONAL_SEQUENCE_RNN = 35, - GATHER = 36, - BATCH_TO_SPACE_ND = 37, - SPACE_TO_BATCH_ND = 38, - TRANSPOSE = 39, - MEAN = 40, - SUB = 41, - DIV = 42, - SQUEEZE = 43, - UNIDIRECTIONAL_SEQUENCE_LSTM = 44, - STRIDED_SLICE = 45, - BIDIRECTIONAL_SEQUENCE_RNN = 46, - EXP = 47, - TOPK_V2 = 48, - SPLIT = 49, - LOG_SOFTMAX = 50, - // DELEGATE is a special op type for the operations which are delegated to - // other backends. - // WARNING: Experimental interface, subject to change - DELEGATE = 51, - BIDIRECTIONAL_SEQUENCE_LSTM = 52, - CAST = 53, - PRELU = 54, - MAXIMUM = 55, - ARG_MAX = 56, - MINIMUM = 57, - LESS = 58, - NEG = 59, - PADV2 = 60, - GREATER = 61, - GREATER_EQUAL = 62, - LESS_EQUAL = 63, - SELECT = 64, - SLICE = 65, - SIN = 66, - TRANSPOSE_CONV = 67, - SPARSE_TO_DENSE = 68, - TILE = 69, - EXPAND_DIMS = 70, - EQUAL = 71, - NOT_EQUAL = 72, - LOG = 73, - SUM = 74, - SQRT = 75, - RSQRT = 76, - SHAPE = 77, - POW = 78, - ARG_MIN = 79, - FAKE_QUANT = 80, - REDUCE_PROD = 81, - REDUCE_MAX = 82, - PACK = 83, - LOGICAL_OR = 84, - ONE_HOT = 85, - LOGICAL_AND = 86, - LOGICAL_NOT = 87, - UNPACK = 88, - REDUCE_MIN = 89, - FLOOR_DIV = 90, - REDUCE_ANY = 91, - SQUARE = 92, - ZEROS_LIKE = 93, - FILL = 94, - FLOOR_MOD = 95, - RANGE = 96, - RESIZE_NEAREST_NEIGHBOR = 97, - LEAKY_RELU = 98, - SQUARED_DIFFERENCE = 99, - MIRROR_PAD = 100, - ABS = 101, - SPLIT_V = 102, - UNIQUE = 103, - CEIL = 104, - REVERSE_V2 = 105, - ADD_N = 106, - GATHER_ND = 107, - COS = 108, - WHERE = 109, - RANK = 110, - ELU = 111, - REVERSE_SEQUENCE = 112, - MATRIX_DIAG = 113, - QUANTIZE = 114, - MATRIX_SET_DIAG = 115, - ROUND = 116, - HARD_SWISH = 117, - IF = 118, - WHILE = 119, - NON_MAX_SUPPRESSION_V4 = 120, - NON_MAX_SUPPRESSION_V5 = 121, - SCATTER_ND = 122, - SELECT_V2 = 123, - DENSIFY = 124, - SEGMENT_SUM = 125, - BATCH_MATMUL = 126, - PLACEHOLDER_FOR_GREATER_OP_CODES = 127, - CUMSUM = 128 -} - - -// Options for the builtin operators. -union BuiltinOptions { - Conv2DOptions, - DepthwiseConv2DOptions, - ConcatEmbeddingsOptions, - LSHProjectionOptions, - Pool2DOptions, - SVDFOptions, - RNNOptions, - FullyConnectedOptions, - SoftmaxOptions, - ConcatenationOptions, - AddOptions, - L2NormOptions, - LocalResponseNormalizationOptions, - LSTMOptions, - ResizeBilinearOptions, - CallOptions, - ReshapeOptions, - SkipGramOptions, - SpaceToDepthOptions, - EmbeddingLookupSparseOptions, - MulOptions, - PadOptions, - GatherOptions, - BatchToSpaceNDOptions, - SpaceToBatchNDOptions, - TransposeOptions, - ReducerOptions, - SubOptions, - DivOptions, - SqueezeOptions, - SequenceRNNOptions, - StridedSliceOptions, - ExpOptions, - TopKV2Options, - SplitOptions, - LogSoftmaxOptions, - CastOptions, - DequantizeOptions, - MaximumMinimumOptions, - ArgMaxOptions, - LessOptions, - NegOptions, - PadV2Options, - GreaterOptions, - GreaterEqualOptions, - LessEqualOptions, - SelectOptions, - SliceOptions, - TransposeConvOptions, - SparseToDenseOptions, - TileOptions, - ExpandDimsOptions, - EqualOptions, - NotEqualOptions, - ShapeOptions, - PowOptions, - ArgMinOptions, - FakeQuantOptions, - PackOptions, - LogicalOrOptions, - OneHotOptions, - LogicalAndOptions, - LogicalNotOptions, - UnpackOptions, - FloorDivOptions, - SquareOptions, - ZerosLikeOptions, - FillOptions, - BidirectionalSequenceLSTMOptions, - BidirectionalSequenceRNNOptions, - UnidirectionalSequenceLSTMOptions, - FloorModOptions, - RangeOptions, - ResizeNearestNeighborOptions, - LeakyReluOptions, - SquaredDifferenceOptions, - MirrorPadOptions, - AbsOptions, - SplitVOptions, - UniqueOptions, - ReverseV2Options, - AddNOptions, - GatherNdOptions, - CosOptions, - WhereOptions, - RankOptions, - ReverseSequenceOptions, - MatrixDiagOptions, - QuantizeOptions, - MatrixSetDiagOptions, - HardSwishOptions, - IfOptions, - WhileOptions, - DepthToSpaceOptions, - NonMaxSuppressionV4Options, - NonMaxSuppressionV5Options, - ScatterNdOptions, - SelectV2Options, - DensifyOptions, - SegmentSumOptions, - BatchMatMulOptions, - CumsumOptions, -} - -enum Padding : byte { SAME, VALID } - -enum ActivationFunctionType : byte { - NONE = 0, - RELU = 1, - RELU_N1_TO_1 = 2, - RELU6 = 3, - TANH = 4, - SIGN_BIT = 5, -} - -table Conv2DOptions { - padding:Padding; - stride_w:int; - stride_h:int; - fused_activation_function:ActivationFunctionType; - dilation_w_factor:int = 1; - dilation_h_factor:int = 1; -} - -table Pool2DOptions { - padding:Padding; - stride_w:int; - stride_h:int; - filter_width:int; - filter_height:int; - fused_activation_function:ActivationFunctionType; -} - -table DepthwiseConv2DOptions { - // Parameters for DepthwiseConv version 1 or above. - padding:Padding; - stride_w:int; - stride_h:int; - // `depth_multiplier` is redundant. It's used by CPU kernels in - // TensorFlow 2.0 or below, but ignored in versions above. - // See comments in lite/c/builtin_op_data.h for more details. - depth_multiplier:int; - fused_activation_function:ActivationFunctionType; - // Parameters for DepthwiseConv version 2 or above. - dilation_w_factor:int = 1; - dilation_h_factor:int = 1; -} - -table ConcatEmbeddingsOptions { - num_channels:int; - num_columns_per_channel:[int]; - embedding_dim_per_channel:[int]; // This could be inferred from parameters. -} - -enum LSHProjectionType: byte { - UNKNOWN = 0, - SPARSE = 1, - DENSE = 2, -} - -table LSHProjectionOptions { - type: LSHProjectionType; -} - -table SVDFOptions { - rank:int; - fused_activation_function:ActivationFunctionType; - // For weights-only quantization, use asymmetric quantization for non - // constant inputs at evaluation time. - asymmetric_quantize_inputs:bool; -} - -// An implementation of TensorFlow RNNCell. -table RNNOptions { - fused_activation_function:ActivationFunctionType; - asymmetric_quantize_inputs:bool; -} - -// An implementation of TensorFlow dynamic_rnn with RNNCell. -table SequenceRNNOptions { - time_major:bool; - fused_activation_function:ActivationFunctionType; - asymmetric_quantize_inputs:bool; -} - -// An implementation of TensorFlow bidrectional_dynamic_rnn with RNNCell. -table BidirectionalSequenceRNNOptions { - time_major:bool; - fused_activation_function:ActivationFunctionType; - merge_outputs: bool; - asymmetric_quantize_inputs:bool; -} - -enum FullyConnectedOptionsWeightsFormat: byte { - DEFAULT = 0, - SHUFFLED4x16INT8 = 1, -} - -// An implementation of TensorFlow fully_connected (a.k.a Dense) layer. -table FullyConnectedOptions { - // Parameters for FullyConnected version 1 or above. - fused_activation_function:ActivationFunctionType; - - // Parameters for FullyConnected version 2 or above. - weights_format:FullyConnectedOptionsWeightsFormat = DEFAULT; - - // Parameters for FullyConnected version 5 or above. - // If set to true, then the number of dimension is preserved. Furthermore, - // all but the last dimension of the input and output shapes will be equal. - keep_num_dims: bool; - - // Parameters for FullyConnected version 7 or above. - // If set to true, then weights-only op will use asymmetric quantization for - // inputs. - asymmetric_quantize_inputs: bool; -} - -table SoftmaxOptions { - beta: float; -} - -// An implementation of TensorFlow concat. -table ConcatenationOptions { - axis:int; - fused_activation_function:ActivationFunctionType; -} - -table AddOptions { - fused_activation_function:ActivationFunctionType; - // Parameters supported by version 4. - pot_scale_int16:bool = true; -} - -table MulOptions { - fused_activation_function:ActivationFunctionType; -} - -table L2NormOptions { - fused_activation_function:ActivationFunctionType; -} - -table LocalResponseNormalizationOptions { - radius:int; - bias:float; - alpha:float; - beta:float; -} - -enum LSTMKernelType : byte { - // Full LSTM kernel which supports peephole and projection. - FULL = 0, - // Basic LSTM kernels. Equivalent to TensorFlow BasicLSTMCell. - BASIC = 1, -} - -// An implementation of TensorFlow LSTMCell and CoupledInputForgetGateLSTMCell -table LSTMOptions { - // Parameters for LSTM version 1 or above. - fused_activation_function:ActivationFunctionType; - cell_clip: float; // Optional, 0.0 means no clipping - proj_clip: float; // Optional, 0.0 means no clipping - - // Parameters for LSTM version 2 or above. - // Basic kernel is only supported in version 2 or above. - kernel_type: LSTMKernelType = FULL; - - // Parameters for LSTM version 4 or above. - asymmetric_quantize_inputs: bool; -} - -// An implementation of TensorFlow dynamic_rnn with LSTMCell. -table UnidirectionalSequenceLSTMOptions { - fused_activation_function:ActivationFunctionType; - cell_clip: float; // Optional, 0.0 means no clipping - proj_clip: float; // Optional, 0.0 means no clipping - - // If true then first dimension is sequence, otherwise batch. - time_major:bool; - - // Parameter for Unidirectional Sequence LSTM version 4. - asymmetric_quantize_inputs:bool; -} - -table BidirectionalSequenceLSTMOptions { - // Parameters supported by version 1: - fused_activation_function:ActivationFunctionType; - cell_clip: float; // Optional, 0.0 means no clipping - proj_clip: float; // Optional, 0.0 means no clipping - - // If true, store the outputs of both directions into the first output. - merge_outputs: bool; - - // Parameters supported by version 2: - // If true then first dimension is sequence, otherwise batch. - // Version 1 implementations assumed time_major to be true, so this default - // value should never change. - time_major: bool = true; - - // Parameters for version 3 or above. - asymmetric_quantize_inputs:bool; -} - -table ResizeBilinearOptions { - new_height: int (deprecated); - new_width: int (deprecated); - align_corners: bool; - half_pixel_centers: bool; -} - -table ResizeNearestNeighborOptions { - align_corners: bool; - half_pixel_centers: bool; -} - -// A call operation options -table CallOptions { - // The subgraph index that needs to be called. - subgraph:uint; -} - -table PadOptions { -} - -table PadV2Options { -} - -table ReshapeOptions { - new_shape:[int]; -} - -table SpaceToBatchNDOptions { -} - -table BatchToSpaceNDOptions { -} - -table SkipGramOptions { - ngram_size: int; - max_skip_size: int; - include_all_ngrams: bool; -} - -table SpaceToDepthOptions { - block_size: int; -} - -table DepthToSpaceOptions { - block_size: int; -} - -table SubOptions { - fused_activation_function:ActivationFunctionType; - // Parameters supported by version 5 - pot_scale_int16:bool = true; -} - -table DivOptions { - fused_activation_function:ActivationFunctionType; -} - -table TopKV2Options { -} - -enum CombinerType : byte { - SUM = 0, - MEAN = 1, - SQRTN = 2, -} - -table EmbeddingLookupSparseOptions { - combiner:CombinerType; -} - -table GatherOptions { - axis: int; -} - -table TransposeOptions { -} - -table ExpOptions { -} - -table CosOptions { -} - -table ReducerOptions { - keep_dims: bool; -} - -table SqueezeOptions { - squeeze_dims:[int]; -} - -table SplitOptions { - num_splits: int; -} - -table SplitVOptions { - num_splits: int; -} - -table StridedSliceOptions { - begin_mask: int; - end_mask: int; - ellipsis_mask: int; - new_axis_mask: int; - shrink_axis_mask: int; -} - -table LogSoftmaxOptions { -} - -table CastOptions { - in_data_type: TensorType; - out_data_type: TensorType; -} - -table DequantizeOptions { -} - -table MaximumMinimumOptions { -} - -table TileOptions { -} - -table ArgMaxOptions { - output_type : TensorType; -} - -table ArgMinOptions { - output_type : TensorType; -} - -table GreaterOptions { -} - -table GreaterEqualOptions { -} - -table LessOptions { -} - -table LessEqualOptions { -} - -table NegOptions { -} - -table SelectOptions { -} - -table SliceOptions { -} - -table TransposeConvOptions { - padding:Padding; - stride_w:int; - stride_h:int; -} - -table ExpandDimsOptions { -} - -table SparseToDenseOptions { - validate_indices:bool; -} - -table EqualOptions { -} - -table NotEqualOptions { -} - -table ShapeOptions { - // Optional output type of the operation (int32 or int64). Defaults to int32. - out_type : TensorType; -} - -table RankOptions { -} - -table PowOptions { -} - -table FakeQuantOptions { - // Parameters supported by version 1: - min:float; - max:float; - num_bits:int; - - // Parameters supported by version 2: - narrow_range:bool; -} - -table PackOptions { - values_count:int; - axis:int; -} - -table LogicalOrOptions { -} - -table OneHotOptions { - axis:int; -} - -table AbsOptions { -} - - -table HardSwishOptions { -} - -table LogicalAndOptions { -} - -table LogicalNotOptions { -} - -table UnpackOptions { - num:int; - axis:int; -} - -table FloorDivOptions { -} - -table SquareOptions { -} - -table ZerosLikeOptions { -} - -table FillOptions { -} - -table FloorModOptions { -} - -table RangeOptions { -} - -table LeakyReluOptions { - alpha:float; -} - -table SquaredDifferenceOptions { -} - -enum MirrorPadMode : byte { - // Doesn't include borders. - REFLECT = 0, - // Includes borders. - SYMMETRIC = 1, -} - -table MirrorPadOptions { - mode:MirrorPadMode; -} - -table UniqueOptions { - idx_out_type:TensorType = INT32; -} - -table ReverseV2Options { -} - -table AddNOptions { -} - -table GatherNdOptions { -} - -table WhereOptions { -} - -table ReverseSequenceOptions { - seq_dim:int; - batch_dim:int = 0; -} - -table MatrixDiagOptions { -} - -table QuantizeOptions { -} - -table MatrixSetDiagOptions { -} - -table IfOptions { - then_subgraph_index:int; - else_subgraph_index:int; -} - -table WhileOptions { - cond_subgraph_index:int; - body_subgraph_index:int; -} - -table NonMaxSuppressionV4Options { -} - -table NonMaxSuppressionV5Options { -} - -table ScatterNdOptions { -} - -table SelectV2Options { -} - -table DensifyOptions { -} - -table SegmentSumOptions { -} - -table BatchMatMulOptions { - adj_x:bool; - adj_y:bool; -} - -table CumsumOptions { - exclusive:bool; - reverse:bool; -} - -// An OperatorCode can be an enum value (BuiltinOperator) if the operator is a -// builtin, or a string if the operator is custom. -table OperatorCode { - // This field is for backward compatibility. This field will be used when - // the value of the extended builtin_code field has less than - // BulitinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES. - deprecated_builtin_code:byte; - custom_code:string; - - // The version of the operator. The version need to be bumped whenever new - // parameters are introduced into an op. - version:int = 1; - - // This field is introduced for resolving op builtin code shortage problem - // (the original BuiltinOperator enum field was represented as a byte). - // This field will be used when the value of the extended builtin_code field - // has greater than BulitinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES. - builtin_code:BuiltinOperator; -} - -enum CustomOptionsFormat : byte { - FLEXBUFFERS = 0, -} - -// An operator takes tensors as inputs and outputs. The type of operation being -// performed is determined by an index into the list of valid OperatorCodes, -// while the specifics of each operations is configured using builtin_options -// or custom_options. -table Operator { - // Index into the operator_codes array. Using an integer here avoids - // complicate map lookups. - opcode_index:uint; - - // Optional input are indicated by -1. - inputs:[int]; - outputs:[int]; - - builtin_options:BuiltinOptions; - custom_options:[ubyte]; - custom_options_format:CustomOptionsFormat; - - // A list of booleans indicating the input tensors which are being mutated by - // this operator.(e.g. used by RNN and LSTM). - // For example, if the "inputs" array refers to 5 tensors and the second and - // fifth are mutable variables, then this list will contain - // [false, true, false, false, true]. - // - // If the list is empty, no variable is mutated in this operator. - // The list either has the same length as `inputs`, or is empty. - mutating_variable_inputs:[bool]; - - // A list of indices to the subgraph's "tensors" that are internal to an Op. - // Internal tensors are those that do not flow in or out of the operation, - // but instead are part of internal computation. As such, the operation's - // implementation may manage its memory more efficiently. They are needed - // however (i.e. not just an implementation detail) since they are part of the - // computation, which may require relevant metadata such as quantization - // parameters. - intermediates:[int]; -} - -// The root type, defining a subgraph, which typically represents an entire -// model. -table SubGraph { - // A list of all tensors used in this subgraph. - tensors:[Tensor]; - - // Indices of the tensors that are inputs into this subgraph. Note this is - // the list of non-static tensors that feed into the subgraph for inference. - inputs:[int]; - - // Indices of the tensors that are outputs out of this subgraph. Note this is - // the list of output tensors that are considered the product of the - // subgraph's inference. - outputs:[int]; - - // All operators, in execution order. - operators:[Operator]; - - // Name of this subgraph (used for debugging). - name:string; -} - -// Table of raw data buffers (used for constant tensors). Referenced by tensors -// by index. The generous alignment accommodates mmap-friendly data structures. -table Buffer { - data:[ubyte] (force_align: 16); -} - -table Metadata { - // A human readable string to uniquely identify a Metadata. - name:string; - // An index to the buffers table. - buffer:uint; -} - -// Map from an alias name of tensor to tensor index in the graph. -// This is used in Signature def. -table TensorMap { - // Represents the alias to use for this tensor. - name:string; - - // The actual tensor index in the primary graph, that 'name' corresponds to. - tensor_index:uint; -} - -// This corresponds to SignatureDef in Tensorflow SavedModel. -// The SignatureDef will be part of the SavedModel provided for conversion. -table SignatureDef { - // Named inputs for this signature. - inputs:[TensorMap]; - - // Named outputs for this signature. - outputs:[TensorMap]; - - // Exported method name for this signature. - method_name:string; - - // Key value which was in the Tensorflow SavedModel SignatureDef map. - key:string; -} - -table Model { - // Version of the schema. - version:uint; - - // A list of all operator codes used in this model. This is - // kept in order because operators carry an index into this - // vector. - operator_codes:[OperatorCode]; - - // All the subgraphs of the model. The 0th is assumed to be the main - // model. - subgraphs:[SubGraph]; - - // A description of the model. - description:string; - - // Buffers of the model. - // Note the 0th entry of this array must be an empty buffer (sentinel). - // This is a convention so that tensors without a buffer can provide 0 as - // their buffer. - buffers:[Buffer]; - - // Metadata about the model. Indirects into the existings buffers list. - // Deprecated, prefer to use metadata field. - metadata_buffer:[int]; - - // Metadata about the model. - metadata:[Metadata]; - - // Optional SignatureDefs for the model. - signature_defs:[SignatureDef]; -} - -root_type Model; diff --git a/third_party/proto/tensorflow/node_def.proto b/third_party/proto/tensorflow/node_def.proto deleted file mode 100644 index 17d8ecf6..00000000 --- a/third_party/proto/tensorflow/node_def.proto +++ /dev/null @@ -1,88 +0,0 @@ -syntax = "proto3"; - -package tensorflow; - -import "attr_value.proto"; - -option cc_enable_arenas = true; -option java_outer_classname = "NodeProto"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/node_def_go_proto"; - -message NodeDef { - // The name given to this operator. Used for naming inputs, - // logging, visualization, etc. Unique within a single GraphDef. - // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_>./]*". - string name = 1; - - // The operation name. There may be custom parameters in attrs. - // Op names starting with an underscore are reserved for internal use. - string op = 2; - - // Each input is "node:src_output" with "node" being a string name and - // "src_output" indicating which output tensor to use from "node". If - // "src_output" is 0 the ":0" suffix can be omitted. Regular inputs - // may optionally be followed by control inputs that have the format - // "^node". - repeated string input = 3; - - // A (possibly partial) specification for the device on which this - // node should be placed. - // The expected syntax for this string is as follows: - // - // DEVICE_SPEC ::= PARTIAL_SPEC - // - // PARTIAL_SPEC ::= ("/" CONSTRAINT) * - // CONSTRAINT ::= ("job:" JOB_NAME) - // | ("replica:" [1-9][0-9]*) - // | ("task:" [1-9][0-9]*) - // | ("device:" [A-Za-z]* ":" ([1-9][0-9]* | "*") ) - // - // Valid values for this string include: - // * "/job:worker/replica:0/task:1/device:GPU:3" (full specification) - // * "/job:worker/device:GPU:3" (partial specification) - // * "" (no specification) - // - // If the constraints do not resolve to a single device (or if this - // field is empty or not present), the runtime will attempt to - // choose a device automatically. - string device = 4; - - // Operation-specific graph-construction-time configuration. - // Note that this should include all attrs defined in the - // corresponding OpDef, including those with a value matching - // the default -- this allows the default to change and makes - // NodeDefs easier to interpret on their own. However, if - // an attr with a default is not specified in this list, the - // default will be used. - // The "names" (keys) must match the regexp "[a-z][a-z0-9_]+" (and - // one of the names from the corresponding OpDef's attr field). - // The values must have a type matching the corresponding OpDef - // attr's type field. - // TODO(josh11b): Add some examples here showing best practices. - map attr = 5; - - message ExperimentalDebugInfo { - // Opaque string inserted into error messages created by the runtime. - // - // This is intended to store the list of names of the nodes from the - // original graph that this node was derived. For example if this node, say - // C, was result of a fusion of 2 nodes A and B, then 'original_node' would - // be {A, B}. This information can be used to map errors originating at the - // current node to some top level source code. - repeated string original_node_names = 1; - - // This is intended to store the list of names of the functions from the - // original graph that this node was derived. For example if this node, say - // C, was result of a fusion of node A in function FA and node B in function - // FB, then `original_funcs` would be {FA, FB}. If the node is in the top - // level graph, the `original_func` is empty. This information, with the - // `original_node_names` can be used to map errors originating at the - // current ndoe to some top level source code. - repeated string original_func_names = 2; - } - - // This stores debug information associated with the node. - ExperimentalDebugInfo experimental_debug_info = 6; -} diff --git a/third_party/proto/tensorflow/op_def.proto b/third_party/proto/tensorflow/op_def.proto deleted file mode 100644 index 3b2396cb..00000000 --- a/third_party/proto/tensorflow/op_def.proto +++ /dev/null @@ -1,170 +0,0 @@ -syntax = "proto3"; - -package tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "OpDefProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/op_def_go_proto"; -import "attr_value.proto"; -import "types.proto"; - -// Defines an operation. A NodeDef in a GraphDef specifies an Op by -// using the "op" field which should match the name of a OpDef. -// LINT.IfChange -message OpDef { - // Op names starting with an underscore are reserved for internal use. - // Names should be CamelCase and match the regexp "[A-Z][a-zA-Z0-9>_]*". - string name = 1; - - // For describing inputs and outputs. - message ArgDef { - // Name for the input/output. Should match the regexp "[a-z][a-z0-9_]*". - string name = 1; - - // Human readable description. - string description = 2; - - // Describes the type of one or more tensors that are accepted/produced - // by this input/output arg. The only legal combinations are: - // * For a single tensor: either the "type" field is set or the - // "type_attr" field is set to the name of an attr with type "type". - // * For a sequence of tensors with the same type: the "number_attr" - // field will be set to the name of an attr with type "int", and - // either the "type" or "type_attr" field will be set as for - // single tensors. - // * For a sequence of tensors, the "type_list_attr" field will be set - // to the name of an attr with type "list(type)". - DataType type = 3; - string type_attr = 4; // if specified, attr must have type "type" - string number_attr = 5; // if specified, attr must have type "int" - // If specified, attr must have type "list(type)", and none of - // type, type_attr, and number_attr may be specified. - string type_list_attr = 6; - - // For inputs: if true, the inputs are required to be refs. - // By default, inputs can be either refs or non-refs. - // For outputs: if true, outputs are refs, otherwise they are not. - bool is_ref = 16; - }; - - // Description of the input(s). - repeated ArgDef input_arg = 2; - - // Description of the output(s). - repeated ArgDef output_arg = 3; - - // Named control outputs for this operation. Useful only for composite - // operations (i.e. functions) which want to name different control outputs. - repeated string control_output = 20; - - // Description of the graph-construction-time configuration of this - // Op. That is to say, this describes the attr fields that will - // be specified in the NodeDef. - message AttrDef { - // A descriptive name for the argument. May be used, e.g. by the - // Python client, as a keyword argument name, and so should match - // the regexp "[a-z][a-z0-9_]+". - string name = 1; - - // One of the type names from attr_value.proto ("string", "list(string)", - // "int", etc.). - string type = 2; - - // A reasonable default for this attribute if the user does not supply - // a value. If not specified, the user must supply a value. - AttrValue default_value = 3; - - // Human-readable description. - string description = 4; - - // TODO(josh11b): bool is_optional? - - // --- Constraints --- - // These constraints are only in effect if specified. Default is no - // constraints. - - // For type == "int", this is a minimum value. For "list(___)" - // types, this is the minimum length. - bool has_minimum = 5; - int64 minimum = 6; - - // The set of allowed values. Has type that is the "list" version - // of the "type" field above (uses the "list" field of AttrValue). - // If type == "type" or "list(type)" above, then the "type" field - // of "allowed_values.list" has the set of allowed DataTypes. - // If type == "string" or "list(string)", then the "s" field of - // "allowed_values.list" has the set of allowed strings. - AttrValue allowed_values = 7; - } - repeated AttrDef attr = 4; - - // Optional deprecation based on GraphDef versions. - OpDeprecation deprecation = 8; - - // One-line human-readable description of what the Op does. - string summary = 5; - - // Additional, longer human-readable description of what the Op does. - string description = 6; - - // ------------------------------------------------------------------------- - // Which optimizations this operation can participate in. - - // True if the operation is commutative ("op(a,b) == op(b,a)" for all inputs) - bool is_commutative = 18; - - // If is_aggregate is true, then this operation accepts N >= 2 - // inputs and produces 1 output all of the same type. Should be - // associative and commutative, and produce output with the same - // shape as the input. The optimizer may replace an aggregate op - // taking input from multiple devices with a tree of aggregate ops - // that aggregate locally within each device (and possibly within - // groups of nearby devices) before communicating. - // TODO(josh11b): Implement that optimization. - bool is_aggregate = 16; // for things like add - - // Other optimizations go here, like - // can_alias_input, rewrite_when_output_unused, partitioning_strategy, etc. - - // ------------------------------------------------------------------------- - // Optimization constraints. - - // Ops are marked as stateful if their behavior depends on some state beyond - // their input tensors (e.g. variable reading op) or if they have - // a side-effect (e.g. printing or asserting ops). Equivalently, stateless ops - // must always produce the same output for the same input and have - // no side-effects. - // - // By default Ops may be moved between devices. Stateful ops should - // either not be moved, or should only be moved if that state can also - // be moved (e.g. via some sort of save / restore). - // Stateful ops are guaranteed to never be optimized away by Common - // Subexpression Elimination (CSE). - bool is_stateful = 17; // for things like variables, queue - - // ------------------------------------------------------------------------- - // Non-standard options. - - // By default, all inputs to an Op must be initialized Tensors. Ops - // that may initialize tensors for the first time should set this - // field to true, to allow the Op to take an uninitialized Tensor as - // input. - bool allows_uninitialized_input = 19; // for Assign, etc. -}; -// LINT.ThenChange( -// https://www.tensorflow.org/code/tensorflow/core/framework/op_def_util.cc) - -// Information about version-dependent deprecation of an op -message OpDeprecation { - // First GraphDef version at which the op is disallowed. - int32 version = 1; - - // Explanation of why it was deprecated and what to use instead. - string explanation = 2; -}; - -// A collection of OpDefs -message OpList { - repeated OpDef op = 1; -}; diff --git a/third_party/proto/tensorflow/resource_handle.proto b/third_party/proto/tensorflow/resource_handle.proto deleted file mode 100644 index e2bce956..00000000 --- a/third_party/proto/tensorflow/resource_handle.proto +++ /dev/null @@ -1,45 +0,0 @@ -syntax = "proto3"; - -package tensorflow; - -import "tensor_shape.proto"; -import "types.proto"; - -option cc_enable_arenas = true; -option java_outer_classname = "ResourceHandle"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/resource_handle_go_proto"; - -// Protocol buffer representing a handle to a tensorflow resource. Handles are -// not valid across executions, but can be serialized back and forth from within -// a single run. -message ResourceHandleProto { - // Unique name for the device containing the resource. - string device = 1; - - // Container in which this resource is placed. - string container = 2; - - // Unique name of this resource. - string name = 3; - - // Hash code for the type of the resource. Is only valid in the same device - // and in the same execution. - uint64 hash_code = 4; - - // For debug-only, the name of the type pointed to by this handle, if - // available. - string maybe_type_name = 5; - - // Protocol buffer representing a pair of (data type, tensor shape). - message DtypeAndShape { - DataType dtype = 1; - TensorShapeProto shape = 2; - } - - // Data types and shapes for the underlying resource. - repeated DtypeAndShape dtypes_and_shapes = 6; - - reserved 7; -} diff --git a/third_party/proto/tensorflow/tensor.proto b/third_party/proto/tensorflow/tensor.proto deleted file mode 100644 index 7a25c446..00000000 --- a/third_party/proto/tensorflow/tensor.proto +++ /dev/null @@ -1,96 +0,0 @@ -syntax = "proto3"; - -package tensorflow; - -import "resource_handle.proto"; -import "tensor_shape.proto"; -import "types.proto"; - -option cc_enable_arenas = true; -option java_outer_classname = "TensorProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_go_proto"; - -// Protocol buffer representing a tensor. -message TensorProto { - DataType dtype = 1; - - // Shape of the tensor. TODO(touts): sort out the 0-rank issues. - TensorShapeProto tensor_shape = 2; - - // Only one of the representations below is set, one of "tensor_contents" and - // the "xxx_val" attributes. We are not using oneof because as oneofs cannot - // contain repeated fields it would require another extra set of messages. - - // Version number. - // - // In version 0, if the "repeated xxx" representations contain only one - // element, that element is repeated to fill the shape. This makes it easy - // to represent a constant Tensor with a single value. - int32 version_number = 3; - - // Serialized raw tensor content from either Tensor::AsProtoTensorContent or - // memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation - // can be used for all tensor types. The purpose of this representation is to - // reduce serialization overhead during RPC call by avoiding serialization of - // many repeated small items. - bytes tensor_content = 4; - - // Type specific representations that make it easy to create tensor protos in - // all languages. Only the representation corresponding to "dtype" can - // be set. The values hold the flattened representation of the tensor in - // row major order. - - // DT_HALF, DT_BFLOAT16. Note that since protobuf has no int16 type, we'll - // have some pointless zero padding for each value here. - repeated int32 half_val = 13 [packed = true]; - - // DT_FLOAT. - repeated float float_val = 5 [packed = true]; - - // DT_DOUBLE. - repeated double double_val = 6 [packed = true]; - - // DT_INT32, DT_INT16, DT_INT8, DT_UINT8. - repeated int32 int_val = 7 [packed = true]; - - // DT_STRING - repeated bytes string_val = 8; - - // DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real - // and imaginary parts of i-th single precision complex. - repeated float scomplex_val = 9 [packed = true]; - - // DT_INT64 - repeated int64 int64_val = 10 [packed = true]; - - // DT_BOOL - repeated bool bool_val = 11 [packed = true]; - - // DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real - // and imaginary parts of i-th double precision complex. - repeated double dcomplex_val = 12 [packed = true]; - - // DT_RESOURCE - repeated ResourceHandleProto resource_handle_val = 14; - - // DT_VARIANT - repeated VariantTensorDataProto variant_val = 15; - - // DT_UINT32 - repeated uint32 uint32_val = 16 [packed = true]; - - // DT_UINT64 - repeated uint64 uint64_val = 17 [packed = true]; -} - -// Protocol buffer representing the serialization format of DT_VARIANT tensors. -message VariantTensorDataProto { - // Name of the type of objects being serialized. - string type_name = 1; - // Portions of the object that are not Tensors. - bytes metadata = 2; - // Tensors contained within objects being serialized. - repeated TensorProto tensors = 3; -} diff --git a/third_party/proto/tensorflow/tensor_shape.proto b/third_party/proto/tensorflow/tensor_shape.proto deleted file mode 100644 index 45d5b78e..00000000 --- a/third_party/proto/tensorflow/tensor_shape.proto +++ /dev/null @@ -1,46 +0,0 @@ -// Protocol buffer representing the shape of tensors. - -syntax = "proto3"; -option cc_enable_arenas = true; -option java_outer_classname = "TensorShapeProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_shape_go_proto"; - -package tensorflow; - -// Dimensions of a tensor. -message TensorShapeProto { - // One dimension of the tensor. - message Dim { - // Size of the tensor in that dimension. - // This value must be >= -1, but values of -1 are reserved for "unknown" - // shapes (values of -1 mean "unknown" dimension). Certain wrappers - // that work with TensorShapeProto may fail at runtime when deserializing - // a TensorShapeProto containing a dim value of -1. - int64 size = 1; - - // Optional name of the tensor dimension. - string name = 2; - }; - - // Dimensions of the tensor, such as {"input", 30}, {"output", 40} - // for a 30 x 40 2D tensor. If an entry has size -1, this - // corresponds to a dimension of unknown size. The names are - // optional. - // - // The order of entries in "dim" matters: It indicates the layout of the - // values in the tensor in-memory representation. - // - // The first entry in "dim" is the outermost dimension used to layout the - // values, the last entry is the innermost dimension. This matches the - // in-memory layout of RowMajor Eigen tensors. - // - // If "dim.size()" > 0, "unknown_rank" must be false. - repeated Dim dim = 2; - - // If true, the number of dimensions in the shape is unknown. - // - // If true, "dim.size()" must be 0. - bool unknown_rank = 3; -}; diff --git a/third_party/proto/tensorflow/types.proto b/third_party/proto/tensorflow/types.proto deleted file mode 100644 index 61549ae0..00000000 --- a/third_party/proto/tensorflow/types.proto +++ /dev/null @@ -1,87 +0,0 @@ -syntax = "proto3"; - -package tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "TypesProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/types_go_proto"; - -// (== suppress_warning documentation-presence ==) -// LINT.IfChange -enum DataType { - // Not a legal value for DataType. Used to indicate a DataType field - // has not been set. - DT_INVALID = 0; - - // Data types that all computation devices are expected to be - // capable to support. - DT_FLOAT = 1; - DT_DOUBLE = 2; - DT_INT32 = 3; - DT_UINT8 = 4; - DT_INT16 = 5; - DT_INT8 = 6; - DT_STRING = 7; - DT_COMPLEX64 = 8; // Single-precision complex - DT_INT64 = 9; - DT_BOOL = 10; - DT_QINT8 = 11; // Quantized int8 - DT_QUINT8 = 12; // Quantized uint8 - DT_QINT32 = 13; // Quantized int32 - DT_BFLOAT16 = 14; // Float32 truncated to 16 bits. Only for cast ops. - DT_QINT16 = 15; // Quantized int16 - DT_QUINT16 = 16; // Quantized uint16 - DT_UINT16 = 17; - DT_COMPLEX128 = 18; // Double-precision complex - DT_HALF = 19; - DT_RESOURCE = 20; - DT_VARIANT = 21; // Arbitrary C++ data types - DT_UINT32 = 22; - DT_UINT64 = 23; - - // Do not use! These are only for parameters. Every enum above - // should have a corresponding value below (verified by types_test). - DT_FLOAT_REF = 101; - DT_DOUBLE_REF = 102; - DT_INT32_REF = 103; - DT_UINT8_REF = 104; - DT_INT16_REF = 105; - DT_INT8_REF = 106; - DT_STRING_REF = 107; - DT_COMPLEX64_REF = 108; - DT_INT64_REF = 109; - DT_BOOL_REF = 110; - DT_QINT8_REF = 111; - DT_QUINT8_REF = 112; - DT_QINT32_REF = 113; - DT_BFLOAT16_REF = 114; - DT_QINT16_REF = 115; - DT_QUINT16_REF = 116; - DT_UINT16_REF = 117; - DT_COMPLEX128_REF = 118; - DT_HALF_REF = 119; - DT_RESOURCE_REF = 120; - DT_VARIANT_REF = 121; - DT_UINT32_REF = 122; - DT_UINT64_REF = 123; -} -// LINT.ThenChange( -// https://www.tensorflow.org/code/tensorflow/c/tf_datatype.h, -// https://www.tensorflow.org/code/tensorflow/go/tensor.go, -// https://www.tensorflow.org/code/tensorflow/core/framework/tensor.cc, -// https://www.tensorflow.org/code/tensorflow/core/framework/types.h, -// https://www.tensorflow.org/code/tensorflow/core/framework/types.cc, -// https://www.tensorflow.org/code/tensorflow/python/framework/dtypes.py, -// https://www.tensorflow.org/code/tensorflow/python/framework/function.py) - -// For identifying the underlying type of a variant. For variants, the types -// listed here are a subset of the types in the variant type registry, -// corresponding to commonly used variants which must occasionally be -// special-cased. -enum SpecializedType { - // Invalid/unknown specialized type. - ST_INVALID = 0; - // "tensorflow::TensorList" in the variant type registry. - ST_TENSOR_LIST = 1; -} \ No newline at end of file diff --git a/third_party/proto/tensorflow/versions.proto b/third_party/proto/tensorflow/versions.proto deleted file mode 100644 index 2cca6e37..00000000 --- a/third_party/proto/tensorflow/versions.proto +++ /dev/null @@ -1,33 +0,0 @@ -syntax = "proto3"; - -package tensorflow; - -option cc_enable_arenas = true; -option java_outer_classname = "VersionsProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; -option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/versions_go_proto"; - -// Version information for a piece of serialized data -// -// There are different types of versions for each type of data -// (GraphDef, etc.), but they all have the same common shape -// described here. -// -// Each consumer has "consumer" and "min_producer" versions (specified -// elsewhere). A consumer is allowed to consume this data if -// -// producer >= min_producer -// consumer >= min_consumer -// consumer not in bad_consumers -// -message VersionDef { - // The version of the code that produced this data. - int32 producer = 1; - - // Any consumer below this version is not allowed to consume this data. - int32 min_consumer = 2; - - // Specific consumer versions which are disallowed (e.g. due to bugs). - repeated int32 bad_consumers = 3; -} -- Gitee