onnxruntime/onnxruntime/core/providers/common.h
Ryan Hill 11b369a864
Abbreviate ONNXRuntime as Ort in all of our public APIs (#175)
Applies to all public headers and macros, plus many internal ones. There are still some internal things with OnnxRuntime in the name, but this fixes all public functions & macros.
2018-12-14 14:54:23 -08:00

23 lines
763 B
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "core/common/common.h"
namespace onnxruntime {
/**
Handle a potentially negative axis. Enforces negative axis is valid.
@param axis Axis to convert from negative to positive if needed.
@param tensor_rank Rank of tensor axis applies to. Tensor::Shape()::NumDimensions().
@returns Positive axis.
*/
inline int64_t HandleNegativeAxis(int64_t axis, int64_t tensor_rank) {
ORT_ENFORCE(axis >= -tensor_rank && axis <= tensor_rank - 1, "axis ", axis,
" is not in valid range [-", tensor_rank, ",", tensor_rank - 1, "]");
// Handle negative axis
return axis = axis < 0 ? axis + tensor_rank : axis;
}
} // namespace onnxruntime