diff --git a/onnxruntime/contrib_ops/cpu/range.cc b/onnxruntime/contrib_ops/cpu/range.cc index ec0fc8478b..a69c32e990 100644 --- a/onnxruntime/contrib_ops/cpu/range.cc +++ b/onnxruntime/contrib_ops/cpu/range.cc @@ -48,7 +48,9 @@ static Status ComputeRange(OpKernelContext* ctx) { } Status Range::Compute(OpKernelContext* ctx) const { - auto data_type = ctx->Input(0)->DataType(); + auto input_tensor = ctx->Input(0); + if (input_tensor == nullptr) return Status(common::ONNXRUNTIME, common::FAIL, "input count mismatch"); + auto data_type = input_tensor->DataType(); if (data_type == DataTypeImpl::GetType()) { return ComputeRange(ctx); } diff --git a/onnxruntime/contrib_ops/cpu/string_normalizer.cc b/onnxruntime/contrib_ops/cpu/string_normalizer.cc index 9fd5aaacbc..5fa4262884 100644 --- a/onnxruntime/contrib_ops/cpu/string_normalizer.cc +++ b/onnxruntime/contrib_ops/cpu/string_normalizer.cc @@ -207,6 +207,7 @@ Status StringNormalizer::Compute(OpKernelContext* ctx) const { using namespace string_normalizer; auto X = ctx->Input(0); + if (X == nullptr) return Status(common::ONNXRUNTIME, common::FAIL, "input count mismatch"); auto& input_dims = X->Shape().GetDims(); size_t N = 0; diff --git a/onnxruntime/contrib_ops/cpu/tokenizer.cc b/onnxruntime/contrib_ops/cpu/tokenizer.cc index 7e83e1ca71..0efaf5d5eb 100644 --- a/onnxruntime/contrib_ops/cpu/tokenizer.cc +++ b/onnxruntime/contrib_ops/cpu/tokenizer.cc @@ -450,6 +450,7 @@ Status Tokenizer::SeparatorTokenize(OpKernelContext* ctx, Status Tokenizer::Compute(OpKernelContext* ctx) const { // Get input buffer ptr auto X = ctx->Input(0); + if (X == nullptr) return Status(common::ONNXRUNTIME, common::FAIL, "input count mismatch"); if (X->DataType() != DataTypeImpl::GetType()) { return Status(common::ONNXRUNTIME, common::INVALID_ARGUMENT, "tensor(string) expected as input"); diff --git a/onnxruntime/core/providers/cpu/tensor/eye_like.cc b/onnxruntime/core/providers/cpu/tensor/eye_like.cc index 0ce03906fb..d93620ee37 100644 --- a/onnxruntime/core/providers/cpu/tensor/eye_like.cc +++ b/onnxruntime/core/providers/cpu/tensor/eye_like.cc @@ -33,19 +33,18 @@ Status EyeLike::Compute(OpKernelContext* context) const { auto output_tensor_dtype = has_dtype_ ? static_cast(dtype_) : utils::GetTensorProtoType(*T1); switch (output_tensor_dtype) { case onnx::TensorProto_DataType_FLOAT: - return ComputeImpl(context); + return ComputeImpl(context, T1); case onnx::TensorProto_DataType_INT64: - return ComputeImpl(context); + return ComputeImpl(context, T1); case onnx::TensorProto_DataType_UINT64: - return ComputeImpl(context); + return ComputeImpl(context, T1); default: ONNXRUNTIME_THROW("Unsupported 'dtype' value: ", output_tensor_dtype); } } template -Status EyeLike::ComputeImpl(OpKernelContext* context) const { - const Tensor* T1 = context->Input(0); +Status EyeLike::ComputeImpl(OpKernelContext* context, const Tensor* T1) const { const std::vector& input_dims = T1->Shape().GetDims(); if (input_dims.size() != 2) { return Status(ONNXRUNTIME, INVALID_ARGUMENT, "EyeLike : Input tensor dimension is not 2"); diff --git a/onnxruntime/core/providers/cpu/tensor/eye_like.h b/onnxruntime/core/providers/cpu/tensor/eye_like.h index bbc81eb1e7..4fa74d94cc 100644 --- a/onnxruntime/core/providers/cpu/tensor/eye_like.h +++ b/onnxruntime/core/providers/cpu/tensor/eye_like.h @@ -22,7 +22,7 @@ class EyeLike final : public OpKernel { private: template - Status ComputeImpl(OpKernelContext* context) const; + Status ComputeImpl(OpKernelContext* context, const Tensor* T1) const; bool has_dtype_; int64_t dtype_;