12#ifdef INCLUDE_TENSORFLOW
13# include <tensorflow/compiler/xla/array2d.h>
22#if !defined(INCLUDE_TENSORFLOW) && 0
26class Array2D :
public std::vector<T> {
28 Array2D() :
std::vector<T>(
std::vector<int64_t>{0, 0}) {}
30 Array2D(
const int64_t n1,
const int64_t n2) :
std::vector<T>(
std::vector<int64_t>{n1, n2}) {}
32 Array2D(
const int64_t n1,
const int64_t n2,
const T
value) :
std::vector<T>({n1, n2},
value) {}
40 std::locale::global(std::locale(
""));
43#ifdef INCLUDE_TENSORFLOW
46 std::unique_ptr<xla::Array2D<int>> SetupArray(
int ysize,
int xsize,
int start) {
47 std::unique_ptr<xla::Array2D<int>> a(
new xla::Array2D<int>(ysize, xsize));
49 for (
int y = 0;
y < ysize; ++
y) {
50 for (
int x = 0;
x < xsize; ++
x) {
51# ifdef INCLUDE_TENSORFLOW
66#ifdef INCLUDE_TENSORFLOW
67 std::vector<std::unique_ptr<xla::Array2D<int>>> arrays;
68 arrays.push_back(SetupArray(3, 4, 0));
69 arrays.push_back(SetupArray(4, 5, 12));
70 arrays.push_back(SetupArray(4, 4, 32));
71 arrays.push_back(SetupArray(3, 5, 48));
72 std::vector<std::pair<int, int>> h_w_sizes;
73 for (
size_t i = 0;
i < arrays.size(); ++
i) {
74 h_w_sizes.emplace_back(arrays[
i].get()->height(), arrays[
i].get()->width());
125 LOG(
INFO) <<
"Skip test because of missing xla::Array2D";
133#ifdef INCLUDE_TENSORFLOW
134 std::vector<std::unique_ptr<xla::Array2D<int>>> arrays;
135 arrays.push_back(SetupArray(3, 4, 0));
136 arrays.push_back(SetupArray(4, 5, 12));
137 arrays.push_back(SetupArray(4, 4, 32));
138 arrays.push_back(SetupArray(3, 5, 48));
139 std::vector<std::pair<int, int>> h_w_sizes;
140 for (
size_t i = 0;
i < arrays.size(); ++
i) {
141 h_w_sizes.emplace_back(arrays[
i].get()->height(), arrays[
i].get()->width());
147 std::vector<int> values_x2 = {0, 1, 4, 5, 8, 9, 12, 13, 17, 18, 22, 23, 27, 28,
148 32, 33, 36, 37, 40, 41, 44, 45, 48, 49, 53, 54, 58, 59};
154 int expected_value = values_x2[pos++];
160 test_map = stride_map;
162 std::vector<int> values_y2 = {0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
163 32, 33, 34, 35, 36, 37, 38, 39, 48, 49, 50, 51, 52};
168 int expected_value = values_y2[pos++];
174 test_map = stride_map;
176 std::vector<int> values_xy2 = {0, 1, 12, 13, 17, 18, 32, 33, 36, 37, 48, 49};
181 int expected_value = values_xy2[pos++];
187 test_map = stride_map;
189 std::vector<int> values_x_to_1 = {0, 4, 8, 12, 17, 22, 27, 32, 36, 40, 44, 48, 53, 58};
194 int expected_value = values_x_to_1[pos++];
200 LOG(
INFO) <<
"Skip test because of missing xla::Array2D";
#define EXPECT_EQ(val1, val2)
#define EXPECT_GE(val1, val2)
#define EXPECT_TRUE(condition)
#define EXPECT_FALSE(condition)
TEST_F(EuroText, FastLatinOCR)
void ScaleXY(int x_factor, int y_factor)
void SetStride(const std::vector< std::pair< int, int > > &h_w_pairs)
int index(FlexDimensions dimension) const
bool AddOffset(int offset, FlexDimensions dimension)
bool IsLast(FlexDimensions dimension) const