Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Caffe without the patch, cpp-package fixed also with Caffe plugin #5573

Merged
merged 36 commits into from
Mar 31, 2017
Merged

Caffe without the patch, cpp-package fixed also with Caffe plugin #5573

merged 36 commits into from
Mar 31, 2017

Conversation

cjolivier01
Copy link
Member

No description provided.

@@ -35,19 +35,19 @@ class Lenet {
Convolution("conv1", data, conv1_w, conv1_b, Shape(5, 5), 20);
Symbol tanh1 = Activation("tanh1", conv1, ActivationActType::tanh);
Symbol pool1 = Pooling("pool1", tanh1, Shape(2, 2), PoolingPoolType::max,
false, PoolingPoolingConvention::valid, Shape(2, 2));
false, false, PoolingPoolingConvention::valid, Shape(2, 2));
Copy link
Member Author

@cjolivier01 cjolivier01 Mar 26, 2017

Choose a reason for hiding this comment

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

What should the default here be? I assume it's false like the default in the declaration.
parameter is: bool cudnn_off = false

@@ -43,7 +46,7 @@ Symbol getConv(const std::string & name, Symbol data,
kernel, num_filter, stride, Shape(1, 1),
pad, 1, 512);

Symbol bn = BatchNorm(name + "_bn", conv, 2e-5, bn_momentum, false);
Symbol bn = BatchNorm(name + "_bn", conv, BN_GAMMA, BN_BETA, 2e-5, bn_momentum, false);
Copy link
Member Author

@cjolivier01 cjolivier01 Mar 26, 2017

Choose a reason for hiding this comment

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

What is the desired default gamma and beta? These weren't in the older versions.

inline Symbol BatchNorm(const std::string& symbol_name,
Symbol data,
Symbol gamma,
Symbol beta,
mx_float eps = 0.001,
mx_float momentum = 0.9,
bool fix_gamma = true,
bool use_global_stats = false,
bool output_mean_var = false) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Gamma and beta are learnable parameters that can be initialized automatically by initializer, but op.h genereator can't distinguish parameters from hyperparameters currently, as mxnet doesn't provide such information. In older versions, gamma and beta were not declared explicitly. We can use Operator("BatchNorm") here to avoid specifying gamma and beta before figuring out how to detect parameters.

@@ -905,8 +905,6 @@ GraphExecutor::CachedSegOpr GraphExecutor::CreateCachedSegOpr(size_t topo_start,
// you need to copy it out. (potential memory leak risk)
char *p_opr_name = new char[opr_names.size() + 1];
memcpy(p_opr_name, opr_names.c_str(), opr_names.size() + 1);
#else
Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't necessary and generates a warning

@cjolivier01
Copy link
Member Author

Fixing lint...

@cjolivier01
Copy link
Member Author

travis appears to be broken (nohup)

@cjolivier01 cjolivier01 reopened this Mar 26, 2017
@@ -14,8 +14,8 @@
#include "mxnet-cpp/kvstore.h"
#include "mxnet-cpp/optimizer.h"

#ifndef KVSTORE_HPP
#define KVSTORE_HPP
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_KVSTORE_HPP_
Copy link
Member Author

Choose a reason for hiding this comment

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

These are lint fixes which captured problems in the original cpp-package headers

Copy link
Contributor

@piiswrong piiswrong Mar 26, 2017

Choose a reason for hiding this comment

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

you can make lint ignore CPP_PACKAGE_INCLUDE, it's done for r-package for example

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. I went ahead and fixed it so that we could have some clean, homogenous code.

@@ -199,7 +199,7 @@ class BucketSentenceIter : public DataIter {
public:
BucketSentenceIter(string filename, int minibatch, Context context) : batch(minibatch),
current(-1), device(context) {
auto& content = readContent(filename);
auto content = readContent(filename);
Copy link
Member Author

Choose a reason for hiding this comment

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

This was incorrectly taking a reference of a temporary

@@ -343,7 +343,8 @@ class BucketSentenceIter : public DataIter {
chars.push_back(c);
}
}
return {map, chars};
// Note: Can't use {} because this would hit the explicit constructor
return tuple<unordered_map<wchar_t, mx_float>, vector<wchar_t>>(map, chars);
Copy link
Member Author

Choose a reason for hiding this comment

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

My gcc-5.4 won't allow this

Makefile Outdated
@@ -133,7 +138,7 @@ endif
.PHONY: clean all test lint doc clean_all rcpplint rcppexport roxygen\
cython2 cython3 cython cyclean

all: lib/libmxnet.a lib/libmxnet.so $(BIN)
all: lib/libmxnet.a lib/libmxnet.so $(BIN) cpp-package-example-all
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't build cpp-package by default

Copy link
Contributor

Choose a reason for hiding this comment

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

It only generates a header file for cpp-package, and is necessary since updates that break cpp-package will be reflected in the test..

Copy link
Member Author

Choose a reason for hiding this comment

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

are cpp-package tests run during CI builds? I think they they probably aren't because they didn't build at all. In the meantime, how will we keep people from "breaking" these compiliables again?

Copy link
Member Author

Choose a reason for hiding this comment

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

How about we just build lenet by default? At any rate, the build for all of them is quick -- a few seconds.

Copy link
Member Author

Choose a reason for hiding this comment

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

Or you mean a config.mk flag and w can turn it on for the CI build? That might be ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

If someone changes operator api, cpp-package test will fail since op.h changes after building cpp-package.

@piiswrong
Copy link
Contributor

@lx75249

@piiswrong
Copy link
Contributor

piiswrong commented Mar 26, 2017 via email

@@ -0,0 +1,2 @@
# Rebuildable file(s)
op.h
Copy link
Contributor

Choose a reason for hiding this comment

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

This will force everyone to build the whole library..

Copy link
Member Author

@cjolivier01 cjolivier01 Mar 27, 2017

Choose a reason for hiding this comment

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

I am a little confused. The expectation is that someone will check out the mxnet source tree and include directly from mxnet/cpp-package/include, but dynamically load the libmxnet.so that came with their pip install rather than one that they built locally? That seems unlikely and dangerous, correct? I expect development on mxnet to accelerate in the near future and a widely-distributed libmxnet.so to not be in sync for long (as well as inconsistencies with caffe plugin, etc.).
The cmake build "distributes" mxnet headers during a build if INSTALL_INCLUDE_DIR is defined as a path, although not yet for cpp-package. If we're going to make a distribution like apt-get install mxnet-dev, I would expect that we can deploy the built op.h

wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes you're right...

@piiswrong
Copy link
Contributor

@lx75249 @cjolivier01 Is this good for merging?

@cjolivier01
Copy link
Member Author

Fixing build things. Also, need to do Operator("BatchNorm")

@cjolivier01
Copy link
Member Author

other checkin of ft.cc contrib operator broke the build on Windows, libcufft library not linked. Added to cmake.

@piiswrong piiswrong merged commit a5abd79 into apache:master Mar 31, 2017
piiswrong added a commit that referenced this pull request Mar 31, 2017
piiswrong added a commit that referenced this pull request Apr 3, 2017
* Revert "Caffe without the patch, cpp-package fixed also with Caffe plugin (#5573)"

This reverts commit a5abd79.

* Revert "Revert "contrib fft,ifft,countsketch (#5563)" (#5634)"

This reverts commit 7f688f7.
Guneet-Dhillon pushed a commit to Guneet-Dhillon/mxnet that referenced this pull request Sep 13, 2017
…ache#5573)

* PEP8 indentation fix

* Remove executable flag

* Remove executable flags

* Fixing cpp-package including problems with caffe converter

* Fix warnings

* Remove need for caffe patch for caffe plugin

* Ignore cmake paths, remove rebuildable op.h for cpp-package

* cpp-package examples fixed. Makefile and CMake of op.h and examples added.

* cpp-package examples fixed. Makefile and CMake of op.h and examples added.

* Fix source file

* Better example.mk

* Turn off caffe by default

* lint fixes

* Trying to figure out how to fix submodules

* nohub problem on travis so force retry

* Edited test to just run make instead of obsolete make example

* Fix cpp-package op.h bootstrapping with CMake

* Build tweaking cpp-package

* Lint fixes

* op.h generator

* FIx cpp-package for latest merge from master

* Fix lint

* static link

* link whole static lib

* Trigger another build attempt

* Trigger another build attempt

* Add caffe plugin support (disabled until dependencies can be added to build machine)

* Add cufft library

* win32 cufft library

* don't link unit tests as static

* Add include for rebuildable protobuf header caffe.pb.h
Guneet-Dhillon pushed a commit to Guneet-Dhillon/mxnet that referenced this pull request Sep 13, 2017
* Revert "Caffe without the patch, cpp-package fixed also with Caffe plugin (apache#5573)"

This reverts commit a5abd79.

* Revert "Revert "contrib fft,ifft,countsketch (apache#5563)" (apache#5634)"

This reverts commit 7f688f7.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants