| 35 | namespace egr { |
| 36 | |
| 37 | TEST(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 | |
| 66 | TEST(Generated, Matmul_v2) { |
| 67 | // Prepare Device Contexts |
nothing calls this directly
no test coverage detected