Skip to content

Commit

Permalink
Remove coremltools submodule *security vulnerability* and copy the co…
Browse files Browse the repository at this point in the history
…reml model schema (#10424)

* remove coremltools submodule

* update cgmanifest

* Copy proto files directly from coremltools
  • Loading branch information
guoyu-wang authored Jan 28, 2022
1 parent c4f1dfc commit 5f0ba31
Show file tree
Hide file tree
Showing 35 changed files with 8,912 additions and 84 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@
[submodule "cmake/external/mp11"]
path = cmake/external/mp11
url = https://github.com/boostorg/mp11.git
[submodule "cmake/external/coremltools"]
path = cmake/external/coremltools
url = https://github.com/apple/coremltools.git
[submodule "cmake/external/dlpack"]
path = cmake/external/dlpack
url = https://github.com/dmlc/dlpack.git
Expand Down
88 changes: 9 additions & 79 deletions cgmanifests/generated/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,6 @@
"comments": "git submodule at cmake/external/SafeInt/safeint"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "523d5e03d86c26267ee6bdf17dd20f6ce6bdadd7",
"repositoryUrl": "https://github.com/apple/coremltools.git"
},
"comments": "git submodule at cmake/external/coremltools"
}
},
{
"component": {
"type": "git",
Expand Down Expand Up @@ -174,7 +164,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "a3d65c80d32c3e584b7aab41d516a0043b2a5e84",
"commitHash": "3acac70a551c321574732e5bfd67930244bb7151",
"repositoryUrl": "https://github.com/emscripten-core/emsdk.git"
},
"comments": "git submodule at cmake/external/emsdk"
Expand Down Expand Up @@ -215,7 +205,7 @@
"type": "git",
"git": {
"commitHash": "db78ac1d7716f56fc9f1b030b715f872f93964e4",
"repositoryUrl": "https://github.com/nlohmann/json"
"repositoryUrl": "https://github.com/nlohmann/json.git"
},
"comments": "git submodule at cmake/external/json"
}
Expand All @@ -234,7 +224,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "2d54553b7a78c7c35620b827e7e5ab2228ecb495",
"commitHash": "f412df7a2b64421e1f1d61fde6055a6ea288e8f5",
"repositoryUrl": "https://github.com/microsoft/mimalloc.git"
},
"comments": "git submodule at cmake/external/mimalloc"
Expand All @@ -255,7 +245,7 @@
"type": "git",
"git": {
"commitHash": "436617053d0f39a1019a371c3a9aa599b3cb2cea",
"repositoryUrl": "https://github.com/google/nsync"
"repositoryUrl": "https://github.com/google/nsync.git"
},
"comments": "git submodule at cmake/external/nsync"
}
Expand All @@ -265,7 +255,7 @@
"type": "git",
"git": {
"commitHash": "be76ca7148396176784ba8733133b9fb1186ea0d",
"repositoryUrl": "https://github.com/onnx/onnx"
"repositoryUrl": "https://github.com/onnx/onnx.git"
},
"comments": "git submodule at cmake/external/onnx"
}
Expand Down Expand Up @@ -294,7 +284,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "1f416bb462689f3ef9e3f1057a113d9c6aba6972",
"commitHash": "e9456d57605c883cdf985e634ab483e2c1500bb1",
"repositoryUrl": "https://github.com/onnx/onnx-tensorrt.git"
},
"comments": "git submodule at cmake/external/onnx-tensorrt"
Expand All @@ -304,7 +294,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "553df22c67bee5f0fe6599cff60f1afc6748c635",
"commitHash": "994c6181247d7b419b28889fc57d5817e2089419",
"repositoryUrl": "https://github.com/onnx/onnx.git"
},
"comments": "git submodule at cmake/external/onnx-tensorrt/third_party/onnx"
Expand All @@ -324,22 +314,12 @@
"component": {
"type": "git",
"git": {
"commitHash": "09f082940113661256310e3f4811aa7261a9fa05",
"commitHash": "59a2ac2745d8a57ac94c6accced73620d59fb844",
"repositoryUrl": "https://github.com/pybind/pybind11.git"
},
"comments": "git submodule at cmake/external/onnx-tensorrt/third_party/onnx/third_party/pybind11"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "6a00cbc4a9b8e68b71caf7f774b3f9c753ae84d5",
"repositoryUrl": "https://github.com/wjakob/clang-cindex-python3"
},
"comments": "git submodule at cmake/external/onnx-tensorrt/third_party/onnx/third_party/pybind11/tools/clang"
}
},
{
"component": {
"type": "git",
Expand Down Expand Up @@ -410,62 +390,12 @@
"comments": "git submodule at cmake/external/tensorboard"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "9ec2b92d180dff8877e402018b97baa574031b8b",
"repositoryUrl": "https://github.com/microsoft/onnxruntime-tvm.git"
},
"comments": "git submodule at cmake/external/tvm"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "b257a9221ee1e5180d994b3488ddcc259b0ac157",
"repositoryUrl": "https://github.com/dmlc/HalideIR"
},
"comments": "git submodule at cmake/external/tvm/3rdparty/HalideIR"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "5c792cef3aee54ad8b7000111c9dc1797f327b59",
"repositoryUrl": "https://github.com/dmlc/dlpack"
},
"comments": "git submodule at cmake/external/tvm/3rdparty/dlpack"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "d07fb7a443b5db8a89d65a15a024af6a425615a5",
"repositoryUrl": "https://github.com/dmlc/dmlc-core"
},
"comments": "git submodule at cmake/external/tvm/3rdparty/dmlc-core"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "cabe04d6d6b05356fa8f9741704924788f0dd762",
"repositoryUrl": "https://github.com/agauniyal/rang"
},
"comments": "git submodule at cmake/external/tvm/3rdparty/rang"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "e8c599bca6c56c44b6730ad93f6abbc9ecd60fc1",
"repositoryUrl": "https://github.com/microsoft/wil"
"repositoryUrl": "https://github.com/microsoft/wil.git"
},
"comments": "git submodule at cmake/external/wil"
}
Expand Down
1 change: 0 additions & 1 deletion cmake/external/coremltools
Submodule coremltools deleted from 523d5e
2 changes: 1 addition & 1 deletion cmake/onnxruntime_providers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ if (onnxruntime_USE_COREML)

# Compile CoreML proto definition to ${CMAKE_CURRENT_BINARY_DIR}/coreml
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(COREML_PROTO_ROOT ${PROJECT_SOURCE_DIR}/external/coremltools/mlmodel/format)
set(COREML_PROTO_ROOT ${PROJECT_SOURCE_DIR}/../onnxruntime/core/providers/coreml/mlmodel_format)
file(GLOB coreml_proto_srcs
"${COREML_PROTO_ROOT}/*.proto"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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;

/**
* An array feature extractor.
*
* Given an index, extracts the value at that index from its array input.
* Indexes are zero-based.
*/
message ArrayFeatureExtractor {
repeated uint64 extractIndex = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// 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;

/**
* A Bayesian probit regressor.
*
* The probit regression model is superficially similar to the more commonly known
* logistic regression, with sampling distribution of the model given by
*
* P(y=+1|x,w) = Φ(<w,x>/β)
*
* where w are the set of weights,
* x are the set of features for the given event,
* β is a model hyper-parameter, and
* Φ is the link function, defined to be the CDF of the normal distribution.
* The weights w[i,j] are Gaussian distributed, with mean μ[i,j] and precision 1/(σ[i,j])^2
* (where i indexes over features and j indexes over the values for the feature).
* The parameter β scales the steepness of the inverse link function.
*
* (see https://en.wikipedia.org/wiki/Probit_model and https://en.wikipedia.org/wiki/Logistic_regression
* for more details on probit model and logistic regression, respectively)
*
* Input: X
* x represents a set of features, each taking on a discrete value (note that continuous values
* would first need to be discretized). x can be represented as a vector where the index i is
* the feature id and x[i] is the feature value. Alternatively, x can be represented as a matrix
* with 2 columns where the first column indicates the feature id and the second column contains
* the feature values, i.e. x[i,0] is the feature id and x[i,1] is the feature value.
*
* additional input features:
* - "optimism": apply a mean shift to the probability, i.e. shift regression mean by o*stdev,
* where o is the "optimism" parameter (see additional output features)
* - "samplingScale": for sampling from posterior, multiply standard deviation by this factor
* - "samplingTruncation": for sampling from posterior, truncate sampling distribution at given multiple of std from mean
*
* Output: Y
* probability P(y|x,w)
*
* additional output features:
* - mean (regression output before applying link function)
* - variance (regression output variance before applying link function)
* - pessimistic probability: P(y|x,w) with a mean shift parameterized by "optimism" feature
* - sampled probability: p ~ P(y|x,w) with standard deviation scaling parametrized by "samplingScale" feature
* and distribution truncated at multiple of standard deviation,
* where multiple parameterized by "samplingTruncation" feature.
*
*/

message BayesianProbitRegressor {

/*
* Parameterization of a Gaussian distribution
*/
message Gaussian {
double mean = 1;
double precision = 2; // inverse of the variance
}

/*
* Weight for a specific feature value
* The weight is represented as a Gaussian distribution
* with a mean and precision (1/variance) to capture
* uncertainty in the weight
*/
message FeatureValueWeight {
uint32 featureValue = 1;
Gaussian featureWeight = 2;
}

/*
* Feature with associated weights (for different values)
* Each feature has a set of weights for the (discrete) values
* it can take
*/
message FeatureWeight {
uint32 featureId = 1;
repeated FeatureValueWeight weights = 2;
}

uint32 numberOfFeatures = 1;

Gaussian bias = 2; // bias term

/*
* Set of features with associated weights
*/
repeated FeatureWeight features = 3; // feature weights

/*
* Set this name to be the same as input feature of type multi-array (1D)
* in the model description you want to use as the regression input
*/
string regressionInputFeatureName = 10;

/*
* Set this name to be the same as optional input feature of type double
* in the model description you want to use as the optimism input
*/
string optimismInputFeatureName = 11;

/*
* Set this name to be the same as optional input feature of type double
* in the model description you want to use as the samplingScale input
*/
string samplingScaleInputFeatureName = 12;

/*
* Set this name to be the same as optional input feature of type double
* in the model description you want to use as the samplingBounds input
*/
string samplingTruncationInputFeatureName = 13;

/*
* name of 'mean' output feature
*/
string meanOutputFeatureName = 20;

/*
* name of 'variance' output feature
*/
string varianceOutputFeatureName = 21;

/*
* name of 'pessimistic' output feature
*/
string pessimisticProbabilityOutputFeatureName = 22;

/*
* name of 'sampled' output feature: samples from the scaled posterior probability distribuiton
*/
string sampledProbabilityOutputFeatureName = 23;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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;

/**
* A categorical mapping.
*
* This allows conversion from integers to strings, or from strings to integers.
*/
message CategoricalMapping {
oneof MappingType {
// Conversion from strings to integers
StringToInt64Map stringToInt64Map = 1;

// Conversion from integer to string
Int64ToStringMap int64ToStringMap = 2;
}

/**
* The value returned if an input is not contained in the map above.
* If one of these is not set, then an error is raised on an unknown input.
*/
oneof ValueOnUnknown {
// Default output when converting from an integer to a string.
string strValue = 101;

// Default output when converting from a string to an integer.
int64 int64Value = 102;
}
}
Loading

0 comments on commit 5f0ba31

Please sign in to comment.