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

Function CreateTensorWithValue

test/cpp/eager/test_utils.h:31–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29namespace eager_test {
30
31inline 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
53template <typename T>
54bool CompareGradTensorWithValue(const paddle::Tensor& target, T value) {

Callers 15

TESTFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
test_sigmoidFunction · 0.85
test_elementwiseAddFunction · 0.85
test_matmulFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85

Calls 5

vectorizeFunction · 0.85
ScalarClass · 0.85
fullFunction · 0.50
SetGradNodeMethod · 0.45
SetStopGradientMethod · 0.45

Tested by

no test coverage detected