MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/core/framework/tensor_util_test.cc:31–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29namespace {
30
31TEST(TensorUtil, DeepCopy0d) {
32 Tensor x(DT_FLOAT, TensorShape({}));
33 x.scalar<float>()() = 10.0;
34
35 // Make y a deep copy of x and then change it.
36 Tensor y = tensor::DeepCopy(x);
37 y.scalar<float>()() = 20.0;
38
39 // x doesn't change
40 EXPECT_EQ(10.0, x.scalar<float>()());
41
42 // Change x.
43 x.scalar<float>()() = 30.0;
44
45 // Y doesn't change.
46 EXPECT_EQ(20.0, y.scalar<float>()());
47
48 Tensor z = tensor::DeepCopy(y);
49
50 // Change y.
51 y.scalar<float>()() = 40.0;
52
53 // The final states should all be different.
54 EXPECT_EQ(20.0, z.scalar<float>()());
55 EXPECT_EQ(30.0, x.scalar<float>()());
56 EXPECT_EQ(40.0, y.scalar<float>()());
57
58 // Should have the same shape and type.
59 EXPECT_EQ(TensorShape({}), x.shape());
60 EXPECT_EQ(TensorShape({}), y.shape());
61 EXPECT_EQ(TensorShape({}), z.shape());
62
63 EXPECT_EQ(DT_FLOAT, x.dtype());
64 EXPECT_EQ(DT_FLOAT, y.dtype());
65 EXPECT_EQ(DT_FLOAT, z.dtype());
66}
67
68TEST(TensorUtil, DeepCopyZeroElements) {
69 Tensor x;

Callers

nothing calls this directly

Calls 15

CreateTensorProtoFunction · 0.85
TensorShapeClass · 0.70
DeepCopyFunction · 0.70
TensorClass · 0.70
ConcatFunction · 0.70
SplitFunction · 0.70
StrCatFunction · 0.50
shapeMethod · 0.45
dtypeMethod · 0.45
NumElementsMethod · 0.45
SliceMethod · 0.45

Tested by

no test coverage detected