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

Fix issue caused by argmin/argmax output shape #7

Merged
merged 1 commit into from
May 18, 2023

Conversation

mingmingtasd
Copy link

No description provided.

@mingmingtasd mingmingtasd changed the title Fix issue caused by agrmin/argmax output shape Fix issue caused by argmin/argmax output shape May 18, 2023
@@ -1052,6 +1053,15 @@ void GraphDMLImpl::AddArgMinMax(OperatorType operator_type,

auto node_output = graph_desc_builder_->CreateNodeOutput(
node, 0, std::move(output_tensor_desc));

if (!keep_dimensions) {
Copy link
Owner

@fdwr fdwr May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Propose the following, just checking original_output_tensor_desc and calling CreateNodeOutput once, rather than calling CreateNodeOutput once and then again, overwriting a previous call.

...
  auto output_data_type = GetTensorDataType(output_desc->data_type);
  TensorDesc output_tensor_desc(output_data_type, output_dimensions);
  TensorDesc original_output_tensor_desc(output_data_type,  //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                         output_desc->dimensions);

  // DML accepts multiple axes. So pass the single index along.
  std::array<uint32_t, 1> axes = {axis};

...
  Node node = graph_desc_builder_->CreateOperatorNode(dml_operator_type,
                                                      &operator_desc);

  graph_desc_builder_->Connect({input_node}, {node});

  auto node_output = graph_desc_builder_->CreateNodeOutput(
      node, 0, std::move(original_output_tensor_desc)); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  node_output_map_[output_index] = std::move(node_output);

(no need to keep_dimensions down the stack, since the original dimensions already adjusted that)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated, PTAL! @fdwr

@fdwr fdwr merged commit ade7fa2 into fdwr:dml_sd May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants