Fix some warnings (#551)

This commit is contained in:
Changming Sun 2019-03-06 11:46:59 -08:00 committed by GitHub
parent 714d4100bd
commit cf41f76d79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 24 additions and 25 deletions

View file

@ -49,12 +49,13 @@ std::ostream& operator<<(std::ostream& out, const OrtAllocatorInfo& info) {
return (out << info.ToString());
}
ORT_API_STATUS_IMPL(OrtCreateAllocatorInfo, const char* name1, OrtAllocatorType type, int id1, OrtMemType mem_type1, OrtAllocatorInfo** out) {
ORT_API_STATUS_IMPL(OrtCreateAllocatorInfo, _In_ const char* name1, OrtAllocatorType type, int id1,
OrtMemType mem_type1, _Out_ OrtAllocatorInfo** out) {
*out = new OrtAllocatorInfo(name1, type, id1, mem_type1);
return nullptr;
}
ORT_API(void, OrtReleaseAllocatorInfo, OrtAllocatorInfo* p) {
ORT_API(void, OrtReleaseAllocatorInfo, _Frees_ptr_opt_ OrtAllocatorInfo* p) {
delete p;
}

View file

@ -12,7 +12,7 @@ struct OrtStatus {
char msg[1]; // a null-terminated string
};
ORT_API(OrtStatus*, OrtCreateStatus, OrtErrorCode code, const char* msg) {
ORT_API(OrtStatus*, OrtCreateStatus, OrtErrorCode code, _In_ const char* msg) {
assert(!(code == 0 && msg != nullptr));
size_t clen = strlen(msg);
OrtStatus* p = reinterpret_cast<OrtStatus*>(new char[sizeof(OrtStatus) + clen]);
@ -42,4 +42,4 @@ ORT_API(const char*, OrtGetErrorMessage, _In_ const OrtStatus* status) {
return status->msg;
}
ORT_API(void, OrtReleaseStatus, OrtStatus* value) { delete[] reinterpret_cast<char*>(value); }
ORT_API(void, OrtReleaseStatus, _Frees_ptr_opt_ OrtStatus* value) { delete[] reinterpret_cast<char*>(value); }

View file

@ -416,7 +416,7 @@ Status ExecutionFrame::CreateNodeOutputMLValueImpl(MLValue& mlvalue, int mlvalue
}
Status ExecutionFrame::ReleaseMLValueImpl(int mlvalue_idx) {
IExecutionFrame::ReleaseMLValueImpl(mlvalue_idx);
ORT_RETURN_IF_ERROR(IExecutionFrame::ReleaseMLValueImpl(mlvalue_idx));
TraceFree(mlvalue_idx);
return Status::OK();
}

View file

@ -57,7 +57,8 @@ Status KernelRegistryManager::RegisterKernels(const ExecutionProviders& executio
for (auto& provider : execution_providers) {
auto iter = provider_type_to_registry_.find(provider->Type());
if (iter != provider_type_to_registry_.end()) {
ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "found duplicated provider ", provider->Type(), " in KernelRegistryManager");
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "found duplicated provider ", provider->Type(),
" in KernelRegistryManager");
}
provider_type_to_registry_.insert(std::make_pair(provider->Type(), provider->GetKernelRegistry()));
}

View file

@ -25,7 +25,7 @@ ORT_API(const struct OrtTensorTypeAndShapeInfo*, OrtCastTypeInfoToTensorInfo, _I
return input->type == ONNX_TYPE_TENSOR ? input->data : nullptr;
}
ORT_API(void, OrtReleaseTypeInfo, OrtTypeInfo* ptr) {
ORT_API(void, OrtReleaseTypeInfo, _Frees_ptr_opt_ OrtTypeInfo* ptr) {
delete ptr;
}

View file

@ -55,7 +55,7 @@ common::Status GetDirNameFromFilePath(const std::basic_string<ORTCHAR_T>& s, std
auto st = onnxruntime::RemoveFileSpec(const_cast<wchar_t*>(ret.data()), ret.length() + 1);
if (!st.IsOK()) {
std::ostringstream oss;
oss << "illegal input path:", ToMBString(s);
oss << "illegal input path:" << ToMBString(s);
return Status(st.Category(), st.Code(), oss.str());
}
ret.resize(wcslen(ret.c_str()));

View file

@ -98,8 +98,6 @@ Status SessionState::UpdateMemoryPatternGroupCache(const std::vector<TensorShape
common::Status SessionState::AddInputNameToNodeInfoMapping(const std::string& input_name, const NodeInfo& node_info) {
auto status = Status::OK();
// in the future we could support multiple nodes on difference devices using an input, however right now
// the logic in utils::CopyOneInputAcrossDevices only checks the first entry.
// Instead of failing silently and adding extra entries that will be ignored, check if the required provider
@ -130,15 +128,15 @@ common::Status SessionState::AddInputNameToNodeInfoMapping(const std::string& in
if (current_provider == new_provider) {
entries.push_back(node_info);
} else {
ORT_MAKE_STATUS(ONNXRUNTIME, FAIL,
"Using an input in multiple nodes on different devices is not supported currently. Input:",
input_name, " is used by node ", existing_entry.p_node->Name(), " (", current_provider,
") and node ", node_info.p_node->Name(), " (", new_provider, ").");
return ORT_MAKE_STATUS(ONNXRUNTIME, NOT_IMPLEMENTED,
"Using an input in multiple nodes on different devices is not supported currently. Input:",
input_name, " is used by node ", existing_entry.p_node->Name(), " (", current_provider,
") and node ", node_info.p_node->Name(), " (", new_provider, ").");
}
}
}
return status;
return Status::OK();
}
common::Status SessionState::GetInputNodeInfo(const std::string& input_name,

View file

@ -445,13 +445,13 @@ common::Status SaveInputOutputNamesToNodeMapping(const onnxruntime::Graph& graph
SessionState::NodeInfo node_info(index, &node, kci);
if (IsArgNameInInputsOutputs(arg.Name(), graph_inputs)) {
session_state.AddInputNameToNodeInfoMapping(arg.Name(), node_info);
ORT_RETURN_IF_ERROR(session_state.AddInputNameToNodeInfoMapping(arg.Name(), node_info));
return Status::OK();
}
if (implicit_inputs) {
if (IsArgNameInInputsOutputs(arg.Name(), *implicit_inputs)) {
session_state.AddInputNameToNodeInfoMapping(arg.Name(), node_info);
ORT_RETURN_IF_ERROR(session_state.AddInputNameToNodeInfoMapping(arg.Name(), node_info));
return Status::OK();
}
}
@ -476,7 +476,7 @@ common::Status SaveInputOutputNamesToNodeMapping(const onnxruntime::Graph& graph
// copy to a different device is required
SessionState::NodeInfo node_info(std::numeric_limits<size_t>::max(), &node, kci);
for (const auto& input_def : node_implicit_inputs) {
session_state.AddInputNameToNodeInfoMapping(input_def->Name(), node_info);
ORT_RETURN_IF_ERROR(session_state.AddInputNameToNodeInfoMapping(input_def->Name(), node_info));
}
}
}
@ -498,7 +498,7 @@ common::Status SaveInputOutputNamesToNodeMapping(const onnxruntime::Graph& graph
// dummy entry for an input that we didn't find a use of in the graph. warn about it in case that's a bug.
// utils::CopyOneInputAcrossDevices will use the input MLValue as is given we don't believe it's used anywhere.
LOGS(session_state.Logger(), WARNING) << "Graph input with name " << name << " is not associated with a node. ";
session_state.AddInputNameToNodeInfoMapping(name, empty_node_info);
ORT_RETURN_IF_ERROR(session_state.AddInputNameToNodeInfoMapping(name, empty_node_info));
}
}

View file

@ -36,7 +36,7 @@ ORT_API(OrtTensorTypeAndShapeInfo*, OrtCreateTensorTypeAndShapeInfo) {
return new OrtTensorTypeAndShapeInfo();
}
ORT_API(void, OrtReleaseTensorTypeAndShapeInfo, OrtTensorTypeAndShapeInfo* ptr) {
ORT_API(void, OrtReleaseTensorTypeAndShapeInfo, _Frees_ptr_opt_ OrtTensorTypeAndShapeInfo* ptr) {
delete ptr;
}
@ -47,7 +47,7 @@ ORT_API_STATUS_IMPL(OrtSetTensorElementType, _In_ OrtTensorTypeAndShapeInfo* thi
API_IMPL_END
}
ORT_API_STATUS_IMPL(OrtSetDims, _In_ OrtTensorTypeAndShapeInfo* this_ptr, _In_ const int64_t* dim_values, size_t dim_count) {
ORT_API_STATUS_IMPL(OrtSetDims, OrtTensorTypeAndShapeInfo* this_ptr, _In_ const int64_t* dim_values, size_t dim_count) {
API_IMPL_BEGIN
this_ptr->shape = onnxruntime::TensorShape(dim_values, dim_count);
return nullptr;

View file

@ -217,7 +217,7 @@ Status UnpackTensor(const ONNX_NAMESPACE::TensorProto& tensor, const void* raw_d
return Status(common::ONNXRUNTIME, common::FAIL,
"UnpackTensor: the pre-allocate size does not match the size in proto");
const int max_value = std::numeric_limits<uint16_t>::max();
constexpr int max_value = std::numeric_limits<uint16_t>::max();
for (int i = 0; i < static_cast<int>(expected_size); i++) {
int v = tensor.int32_data()[i];
if (v < 0 || v > max_value) {
@ -251,7 +251,7 @@ Status UnpackTensor(const ONNX_NAMESPACE::TensorProto& tensor, const void* raw_d
return Status(common::ONNXRUNTIME, common::FAIL,
"UnpackTensor: the pre-allocate size does not match the size in proto");
const int max_value = std::numeric_limits<uint16_t>::max();
constexpr int max_value = std::numeric_limits<uint16_t>::max();
for (int i = 0; i < static_cast<int>(expected_size); i++) {
int v = tensor.int32_data()[i];
if (v < 0 || v > max_value) {

View file

@ -142,8 +142,7 @@ common::Status CopyOneInputAcrossDevices(const SessionState& session_state,
// If a node requires input on cpu and input tensor is allocated with pinned memory allocator, don't do copy
if (required_provider_type == onnxruntime::kCpuExecutionProvider &&
(input_tensor_loc.mem_type == OrtMemTypeCPU ||
input_tensor_loc.mem_type == OrtMemTypeCPUOutput)) {
input_tensor_loc.mem_type == OrtMemTypeCPU) {
new_mlvalue = orig_mlvalue;
break;
}