Skip to content

Commit 5bb7c78

Browse files
committed
Bindings working! We have a starting point to begin with
1 parent 3cecd42 commit 5bb7c78

4 files changed

Lines changed: 47 additions & 28 deletions

File tree

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ RUN ls && cd tensorflow && ls && cd tools && ls
4646

4747
RUN bash ./tensorflow/tools/install.sh
4848

49-
ADD ./ tensorflow
50-
5149
RUN \
5250
rm -rf /var/lib/apt/lists/* && \
5351
rm -rf /var/cache/oracle-jdk8-installer
5452

55-
CMD ["bash"]
53+
ADD ./ tensorflow
54+
55+
56+
# RUN cd tensorflow && npm install && node-gyp configure build
57+
58+
CMD ["bash"]

binding.gyp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
'libraries' : [
77
"<!@(pkg-config --libs protobuf)",
8-
"<!@(find $(pwd)/src/lib -iname \*.lo)"
8+
"<!@(find $(pwd)/src/lib -iname \*.o)",
99
],
1010

1111
'include_dirs' : [
@@ -25,22 +25,32 @@
2525
"xcode_settings": {
2626
"OTHER_CFLAGS": [
2727
"-mmacosx-version-min=10.7",
28-
"-std=c++11",
28+
"-std=c++",
2929
"-stdlib=libc++",
3030
"<!@(pkg-config --cflags protobuf)",
31-
],
31+
],
32+
"OTHER_LDFLAGS": [
33+
'-stdlib=libc++',
34+
],
35+
"OTHER_CPLUSPLUSFLAGS": [
36+
'-std=c++11',
37+
'-stdlib=libc++',
38+
'-v'
39+
],
3240
"GCC_ENABLE_CPP_RTTI": "YES",
33-
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
34-
}
41+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
42+
'MACOSX_DEPLOYMENT_TARGET': '10.9',
43+
},
3544
}]
3645
],
3746
'cflags': [
3847
"<!@(pkg-config --cflags protobuf)",
39-
"-frtti",
4048
],
41-
'cflags!': [
42-
"-fno-rtti",
49+
"cflags!": [
4350
"-fno-exceptions"
51+
],
52+
'cflags_cc!': [
53+
"-fno-rtti", "-fno-exceptions"
4454
]
4555
}]
4656
}

src/api.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
#include <fstream>
88

9+
// #include "tensorflow/core/lib/core/stringpiece.h"
10+
11+
912
#include "tensorflow/cc/ops/const_op.h"
1013
#include "tensorflow/cc/ops/image_ops.h"
1114
#include "tensorflow/cc/ops/standard_ops.h"
@@ -34,14 +37,14 @@ using tensorflow::int32;
3437
// input the model expects. If you train your own model, or use something
3538
// other than GoogLeNet you'll need to update these.
3639
TF_DEFINE_string(image,
37-
"data/grace_hopper.jpg",
40+
"src/data/grace_hopper.jpg",
3841
"The image to classify (JPEG or PNG).");
3942
TF_DEFINE_string(graph,
40-
"data/googlenet_graph.pb",
43+
"src/data/tensorflow_inception_graph.pb",
4144
"The location of the GraphDef file containing the protobuf"
4245
" definition of the network.");
4346
TF_DEFINE_string(labels,
44-
"data/googlenet_labels.txt",
47+
"src/data/imagenet_comp_graph_label_strings.txt",
4548
"A text file containing the labels of all the categories, one"
4649
" per line.");
4750
TF_DEFINE_int32(input_width, 224, "Width of the image the network expects.");
@@ -216,6 +219,8 @@ Status CheckTopLabel(const std::vector<Tensor>& outputs, int expected,
216219
return Status::OK();
217220
}
218221

222+
using namespace v8;
223+
219224
int runTests() {
220225
// We need to call this to set up global state for TensorFlow.
221226
// tensorflow::port::InitMain(argv[0], &argc, &argv);
@@ -227,6 +232,7 @@ int runTests() {
227232

228233
// First we load and initialize the model.
229234
std::unique_ptr<tensorflow::Session> session;
235+
printf("HEY!");
230236
string graph_path = tensorflow::io::JoinPath(FLAGS_root_dir, FLAGS_graph);
231237
Status load_graph_status = LoadGraph(graph_path, &session);
232238
if (!load_graph_status.ok()) {
@@ -283,7 +289,6 @@ int runTests() {
283289
}
284290

285291

286-
using namespace v8;
287292

288293
NAN_METHOD(RunTest) {
289294
printf("\nRunning Test\n");

tools/install.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ clone(){
110110
echo "= cloning $folderName [url: $repo]"
111111

112112
# Remove folder before cloning
113-
# rm -rf $folderName
113+
rm -rf $folderName
114114

115115
# Git clone the repo
116116
git clone --recurse-submodules $repo ./$folderName
@@ -252,25 +252,20 @@ echo ""
252252
echo "= Configuring TensorFlow (GPU: $TENSORFLOW_GPU_ENABLED)"
253253
./configure <<< "n"
254254

255-
# Compile TensorFlow CC
255+
# Compile TensorFlow Core and CC
256256
echo ""
257-
echo "= Compiling TensorFlow:cc"
258-
bazel build //tensorflow/cc:cc_ops
259-
260-
# Compile TensorFlow Core
261-
echo ""
262-
echo "= Compiling TensorFlow:core"
263-
bazel build //tensorflow/core
257+
echo "= Compiling TensorFlow [cc|core]"
258+
bazel build //tensorflow/cc:cc_ops //tensorflow/core:tensorflow
264259

265260
# Compile photobuf
266261
cd "google/protobuf"
267262
echo ""
268263
echo "= Installing Google's protobuf"
269264
if ! pkg-config protobuf --exists; then
270265
./autogen.sh
271-
./configure
266+
./configure --prefix=/usr/local/bin
272267
make
273-
make check
268+
# make check
274269
make install
275270
else
276271
echo "== Skipped. Already installed."
@@ -302,8 +297,14 @@ cp -a tensorflow/tensorflow/core $srcDir/tensorflow
302297
cp -a tensorflow/google/protobuf/src/google $srcDir
303298
cp -a tensorflow/third_party $srcDir
304299

305-
# Copy Libraries (.io)
306-
cp -a tensorflow/bazel-out/host/bin/. $libDir
300+
# Copy Libraries (.o)
301+
mkdir -p $libDir/google
302+
mkdir -p $libDir/external
303+
mkdir -p $libDir/tensorflow
304+
305+
cp -a tensorflow/bazel-bin/google/. $libDir/google
306+
cp -a tensorflow/bazel-bin/external/. $libDir/external
307+
cp -a tensorflow/bazel-bin/tensorflow/. $libDir/tensorflow
307308

308309
# Remove repo folder
309310
rm -rf "tensorflow"

0 commit comments

Comments
 (0)