26 #ifndef LBANN_TRANSFORMS_VISION_UNIT_TEST_HELPER 27 #define LBANN_TRANSFORMS_VISION_UNIT_TEST_HELPER 36 std::function<
void(uint8_t&, El::Int, El::Int, El::Int)> f)
38 uint8_t* buf = mat.Buffer();
39 for (El::Int channel = 0; channel < channels; ++channel) {
40 for (El::Int col = 0; col < width; ++col) {
41 for (El::Int row = 0; row < height; ++row) {
42 f(buf[channels * (col + row * width) + channel], row, col, channel);
53 mat.Resize(height * width * channels, 1);
58 [](uint8_t& x, El::Int row, El::Int col, El::Int) {
59 x = (row == col) ? 1 : 0;
63 inline void zeros(El::Matrix<uint8_t>& mat,
68 mat.Resize(height * width * channels, 1);
69 uint8_t* buf = mat.Buffer();
70 for (El::Int i = 0; i < height * width * channels; ++i) {
75 inline void ones(El::Matrix<uint8_t>& mat,
80 mat.Resize(height * width * channels, 1);
81 uint8_t* buf = mat.Buffer();
82 for (El::Int i = 0; i < height * width * channels; ++i) {
87 inline void print(
const El::Matrix<uint8_t>& mat,
92 const uint8_t* buf = mat.LockedBuffer();
93 for (El::Int channel = 0; channel < channels; ++channel) {
94 for (El::Int col = 0; col < width; ++col) {
95 for (El::Int row = 0; row < height; ++row) {
96 std::cout << ((int)buf[channels * (col + row * width) + channel])
99 std::cout << std::endl;
101 std::cout <<
"--" << std::endl;
105 #endif // LBANN_TRANSFORMS_VISION_UNIT_TEST_HELPER void ones(El::Matrix< uint8_t > &mat, El::Int height, El::Int width, El::Int channels=1)
void identity(El::Matrix< uint8_t > &mat, El::Int height, El::Int width, El::Int channels=1)
void print(const El::Matrix< uint8_t > &mat, El::Int height, El::Int width, El::Int channels=1)
void apply_elementwise(El::Matrix< uint8_t > &mat, El::Int height, El::Int width, El::Int channels, std::function< void(uint8_t &, El::Int, El::Int, El::Int)> f)
void zeros(El::Matrix< uint8_t > &mat, El::Int height, El::Int width, El::Int channels=1)