Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.16.1 cherry picks #6108

Merged
merged 9 commits into from
May 9, 2024
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,11 @@ if(BUILD_ONNX_PYTHON)
target_link_libraries(onnx_cpp2py_export
PRIVATE "-Wl,--whole-archive" $<TARGET_FILE:onnx>
"-Wl,--no-whole-archive")
# Prevent "undefined symbol: _ZNSt10filesystem7__cxx114path14_M_split_cmptsEv"
# (std::filesystem::__cxx11::path::_M_split_cmpts()) on gcc 8
if (CMAKE_CXX_STANDARD EQUAL 17 AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
target_link_libraries(onnx_cpp2py_export PRIVATE "-lstdc++fs")
endif()
set_target_properties(onnx_cpp2py_export
PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL")
endif()
Expand Down
3 changes: 3 additions & 0 deletions onnx/defs/quantization/defs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ ONNX_OPERATOR_SET_SCHEMA(
.SetDoc(DequantizeLinear_ver21_doc)
.TypeAndShapeInferenceFunction([](ONNX_NAMESPACE::InferenceContext& ctx) {
propagateElemTypeFromInputToOutput(ctx, 1, 0);
if (!hasInputShape(ctx, 0)) {
return;
}
auto& input_shape = getInputShape(ctx, 0);
updateOutputShape(ctx, 0, input_shape);
}));
Expand Down
4 changes: 3 additions & 1 deletion onnx/defs/quantization/old.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ ONNX_OPERATOR_SET_SCHEMA(
.SetDoc(DequantizeLinear_ver19_doc)
.TypeAndShapeInferenceFunction([](ONNX_NAMESPACE::InferenceContext& ctx) {
propagateElemTypeFromInputToOutput(ctx, 1, 0);
if (!hasInputShape(ctx, 0)) {
return;
}
auto& input_shape = getInputShape(ctx, 0);
updateOutputShape(ctx, 0, input_shape);
}));
Expand Down Expand Up @@ -181,7 +184,6 @@ ONNX_OPERATOR_SET_SCHEMA(
if (!hasInputShape(ctx, 0)) {
return;
}

auto& input_shape = getInputShape(ctx, 0);
updateOutputShape(ctx, 0, input_shape);
}));
Expand Down
36 changes: 18 additions & 18 deletions onnx/shape_inference/implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -488,29 +488,29 @@ class ShapeInferenceImplBase {
ProcessCall(n, *(iter->second), ctx);
} else {
has_unsupported_op = true;
return;
}
} else {
has_unsupported_op = true;
return;
}
if (!has_unsupported_op) {
for (int i = 0; i < n.output_size(); ++i) {
// skip type and shape propagation for missing optional outputs.
if (!n.output(i).empty())
UpdateType(n.output(i), ctx.getOutputType(i));
}
// Constant values are tracked to improve inference/checking for subsequent nodes.
ProcessConstant(n);
// If data-propagation is enabled, partial-evaluation (aka data-propagation) is performed
// to improve inference/checking for subsequent nodes.
if (options.enable_data_propagation && schema && schema->has_data_propagation_function()) {
if (generated_shape_data_by_name == nullptr) {
fail_shape_inference(
"Container for generated shape data cannot be nullptr when enable_data_propagation option is set.");
}
DataPropagationContextImpl data_propagation_ctx(
n, value_types_by_name, input_data_by_name, *generated_shape_data_by_name);
schema->GetDataPropagationFunction()(data_propagation_ctx);
for (int i = 0; i < n.output_size(); ++i) {
// skip type and shape propagation for missing optional outputs.
if (!n.output(i).empty())
UpdateType(n.output(i), ctx.getOutputType(i));
}
// Constant values are tracked to improve inference/checking for subsequent nodes.
ProcessConstant(n);
// If data-propagation is enabled, partial-evaluation (aka data-propagation) is performed
// to improve inference/checking for subsequent nodes.
if (options.enable_data_propagation && schema && schema->has_data_propagation_function()) {
if (generated_shape_data_by_name == nullptr) {
fail_shape_inference(
"Container for generated shape data cannot be nullptr when enable_data_propagation option is set.");
}
DataPropagationContextImpl data_propagation_ctx(
n, value_types_by_name, input_data_by_name, *generated_shape_data_by_name);
schema->GetDataPropagationFunction()(data_propagation_ctx);
}
}
ONNX_CATCH(const ONNX_NAMESPACE::InferenceError& ex) {
Expand Down
Loading