fix xcode alerts (#4470)

* fix xcode alerts

* fix comment

* fix comments

* update text

* fix comments

* fix comments

* remove checks on context

Co-authored-by: Randy <Randy@randysmac.attlocal.net>
Co-authored-by: Randy <Randy@randysmac.local>
Co-authored-by: Tracy Sharpe <tracysh@microsoft.com>
This commit is contained in:
RandySheriffH 2020-07-16 10:20:34 -07:00 committed by GitHub
parent 8ada440961
commit 76b31d6ce2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 22 additions and 20 deletions

View file

@ -48,13 +48,10 @@ class CropBase {
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "Input's width (", W, ") needs to be greater than or equal to the leftBorder (", leftBorder, ") + rightBorder (", rightBorder, ")");
}
int64_t bottomLimit = H - bottomBorder;
int64_t rightLimit = W - rightBorder;
// scale = (height, width)
if (!scale_.empty()) {
bottomLimit = topBorder + scale_[0];
rightLimit = leftBorder + scale_[1];
int64_t bottomLimit = topBorder + scale_[0];
int64_t rightLimit = leftBorder + scale_[1];
if (H < bottomLimit) {
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT,

View file

@ -312,7 +312,6 @@ static ptrdiff_t CalculateParallelForBlock(const ptrdiff_t n, const Eigen::Tenso
if (coarser_efficiency + 0.01 >= max_efficiency) {
// Taking it.
block_size = coarser_block_size;
block_count = coarser_block_count;
if (max_efficiency < coarser_efficiency) {
max_efficiency = coarser_efficiency;
}

View file

@ -23,7 +23,7 @@ struct OrtStatus {
_Check_return_ _Ret_notnull_ OrtStatus* ORT_API_CALL OrtApis::CreateStatus(OrtErrorCode code,
_In_z_ const char* msg) NO_EXCEPTION {
assert(!(code == 0 && msg != nullptr));
SafeInt<size_t> clen(strlen(msg));
SafeInt<size_t> clen(nullptr == msg ? 0 : strlen(msg));
OrtStatus* p = reinterpret_cast<OrtStatus*>(::malloc(sizeof(OrtStatus) + clen));
if (p == nullptr) return nullptr; // OOM. What we can do here? abort()?
p->code = code;

View file

@ -233,9 +233,8 @@ Status KernelRegistry::TryCreateKernel(const onnxruntime::Node& node,
const FuncManager& funcs_mgr,
const DataTransferManager& data_transfer_mgr,
/*out*/ std::unique_ptr<OpKernel>& op_kernel) const {
const KernelCreateInfo* kernel_create_info;
const KernelCreateInfo* kernel_create_info = nullptr;
ORT_RETURN_IF_ERROR(TryFindKernel(node, execution_provider.Type(), &kernel_create_info));
OpKernelInfo kernel_info(node,
*kernel_create_info->kernel_def,
execution_provider,

View file

@ -698,7 +698,7 @@ common::Status SparseTensorProtoToDenseTensorProto(const ONNX_NAMESPACE::SparseT
auto dims = gsl::make_span<const int64_t>(dense.dims().data(), dense.dims().size());
// need to read in sparse data first as it could be in a type specific field, in raw data, or in external data
size_t sparse_bytes;
size_t sparse_bytes = 0;
ORT_RETURN_IF_ERROR(GetSizeInBytesFromTensorProto<0>(sparse_values, &sparse_bytes));
if (type != TensorProto_DataType_STRING) {

View file

@ -1196,6 +1196,10 @@ Return Value:
bool AllPaddingIsZero = true;
bool AllKernelsAreSmall = true;
if (Dimensions > 3) {
throw std::runtime_error("bad dimensions");
}
for (size_t dim = 0; dim < Dimensions; dim++) {
WorkBlock.InputShape[dim] = size_t(InputShape[dim]);

View file

@ -423,9 +423,9 @@ class PosixEnv : public Env {
}
common::Status LoadDynamicLibrary(const std::string& library_filename, void** handle) const override {
char* error_str = dlerror(); // clear any old error_str
dlerror(); // clear any old error_str
*handle = dlopen(library_filename.c_str(), RTLD_NOW | RTLD_LOCAL);
error_str = dlerror();
char* error_str = dlerror();
if (!*handle) {
return common::Status(common::ONNXRUNTIME, common::FAIL,
"Failed to load library " + library_filename + " with error: " + error_str);
@ -437,9 +437,9 @@ class PosixEnv : public Env {
if (!handle) {
return common::Status(common::ONNXRUNTIME, common::FAIL, "Got null library handle");
}
char* error_str = dlerror(); // clear any old error_str
dlerror(); // clear any old error_str
int retval = dlclose(handle);
error_str = dlerror();
char* error_str = dlerror();
if (retval != 0) {
return common::Status(common::ONNXRUNTIME, common::FAIL,
"Failed to unload library with error: " + std::string(error_str));
@ -448,9 +448,9 @@ class PosixEnv : public Env {
}
common::Status GetSymbolFromLibrary(void* handle, const std::string& symbol_name, void** symbol) const override {
char* error_str = dlerror(); // clear any old error str
dlerror(); // clear any old error str
*symbol = dlsym(handle, symbol_name.c_str());
error_str = dlerror();
char* error_str = dlerror();
if (error_str) {
return common::Status(common::ONNXRUNTIME, common::FAIL,
"Failed to get symbol " + symbol_name + " with error: " + error_str);

View file

@ -144,7 +144,7 @@ Status CumSum<T>::Compute(OpKernelContext* ctx) const {
if (output_shape.Size() == 0)
return Status::OK();
int64_t axis;
int64_t axis = 0;
ORT_THROW_IF_ERROR(cumsum_op::GetAxis(axis_tensor, rank, axis));
auto dim(output_tensor.Shape()[axis]); // dimension size for the axis

View file

@ -286,6 +286,10 @@ bool PrepareForReduce(const Tensor* input_tensor_ptr,
return true;
}
if (0 == first_dim) {
return false;
}
block_size = num_elements / first_dim;
blocks = first_dim;

View file

@ -58,6 +58,7 @@ Status UnsqueezeBase::PrepareCompute(OpKernelContext* ctx, Prepare& p) const {
TensorShape output_shape(output_dims);
p.output_tensor = ctx->Output(0, output_shape);
ORT_ENFORCE(nullptr != p.output_tensor);
p.input_tensor = &input_tensor;
return Status::OK();
}
@ -65,9 +66,7 @@ Status UnsqueezeBase::PrepareCompute(OpKernelContext* ctx, Prepare& p) const {
Status Unsqueeze::Compute(OpKernelContext* ctx) const {
Prepare p;
ORT_RETURN_IF_ERROR(PrepareCompute(ctx, p));
CopyCpuTensor(p.input_tensor, p.output_tensor);
return Status::OK();
}
} // namespace onnxruntime

View file

@ -401,7 +401,7 @@ Status TensorProtoToMLValue(const onnx::TensorProto& tensor_proto, const MemBuff
if (static_cast<uint64_t>(tensor_size) > SIZE_MAX) {
return Status(common::ONNXRUNTIME, common::INVALID_ARGUMENT, "Size overflow");
}
size_t size_to_allocate;
size_t size_to_allocate = 0;
ORT_RETURN_IF_ERROR(GetSizeInBytesFromTensorProto<0>(tensor_proto, &size_to_allocate));
if (preallocated && preallocated_size < size_to_allocate)