diff options
author | Gerard Goossen <ggoossen@fb.com> | 2019-03-22 06:33:24 -0700 |
---|---|---|
committer | Facebook Github Bot <facebook-github-bot@users.noreply.github.com> | 2019-03-22 06:36:25 -0700 |
commit | 46990c20fa867aa29e049f7664da071e0cfc9c95 (patch) | |
tree | 0dd1350e4121e3c6e0a9c6ca974ca39a795f0d16 /caffe2/core | |
parent | 77a7285764334cc50eb573c3d2614ffefba4a29f (diff) | |
download | pytorch-46990c20fa867aa29e049f7664da071e0cfc9c95.tar.gz pytorch-46990c20fa867aa29e049f7664da071e0cfc9c95.tar.bz2 pytorch-46990c20fa867aa29e049f7664da071e0cfc9c95.zip |
Verify def before infer fensor (#18129)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18129
A lot of tensor interference function assume the operator passes the schema.
So call Verity to make sure this is actually the case.
Created diff before to add checking in Concat (https://github.com/pytorch/pytorch/pull/17110), but I encountered lot more places where this is assumed (for example ElementwiseOpShapeInference)
Reviewed By: mdschatz
Differential Revision: D14503933
fbshipit-source-id: cf0097b8c3e4beb1cded6b61e092a6adee4b8fcb
Diffstat (limited to 'caffe2/core')
-rw-r--r-- | caffe2/core/operator_schema.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/caffe2/core/operator_schema.h b/caffe2/core/operator_schema.h index 02eb2f5899..e902fb57a7 100644 --- a/caffe2/core/operator_schema.h +++ b/caffe2/core/operator_schema.h @@ -14,6 +14,7 @@ #include "caffe2/core/logging.h" #include "caffe2/proto/caffe2_pb.h" #include "caffe2/utils/filler.h" +#include "caffe2/utils/proto_utils.h" namespace caffe2 { @@ -186,6 +187,10 @@ class CAFFE2_API OpSchema { inline vector<TensorShape> InferTensor( const OperatorDef& def, const vector<TensorShape>& input_type_shape) const { + CAFFE_ENFORCE( + Verify(def), + "(InferTensor) Operator def did not pass schema checking: ", + ProtoDebugString(def)); return tensor_inference_function_(def, input_type_shape); } |