Skip to content

Commit

Permalink
fix in_place ut failed caused by PR PaddlePaddle#54389
Browse files Browse the repository at this point in the history
  • Loading branch information
wentaoyu committed Nov 25, 2023
1 parent 781f907 commit 52c31af
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,22 +313,7 @@ paddle::Tensor& multiply__ad_func(paddle::Tensor& x, // NOLINT

// Node Creation
if (require_any_grad) {
paddle::platform::RecordEvent node_creation_record_event(
"multiply node_creation",
paddle::platform::TracerEventType::OperatorInner,
1);

egr::EagerUtils::PassStopGradient(false, out_autograd_meta);

// Node Construction
auto grad_node =
std::shared_ptr<MultiplyGradNode>(new MultiplyGradNode(1, 2));

// SetAttributes if needed
grad_node->SetAttributeaxis(-1);
// Set TensorWrappers for Forward Inputs if needed
grad_node->SetTensorWrapperx(x);
grad_node->SetTensorWrappery(y);
// SetGradOutMeta & SetEdges
grad_node->SetGradOutMeta(x, 0);
grad_node->SetGradOutMeta(y, 1);
Expand Down
50 changes: 0 additions & 50 deletions paddle/fluid/eager/api/manual/eager_manual/nodes/multiply_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -411,56 +411,6 @@ MultiplyDoubleGradNode::operator()(

// Create Grad Node

if (!paddle::prim::PrimCommonUtils::IsEagerPrimEnabled()) {
if (trace_backward) {
paddle::platform::RecordEvent node_creation_record_event(
"multiply_double_grad node_creation",
paddle::platform::TracerEventType::OperatorInner,
1);

// Node Construction
auto grad_node = std::shared_ptr<MultiplyTripleGradNode>(
new MultiplyTripleGradNode(3, 5));
// SetAttributes if needed
grad_node->SetAttributeaxis(-1);
// Set TensorWrappers for Forward Inputs if needed
grad_node->SetTensorWrapperx(x);
grad_node->SetTensorWrappery(y);
grad_node->SetTensorWrapperfwd_grad_out(fwd_grad_out);
grad_node->SetTensorWrapperfwd_grad_grad_x(fwd_grad_grad_x);
grad_node->SetTensorWrapperfwd_grad_grad_y(fwd_grad_grad_y);
// SetGradOutMeta & SetEdges
grad_node->SetGradOutMeta(x, 0);
grad_node->SetGradOutMeta(y, 1);
grad_node->SetGradOutMeta(fwd_grad_out, 2);
grad_node->SetGradOutMeta(fwd_grad_grad_x, 3);
grad_node->SetGradOutMeta(fwd_grad_grad_y, 4);
// SetOutRank & SetHistory & SetGradInMeta
if (grad_x_autograd_meta) {
egr::EagerUtils::SetOutRankWithSlot(grad_x_autograd_meta, 0);
}
if (grad_y_autograd_meta) {
egr::EagerUtils::SetOutRankWithSlot(grad_y_autograd_meta, 1);
}
if (grad_grad_out_autograd_meta) {
egr::EagerUtils::SetOutRankWithSlot(grad_grad_out_autograd_meta, 2);
}
if (grad_x_autograd_meta) {
egr::EagerUtils::SetHistory(grad_x_autograd_meta, grad_node);
}
if (grad_y_autograd_meta) {
egr::EagerUtils::SetHistory(grad_y_autograd_meta, grad_node);
}
if (grad_grad_out_autograd_meta) {
egr::EagerUtils::SetHistory(grad_grad_out_autograd_meta, grad_node);
}
grad_node->SetGradInMeta(grad_x, 0);
grad_node->SetGradInMeta(grad_y, 1);
grad_node->SetGradInMeta(grad_grad_out, 2);
// Set TensorWrappers for Forward Outputs if needed
}
}

VLOG(4) << "Finish AD API GRAD: multiply_double_grad";
// LOG IF DEBUG

Expand Down

0 comments on commit 52c31af

Please sign in to comment.