Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions cmake/external/onnxruntime_external_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -367,23 +367,23 @@ if (CPUINFO_SUPPORTED)
set(CPUINFO_BUILD_MOCK_TESTS OFF CACHE INTERNAL "")
set(CPUINFO_BUILD_BENCHMARKS OFF CACHE INTERNAL "")
if (onnxruntime_target_platform STREQUAL "ARM64EC" OR onnxruntime_target_platform STREQUAL "ARM64")
message(STATUS "Applying a patch for Windows ARM64/ARM64EC in cpuinfo")
onnxruntime_fetchcontent_declare(
pytorch_cpuinfo
URL ${DEP_URL_pytorch_cpuinfo}
URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
EXCLUDE_FROM_ALL
PATCH_COMMAND ${Patch_EXECUTABLE} -p1 < ${PROJECT_SOURCE_DIR}/patches/cpuinfo/9bb12d342fd9479679d505d93a478a6f9cd50a47.patch
FIND_PACKAGE_ARGS NAMES cpuinfo
)
message(STATUS "Applying a patch for Windows ARM64/ARM64EC in cpuinfo")
onnxruntime_fetchcontent_declare(
pytorch_cpuinfo
URL ${DEP_URL_pytorch_cpuinfo}
URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
EXCLUDE_FROM_ALL
PATCH_COMMAND ${Patch_EXECUTABLE} -p1 < ${PROJECT_SOURCE_DIR}/patches/cpuinfo/patch_cpuinfo_h_for_arm64ec.patch
FIND_PACKAGE_ARGS NAMES cpuinfo
)
else()
onnxruntime_fetchcontent_declare(
pytorch_cpuinfo
URL ${DEP_URL_pytorch_cpuinfo}
URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
EXCLUDE_FROM_ALL
FIND_PACKAGE_ARGS NAMES cpuinfo
)
onnxruntime_fetchcontent_declare(
pytorch_cpuinfo
URL ${DEP_URL_pytorch_cpuinfo}
URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
EXCLUDE_FROM_ALL
FIND_PACKAGE_ARGS NAMES cpuinfo
)
endif()
set(ONNXRUNTIME_CPUINFO_PROJ pytorch_cpuinfo)
onnxruntime_fetchcontent_makeavailable(${ONNXRUNTIME_CPUINFO_PROJ})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/include/cpuinfo.h b/include/cpuinfo.h
index 6eb4b8c..4346a5a 100644
index f1d35d4..9e454d2 100644
--- a/include/cpuinfo.h
+++ b/include/cpuinfo.h
@@ -18,7 +18,7 @@
Expand All @@ -20,16 +20,3 @@ index 6eb4b8c..4346a5a 100644
#define CPUINFO_ARCH_ARM64 1
#endif

diff --git a/src/arm/windows/init.c b/src/arm/windows/init.c
index de2f6cc..c3a7835 100644
--- a/src/arm/windows/init.c
+++ b/src/arm/windows/init.c
@@ -175,7 +175,7 @@ static struct woa_chip_info* get_system_info_from_registry(void) {
if (chip_info == NULL) {
/* No match was found, so print a warning and assign the unknown
* case. */
- cpuinfo_log_error(
+ cpuinfo_log_debug(
"Unknown chip model name '%ls'.\nPlease add new Windows on Arm SoC/chip support to arm/windows/init.c!",
text_buffer);
} else {
4 changes: 2 additions & 2 deletions csharp/src/Microsoft.ML.OnnxRuntime/Exceptions.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ internal enum ErrorCode
ModelLoaded = 8,
NotImplemented = 9,
InvalidGraph = 10,
ShapeInferenceNotRegistered = 11,
RequirementNotRegistered = 12,
ShapeInferenceNotRegistered = 11, // TODO: should be ORT_EP_FAIL
RequirementNotRegistered = 12, // TODO: should be ORT_MODEL_LOAD_CANCELED
}

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions include/onnxruntime/core/common/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
EP_FAIL = 11,
MODEL_LOAD_CANCELED = 12,
MODEL_REQUIRES_COMPILATION = 13,
NOT_FOUND = 14,
};

constexpr const char* StatusCodeToString(StatusCode status) noexcept {
Expand Down Expand Up @@ -78,6 +79,8 @@
return "MODEL_LOAD_CANCELED";
case StatusCode::MODEL_REQUIRES_COMPILATION:
return "MODEL_REQUIRES_COMPILATION";
case StatusCode::NOT_FOUND:
return "NOT_FOUND";
default:
return "GENERAL ERROR";
}
Expand Down Expand Up @@ -111,9 +114,11 @@
case StatusCode::EP_FAIL:
return HRESULT_FROM_WIN32(ERROR_INTERNAL_ERROR);
case StatusCode::MODEL_LOAD_CANCELED:
return HRESULT_FROM_WIN32(ERROR_CANCELLED);

Check notice on line 117 in include/onnxruntime/core/common/status.h

View workflow job for this annotation

GitHub Actions / misspell

[misspell] include/onnxruntime/core/common/status.h#L117

"CANCELLED" is a misspelling of "CANCELED"
Raw output
./include/onnxruntime/core/common/status.h:117:38: "CANCELLED" is a misspelling of "CANCELED"
case StatusCode::MODEL_REQUIRES_COMPILATION:
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
case StatusCode::NOT_FOUND:
return HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
default:
return E_FAIL;
}
Expand Down
103 changes: 100 additions & 3 deletions include/onnxruntime/core/providers/utils/ort_graph_to_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
/*out*/ std::vector<int64_t>& dims,
/*out*/ std::vector<std::string>& symbolic_dims);
static Ort::Status OrtValueInfoToProto(const OrtValueInfo& ort_value_info, onnx::ValueInfoProto& value_info_proto);
static Ort::Status OrtOpAttrToProto(const OrtOpAttr& ort_attr, onnx::AttributeProto& attr_proto);
static Ort::Status OrtOpAttrToProto(const OrtNode& ort_node, const OrtOpAttr& ort_attr, onnx::AttributeProto& attr_proto);

Ort::Status OrtGraphToProto(const OrtGraph& ort_graph,
onnx::GraphProto& graph_proto,
Expand Down Expand Up @@ -379,7 +379,7 @@
}

onnx::AttributeProto* attr_proto = node_proto->add_attribute();
ORT_EP_UTILS_CXX_RETURN_IF_ERROR(OrtOpAttrToProto(*ort_attr, *attr_proto));
ORT_EP_UTILS_CXX_RETURN_IF_ERROR(OrtOpAttrToProto(*ort_node, *ort_attr, *attr_proto));
}
}

Expand Down Expand Up @@ -652,7 +652,7 @@
return Ort::Status{nullptr};
}

static Ort::Status OrtOpAttrToProto(const OrtOpAttr& ort_attr, onnx::AttributeProto& attr_proto) {
static Ort::Status OrtOpAttrToProto(const OrtNode& ort_node, const OrtOpAttr& ort_attr, onnx::AttributeProto& attr_proto) {
const OrtApi& ort_api = Ort::GetApi();

const char* attr_name = nullptr;
Expand Down Expand Up @@ -758,6 +758,103 @@

break;
}
case OrtOpAttrType::ORT_OP_ATTR_TENSOR: {
attr_proto.set_type(onnx::AttributeProto_AttributeType_TENSOR);

onnx::TensorProto tensor_proto;

// TensorProto as an attribute value doesn't require a name.

OrtValue* ort_value = nullptr;
ORT_EP_UTILS_C_RETURN_IF_ERROR(ort_api.Node_GetTensorAttributeAsOrtValue(&ort_node, &ort_attr, &ort_value));

Ort::Value tensor(ort_value);

// Get tensor type and shape info
Ort::TensorTypeAndShapeInfo type_shape_info = tensor.GetTensorTypeAndShapeInfo();

// Get tensor type
ONNXTensorElementDataType element_type = type_shape_info.GetElementType();

size_t element_size = 0;
switch (element_type) {
case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT: {
tensor_proto.set_data_type(onnx::TensorProto_DataType_FLOAT);
element_size = sizeof(float);
break;
}
case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8: {
tensor_proto.set_data_type(onnx::TensorProto_DataType_UINT8);
element_size = sizeof(uint8_t);
break;
}
case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8: {
tensor_proto.set_data_type(onnx::TensorProto_DataType_INT8);
element_size = sizeof(int8_t);
break;
}
case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16: {
tensor_proto.set_data_type(onnx::TensorProto_DataType_UINT16);
element_size = sizeof(uint16_t);
break;
}
case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16: {
tensor_proto.set_data_type(onnx::TensorProto_DataType_INT16);
element_size = sizeof(int16_t);
break;
}
case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32: {
tensor_proto.set_data_type(onnx::TensorProto_DataType_INT32);
element_size = sizeof(int32_t);
break;
}
case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64: {
tensor_proto.set_data_type(onnx::TensorProto_DataType_INT64);
element_size = sizeof(int64_t);
break;
}
case ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL: {
tensor_proto.set_data_type(onnx::TensorProto_DataType_BOOL);
element_size = sizeof(bool);
break;
}
case ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE: {
tensor_proto.set_data_type(onnx::TensorProto_DataType_DOUBLE);
element_size = sizeof(double);
break;
}
case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32: {
tensor_proto.set_data_type(onnx::TensorProto_DataType_UINT32);
element_size = sizeof(uint32_t);
break;
}
case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64: {
tensor_proto.set_data_type(onnx::TensorProto_DataType_UINT64);
element_size = sizeof(uint64_t);
break;
}
default: {
std::string err_msg = "Unexpected ONNXTensorElementDataType with value " + std::to_string(static_cast<int>(element_type));
return Ort::Status(err_msg.c_str(), ORT_FAIL);
}
}

auto shape = type_shape_info.GetShape();

for (auto& dim : shape) {
tensor_proto.add_dims(dim);
}

size_t element_count = type_shape_info.GetElementCount();
size_t data_bytes = element_count * element_size;
const void* data = tensor.GetTensorData<void>();

// Copy the Ortvalue to TensorProto as raw data
tensor_proto.set_raw_data(data, data_bytes);

*(attr_proto.mutable_t()) = std::move(tensor_proto);

Check notice on line 855 in include/onnxruntime/core/providers/utils/ort_graph_to_proto.h

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] include/onnxruntime/core/providers/utils/ort_graph_to_proto.h#L855

Add #include <utility> for move [build/include_what_you_use] [4]
Raw output
include/onnxruntime/core/providers/utils/ort_graph_to_proto.h:855:  Add #include <utility> for move  [build/include_what_you_use] [4]
break;
}
default: {
std::string err_msg = "Unexpected OrtOpAttrType with value " + std::to_string(static_cast<int>(attr_type));
return Ort::Status(err_msg.c_str(), ORT_FAIL);
Expand Down
33 changes: 31 additions & 2 deletions include/onnxruntime/core/session/onnxruntime_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ typedef enum OrtErrorCode {
ORT_EP_FAIL,
ORT_MODEL_LOAD_CANCELED,
ORT_MODEL_REQUIRES_COMPILATION,
ORT_NOT_FOUND,
} OrtErrorCode;

typedef enum OrtOpAttrType {
Expand All @@ -275,6 +276,7 @@ typedef enum OrtOpAttrType {
ORT_OP_ATTR_STRING,
ORT_OP_ATTR_STRINGS,
ORT_OP_ATTR_GRAPH,
ORT_OP_ATTR_TENSOR,
} OrtOpAttrType;

//! @}
Expand Down Expand Up @@ -6031,6 +6033,11 @@ struct OrtApi {
* Typical usage sets this to the result of Node_GetNumAttributes(). An error status is
* returned if `num_attributes` is less than the number of node attributes.
*
* \note ONNX Runtime automatically sets optional (unset) attributes to their default values if the default value
* is a constant expression that does not depend on other tensor/model characteristics. Conv's 'kernel_shape'
* attribute is an example of an optional attribute that does not have a constant default value. This function
* does not provide any unset optional attributes without a constant default value.
*
* \snippet{doc} snippets.dox OrtStatus Return Value
*
* \since Version 1.23.
Expand All @@ -6042,14 +6049,36 @@ struct OrtApi {
*
* \param[in] node The OrtNode instance.
* \param[in] attribute_name The name of the attribute
* \param[out] attribute Output the attribute if its name matches 'attribute_name', otherwise output nullptr.
* \param[out] attribute Output parameter set to the OrtOpAttr instance if an attribute by the given name exists.
* For an unset optional attribute, `attribute` is set to NULL and a non-error status is
* returned. For an invalid attribute name, `attribute` is set to NULL and an error status with
* code ORT_NOT_FOUND is returned.
*
* \note ONNX Runtime automatically sets optional (unset) attributes to their default values if the default value
* is a constant expression that does not depend on other tensor/model characteristics. Conv's 'kernel_shape'
* attribute is an example of an optional attribute that does not have a constant default value. This function
* does not provide any unset optional attributes without a constant default value.
*
* \snippet{doc} snippets.dox OrtStatus Return Value
*
* \since Version 1.23.
*/
ORT_API2_STATUS(Node_GetAttributeByName, _In_ const OrtNode* node, _In_ const char* attribute_name,
_Outptr_ const OrtOpAttr** attribute);
_Outptr_result_maybenull_ const OrtOpAttr** attribute);

/** \brief Get the OrtNode's 'TENSOR' attribute as an OrtValue.
*
* \param[in] node The OrtNode instance.
* \param[in] attribute The OrtOpAttr instance.
* \param[out] attr_tensor If successful, contains the 'TENSOR' attribute as a newly created OrtValue.
Must be freed with OrtApi::ReleaseValue.
*
* \snippet{doc} snippets.dox OrtStatus Return Value
*
* \since Version 1.23.
*/
ORT_API2_STATUS(Node_GetTensorAttributeAsOrtValue, _In_ const OrtNode* node, _In_ const OrtOpAttr* attribute,
_Outptr_result_maybenull_ OrtValue** attr_tensor);

/** \brief Get the attribute type as OrtOpAttrType from an OrtOpAttr.
*
Expand Down
10 changes: 8 additions & 2 deletions java/src/main/java/ai/onnxruntime/OrtException.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ public enum OrtErrorCode {
/** The ONNX graph is invalid. */
ORT_INVALID_GRAPH(10),
/** The ORT execution provider failed. */
ORT_EP_FAIL(11);
ORT_EP_FAIL(11),
/** Model load was canceled. */
ORT_MODEL_LOAD_CANCELED(12),
/** Model requires compilation. */
ORT_MODEL_REQUIRES_COMPILATION(13),
/** Item was not found. */
ORT_NOT_FOUND(14);

private final int value;

private static final OrtErrorCode[] values = new OrtErrorCode[12];
private static final OrtErrorCode[] values = new OrtErrorCode[15];

static {
for (OrtErrorCode ot : OrtErrorCode.values()) {
Expand Down
6 changes: 6 additions & 0 deletions java/src/main/native/OrtJniUtil.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,12 @@ jint convertErrorCode(OrtErrorCode code) {
return 10;
case ORT_EP_FAIL:
return 11;
case ORT_MODEL_LOAD_CANCELED:
return 12;
case ORT_MODEL_REQUIRES_COMPILATION:
return 13;
case ORT_NOT_FOUND:
return 14;
default:
return -1; // Unknown error code
}
Expand Down
1 change: 1 addition & 0 deletions onnxruntime/contrib_ops/webgpu/bert/attention_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct WebgpuAttentionParameters {
v_hidden_size_(parameters.kv_hidden_size),
v_head_size_(parameters.kv_hidden_size / parameters.kv_num_heads),
num_heads_(parameters.num_heads),
is_unidirectional_(true),
do_rotary_(parameters.do_rotary),
scale_(parameters.scale),
seqlen_past_kv_cache_(parameters.seqlen_past_kv_cache),
Expand Down
Loading
Loading