MCPcopy Create free account
hub / github.com/davisking/dlib / test_input_tensor

Function test_input_tensor

dlib/test/dnn.cpp:5724–5754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5722 }
5723
5724 void test_input_tensor()
5725 {
5726 using namespace dlib::tt;
5727 print_spinner();
5728 tt::tensor_rand rnd;
5729 std::vector<resizable_tensor> tensors(3);
5730
5731 for (auto& t : tensors) {
5732 t.set_size(1, 3, 224, 224);
5733 rnd.fill_gaussian(t);
5734 }
5735
5736 resizable_tensor out;
5737 input_tensor input_layer;
5738
5739 input_layer.to_tensor(tensors.begin(), tensors.end(), out);
5740
5741 DLIB_TEST(out.num_samples() == 3);
5742 DLIB_TEST(out.k() == 3);
5743 DLIB_TEST(out.nr() == 224);
5744 DLIB_TEST(out.nc() == 224);
5745 size_t stride = out.k() * out.nr() * out.nc();
5746 size_t offset = 0;
5747 int error = 0;
5748
5749 for (auto& t : tensors) {
5750 error = memcmp(out.host() + offset, t.host(), sizeof(float) * t.size());
5751 DLIB_TEST(error == 0);
5752 offset += stride;
5753 }
5754 }
5755
5756// ----------------------------------------------------------------------------------------
5757

Callers 1

run_testsMethod · 0.85

Calls 11

print_spinnerFunction · 0.85
set_sizeMethod · 0.45
to_tensorMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
num_samplesMethod · 0.45
kMethod · 0.45
nrMethod · 0.45
ncMethod · 0.45
hostMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected