MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / TEST

Function TEST

test/cpp/eager/task_tests/generated_test.cc:37–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35namespace egr {
36
37TEST(Generated, Sigmoid) {
38 // Prepare Device Contexts
39 eager_test::InitEnv(phi::CPUPlace());
40 VLOG(6) << "Init Env";
41 // 1. Prepare Input
42 phi::DDim ddim = common::make_ddim({2, 4, 4, 4});
43 VLOG(6) << "Make Dim";
44 paddle::Tensor tensor =
45 eager_test::CreateTensorWithValue(ddim,
46 phi::CPUPlace(),
47 phi::DataType::FLOAT32,
48 phi::DataLayout::NCHW,
49 0.0,
50 true);
51 VLOG(6) << "Make paddle::Tensor";
52 egr_utils_api::RetainGradForTensor(tensor);
53 VLOG(6) << "Retain Grad for Tensor";
54 auto output_tensor = sigmoid_dygraph_function(tensor, {});
55 VLOG(6) << "Run Backward";
56 eager_test::CompareTensorWithValue<float>(output_tensor, 0.5);
57
58 std::vector<paddle::Tensor> target_tensors = {output_tensor};
59 VLOG(6) << "Running Backward";
60 Backward(target_tensors, {});
61
62 VLOG(6) << "Finish Backward";
63 eager_test::CompareGradTensorWithValue<float>(tensor, 0.25);
64}
65
66TEST(Generated, Matmul_v2) {
67 // Prepare Device Contexts

Callers

nothing calls this directly

Calls 7

InitEnvFunction · 0.85
make_ddimFunction · 0.85
CreateTensorWithValueFunction · 0.85
RetainGradForTensorFunction · 0.85
BackwardFunction · 0.85
SetCurrentTracerFunction · 0.85
CPUPlaceClass · 0.50

Tested by

no test coverage detected