Fixed tabbing

This commit is contained in:
Davis King 2017-07-24 10:01:30 -04:00
parent b4853ce449
commit 968818748a
1 changed files with 23 additions and 21 deletions

View File

@ -1946,36 +1946,38 @@ namespace dlib
}
}
}
// ------------------------------------------------------------------------------------
void copy_tensor(
void copy_tensor(
tensor& dest,
size_t dest_k_offset,
const tensor& src,
size_t src_k_offset,
size_t count_k
)
{
const size_t dest_sample_size = static_cast<size_t>(dest.nc() * dest.nr() * dest.k());
const size_t src_sample_size = static_cast<size_t>(src.nc() * src.nr() * src.k());
const size_t block_size = count_k * dest.nc() * dest.nr();
DLIB_CASSERT(dest.num_samples() == src.num_samples() &&
dest.nc() == src.nc() && dest.nr() == src.nr(), "All sources should fit into dest tensor size");
DLIB_CASSERT(dest.k() - dest_k_offset >= count_k, "Not enough space in dest tensor");
DLIB_CASSERT(src.k() - src_k_offset >= count_k, "Not enough space in src tensor");
float* dest_p = dest.host() + dest_k_offset * dest.nc() * dest.nr();
const float* src_p = src.host() + src_k_offset * src.nc() * src.nr();
for (long i = 0; i < src.num_samples(); ++i)
)
{
::memcpy(dest_p, src_p, block_size * sizeof(float));
const size_t dest_sample_size = static_cast<size_t>(dest.nc() * dest.nr() * dest.k());
const size_t src_sample_size = static_cast<size_t>(src.nc() * src.nr() * src.k());
dest_p += dest_sample_size;
src_p += src_sample_size;
const size_t block_size = count_k * dest.nc() * dest.nr();
DLIB_CASSERT(dest.num_samples() == src.num_samples() &&
dest.nc() == src.nc() && dest.nr() == src.nr(), "All sources should fit into dest tensor size");
DLIB_CASSERT(dest.k() - dest_k_offset >= count_k, "Not enough space in dest tensor");
DLIB_CASSERT(src.k() - src_k_offset >= count_k, "Not enough space in src tensor");
float* dest_p = dest.host() + dest_k_offset * dest.nc() * dest.nr();
const float* src_p = src.host() + src_k_offset * src.nc() * src.nr();
for (long i = 0; i < src.num_samples(); ++i)
{
::memcpy(dest_p, src_p, block_size * sizeof(float));
dest_p += dest_sample_size;
src_p += src_sample_size;
}
}
}
// ------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------