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

Function ForwardConcatRowTest

test/singa/test_concat.cc:39–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39void ForwardConcatRowTest(std::shared_ptr<singa::Device> dev) {
40 size_t a = 2u, b = 1u, c = 3u;
41 singa::Tensor t1({a, c}, dev);
42 singa::Tensor t2({b, c}, dev);
43 singa::LayerConf conf;
44 conf.set_type("singa_concat");
45 conf.mutable_concat_conf()->set_axis(0);
46 singa::Concat layer;
47 layer.Setup({{c}, {c}}, conf);
48 layer.ToDevice(dev);
49
50 t1.SetValue(1.0f);
51 t2.SetValue(2.0f);
52 auto out = layer.Forward(singa::kTrain, {t1, t2});
53 EXPECT_EQ(out.size(), 1u);
54
55 out[0].ToHost();
56 const float* outptr = out[0].data<float>();
57 for (size_t i = 0; i < a; i++) {
58 for (size_t j = 0; j < c; j++) EXPECT_FLOAT_EQ(outptr[i * c + j], 1.0f);
59 }
60 for (size_t i = a; i < a + b; i++) {
61 for (size_t j = 0; j < c; j++) EXPECT_FLOAT_EQ(outptr[i * c + j], 2.0f);
62 }
63}
64
65void ForwardConcatColumnTest(std::shared_ptr<singa::Device> dev) {
66 size_t a = 2u, b = 1u, c = 3u;

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