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

Do not add Concat + Reshape in OneHotEncoder converter #1052

Open
DeltaEpsilon7787 opened this issue Dec 24, 2023 · 0 comments
Open

Do not add Concat + Reshape in OneHotEncoder converter #1052

DeltaEpsilon7787 opened this issue Dec 24, 2023 · 0 comments

Comments

@DeltaEpsilon7787
Copy link

DeltaEpsilon7787 commented Dec 24, 2023

microsoft/onnxruntime#18918

This issue was discovered because sklearn2onnx always adds a Concat + Reshape operator after a OneHotEncoder, which does nothing but waste time for the output there.

Consider removing

concat_result_name = scope.get_unique_variable_name("concat_result")
apply_concat(scope, result, concat_result_name, container, axis=-1)
reshape_input = concat_result_name
if np.issubdtype(ohe_op.dtype, np.signedinteger):
reshape_input = scope.get_unique_variable_name("cast")
apply_cast(
scope,
concat_result_name,
reshape_input,
container,
to=onnx_proto.TensorProto.INT64,
)
apply_reshape(
scope,
reshape_input,
operator.output_full_names,
container,
desired_shape=(-1, categories_len),
)

@DeltaEpsilon7787 DeltaEpsilon7787 changed the title Do not add Concat + Reshape in OneHotEncoder converters for unary variable inputs Do not add Concat + Reshape in OneHotEncoder converter Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To do
Development

No branches or pull requests

1 participant