Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jim19930609 committed Nov 25, 2021
1 parent b814b5c commit 4e208a0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ egr::EagerTensor scale(const egr::EagerTensor& x, float scale, float bias,
// TODO(zhanlve): which one is more efficient:
// 1. construct a vector of pointers
// 2. call "ComputeRequireGrad" multiple times
bool require_any_grad = ComputeRequireGrad(trace_backward, p_autograd_in);
bool require_any_grad =
EagerUtils::ComputeRequireGrad(trace_backward, p_autograd_in);
if (require_any_grad) {
PassStopGradient(false /*generate_grad*/, p_autograd_out);
EagerUtils::PassStopGradient(false /*generate_grad*/, p_autograd_out);

// 2.2.2 Set OutRankInfo for outputs this needs to be as same as Edges's
// input_rank_
Expand Down
1 change: 1 addition & 0 deletions paddle/fluid/eager/api/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cc_library(global_utils SRCS global_utils.cc DEPS place)
cc_library(tensor_utils SRCS tensor_utils.cc DEPS pten pten_api autograd_meta grad_node_info accumulation_node)
4 changes: 1 addition & 3 deletions paddle/fluid/eager/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
set(eager_deps pten pten_api utils global_utils pten_tensor autograd_meta grad_node_info grad_tensor_holder gradient_accumulation accumulation_node)
set(eager_deps pten pten_api tensor_utils utils global_utils pten_tensor autograd_meta grad_node_info grad_tensor_holder gradient_accumulation accumulation_node)
set(fluid_deps tracer layer proto_desc operator op_registry variable_helper memcpy)

add_subdirectory(data_structure_tests)
add_subdirectory(task_tests)

cc_test(test_egr_forward_autograd SRCS forward_autograd_test.cc DEPS ${eager_deps} ${fluid_deps})
1 change: 1 addition & 0 deletions paddle/fluid/eager/tests/task_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cc_test(test_egr_task_eager_utils SRCS eager_utils_test.cc DEPS ${eager_deps})
cc_test(test_egr_task_forward_autograd SRCS forward_autograd_test.cc DEPS ${eager_deps} ${fluid_deps} eager_scale scale_node)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "paddle/fluid/eager/api/all.h"
#include "paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h"
#include "paddle/fluid/eager/api/utils/tensor_utils.h"
#include "paddle/fluid/eager/autograd_meta.h"
#include "paddle/fluid/eager/grad_node_info.h"
#include "paddle/fluid/eager/tests/test_utils.h"
Expand All @@ -29,6 +30,8 @@
// TODO(jiabin): remove nolint here!!!
using namespace egr; // NOLINT

namespace eager_test {

TEST(Forward, SingleNode) {
// Prepare Device Contexts
InitEnv(paddle::platform::CPUPlace());
Expand All @@ -38,7 +41,7 @@ TEST(Forward, SingleNode) {
paddle::framework::DDim ddim = paddle::framework::make_ddim({4, 16, 16, 32});

// Create Target Tensor
egr::EagerTensor t = EagerUtils::CreateTensorWithValue(
egr::EagerTensor t = CreateTensorWithValue(
ddim, paddle::platform::CPUPlace(), pten::DataType::FLOAT32,
pten::DataLayout::NCHW, 5.0 /*value*/, false /*is_leaf*/);
target_tensors.emplace_back(std::move(t));
Expand Down Expand Up @@ -91,7 +94,7 @@ TEST(Forward, LinearNodes) {
paddle::framework::DDim ddim = paddle::framework::make_ddim({4, 16, 16, 32});

// Create Target Tensor
egr::EagerTensor t = EagerUtils::CreateTensorWithValue(
egr::EagerTensor t = CreateTensorWithValue(
ddim, paddle::platform::CPUPlace(), pten::DataType::FLOAT32,
pten::DataLayout::NCHW, 5.0 /*value*/, false /*is_leaf*/);
target_tensors.emplace_back(std::move(t));
Expand Down Expand Up @@ -186,7 +189,7 @@ TEST(Forward, BranchedNodes) {
paddle::framework::DDim ddim = paddle::framework::make_ddim({4, 16, 16, 32});

// Create Target Tensor
egr::EagerTensor t = EagerUtils::CreateTensorWithValue(
egr::EagerTensor t = CreateTensorWithValue(
ddim, paddle::platform::CPUPlace(), pten::DataType::FLOAT32,
pten::DataLayout::NCHW, 5.0 /*value*/, false /*is_leaf*/);
target_tensors.emplace_back(std::move(t));
Expand Down Expand Up @@ -300,3 +303,5 @@ TEST(Forward, BranchedNodes) {
paddle::platform::errors::Fatal("Node2's edge should point to Node 0"));
}
}

} // namespace eager_test

0 comments on commit 4e208a0

Please sign in to comment.