Skip to content

Commit

Permalink
Add code from tensorflow/models
Browse files Browse the repository at this point in the history
The new code was copied from the latest code on GitHub
(https://github.com/tensorflow/models/tree/master/research/syntaxnet).

It is required for pango_font_info_test and other unit tests.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jun 28, 2019
1 parent 7093727 commit 0702194
Show file tree
Hide file tree
Showing 9 changed files with 1,849 additions and 0 deletions.
61 changes: 61 additions & 0 deletions unittest/syntaxnet/base.h
@@ -0,0 +1,61 @@
/* Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef SYNTAXNET_BASE_H_
#define SYNTAXNET_BASE_H_

#include <functional>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include "google/protobuf/util/message_differencer.h"


#include "tensorflow/core/lib/core/status.h"
#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/default/integral_types.h"
#include "tensorflow/core/platform/mutex.h"
#include "tensorflow/core/platform/protobuf.h"



using tensorflow::int8;
using tensorflow::int16;
using tensorflow::int32;
using tensorflow::int64;
using tensorflow::uint8;
using tensorflow::uint16;
using tensorflow::uint64;
using tensorflow::uint32;
using tensorflow::protobuf::TextFormat;
using tensorflow::mutex_lock;
using tensorflow::mutex;
using std::map;
using std::pair;
using std::vector;
using std::unordered_map;
using std::unordered_set;
typedef signed int char32;

using tensorflow::StringPiece;
using std::string;


// namespace syntaxnet

#endif // SYNTAXNET_BASE_H_

3 comments on commit 0702194

@Shreeshrii
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unittests are failing. Do I need to download/install tensorflow?

g++ -DHAVE_CONFIG_H -I. -I../../unittest -I..  -DNDEBUG -DTESSBIN_DIR="\"/home/ubuntu/tesseract/bin\"" -DLANGDATA_DIR="\"/home/ubuntu/langdata_lstm\"" -DTESSDATA_DIR="\"/home/ubuntu/tessdata\"" -DTESSDATA_BEST_DIR="\"/home/ubuntu/tessdata_best\"" -DTESTING_DIR="\"/home/ubuntu/tesseract/test/testing\"" -DTESTDATA_DIR="\"/home/ubuntu/tesseract/test/testdata\"" -DPANGO_ENABLE_ENGINE  -I../src/api -I../../src/api -I../../src/arch -I../../src/ccmain -I../../src/ccstruct -I../../src/ccutil -I../../src/classify -I../../src/cutil -I../../src/dict -I../../src/display -I../../src/lstm -I../../src/textord -I../../unittest/base -I../../unittest/util -I../../src/training -I../../src/viewer -I../../src/wordrec -I../../abseil -isystem ../../googletest/googletest/include -isystem ../../googletest/googlemock/include -I/usr/include/leptonica   -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/powerpc64le-linux-gnu/glib-2.0/include -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/powerpc64le-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16  -g -O2 -Wall -Wextra -Wpedantic -std=c++17 -MT normstrngs_test.o -MD -MP -MF $depbase.Tpo -c -o normstrngs_test.o ../../unittest/normstrngs_test.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from ../../unittest/util/utf8/unilib.h:35:0,
                 from ../../unittest/normstrngs_test.cc:18:
../../unittest/syntaxnet/base.h:28:10: fatal error: tensorflow/core/lib/core/status.h: No such file or directory
 #include "tensorflow/core/lib/core/status.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:1752: recipe for target 'normstrngs_test.o' failed
make[2]: *** [normstrngs_test.o] Error 1
make[2]: Leaving directory '/home/ubuntu/tesseract/bin/unittest'
Makefile:2441: recipe for target 'check-am' failed

@stweil
Copy link
Contributor Author

@stweil stweil commented on 0702194 Jun 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, I did not notice that those new code requires Tensorflow headers. Yes, installing the package libtensorflow-dev should fix that. Git master now handles missing Tensorflow for the unittests.

@Shreeshrii
Copy link
Collaborator

@Shreeshrii Shreeshrii commented on 0702194 Jun 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried installing the debian package for libtensorflow-dev on ubuntu, but there are a number of unmet dependencies.

Thank you for changing Git master to handle missing Tensorflow.

Edit: I had also installed Tensorflow and have linked header files from there via

 sudo ln -s  ~/my_tensorflow/venv/lib/python3.6/site-packages/tensorflow/include/tensorflow /usr/local/include/tensorflow

Please sign in to comment.