| 29 | namespace eager_test { |
| 30 | |
| 31 | inline paddle::Tensor CreateTensorWithValue(const phi::DDim& ddim, |
| 32 | const phi::Place& place, |
| 33 | const phi::DataType& dtype, |
| 34 | const phi::DataLayout& layout, |
| 35 | float value, |
| 36 | bool is_leaf = true) { |
| 37 | paddle::Tensor out = |
| 38 | paddle::experimental::full(common::vectorize(ddim), |
| 39 | paddle::experimental::Scalar(value), |
| 40 | dtype, |
| 41 | place); |
| 42 | |
| 43 | auto meta = egr::EagerUtils::autograd_meta(&out); |
| 44 | if (is_leaf) { |
| 45 | auto accumulation_node = std::make_shared<egr::GradNodeAccumulation>(out); |
| 46 | meta->SetGradNode(accumulation_node); |
| 47 | meta->SetStopGradient(false); |
| 48 | } |
| 49 | |
| 50 | return out; |
| 51 | } |
| 52 | |
| 53 | template <typename T> |
| 54 | bool CompareGradTensorWithValue(const paddle::Tensor& target, T value) { |
no test coverage detected