MCPcopy Create free account
hub / github.com/apache/singa / ForwardConcatColumnTest

Function ForwardConcatColumnTest

test/singa/test_concat.cc:65–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65void ForwardConcatColumnTest(std::shared_ptr<singa::Device> dev) {
66 size_t a = 2u, b = 1u, c = 3u;
67 singa::Tensor t1({c, a}, dev);
68 singa::Tensor t2({c, b}, dev);
69 singa::LayerConf conf;
70 conf.set_type("singa_concat");
71 conf.mutable_concat_conf()->set_axis(1);
72 singa::Concat layer;
73 layer.Setup({{a}, {b}}, conf);
74 layer.ToDevice(dev);
75
76 t1.SetValue(1.0f);
77 t2.SetValue(2.0f);
78 auto out = layer.Forward(singa::kTrain, {t1, t2});
79 EXPECT_EQ(out.size(), 1u);
80 out[0].ToHost();
81 const float* outptr = out[0].data<float>();
82 for (size_t i = 0; i < c; i++) {
83 for (size_t j = 0; j < a; j++)
84 EXPECT_FLOAT_EQ(outptr[i * (a + b) + j], 1.0f);
85 }
86 for (size_t i = 0; i < c; i++) {
87 for (size_t j = a; j < a + b; j++)
88 EXPECT_FLOAT_EQ(outptr[i * (a + b) + j], 2.0f);
89 }
90}
91TEST(Concat, ForwardConcatRowCpp) {
92 ForwardConcatRowTest(singa::defaultDevice);
93}

Callers 1

TESTFunction · 0.85

Calls 6

ToHostMethod · 0.80
SetupMethod · 0.45
ToDeviceMethod · 0.45
SetValueMethod · 0.45
ForwardMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected