Skip to content

Comments

Suppress boost registration warnings in pycaffe#3960

Closed
TanLingxiao wants to merge 1 commit intoBVLC:masterfrom
TanLingxiao:patch-2
Closed

Suppress boost registration warnings in pycaffe#3960
TanLingxiao wants to merge 1 commit intoBVLC:masterfrom
TanLingxiao:patch-2

Conversation

@TanLingxiao
Copy link

I change four palces like 'const boost::python::type_info ainfo = boost::python::type_id<shared_ptr<Net > >();
const boost::python::converter::registration* areg = boost::python::converter::registry::query(ainfo);
if (areg == NULL)
{
bp::register_ptr_to_python<shared_ptr<Net > >();
}
else if ((*areg).m_to_python == NULL) {
bp::register_ptr_to_python<shared_ptr<Net > >();
} '
It can avoided some problems when use 'make pycaffe' command.

I change four palces like  'const boost::python::type_info ainfo = boost::python::type_id<shared_ptr<Net<Dtype> > >();
  const boost::python::converter::registration* areg = boost::python::converter::registry::query(ainfo);
  if (areg == NULL)
  {
     bp::register_ptr_to_python<shared_ptr<Net<Dtype> > >();
  }
  else if ((*areg).m_to_python == NULL) {
     bp::register_ptr_to_python<shared_ptr<Net<Dtype> > >();
  } '
It can avoided some problems when use 'make pycaffe' command.
@shelhamer shelhamer changed the title Update _caffe.cpp Suppress boost registration warnings in pycaffe Apr 8, 2016
@shelhamer
Copy link
Member

@TanLingxiao Make sure to lint, and please compare to the related #3866.

At first glance this looks like it will be compatible across boost versions, but it's too bad this (apparently) has to be so verbose.

@seanbell
Copy link

seanbell commented Apr 9, 2016

If this is the same pattern used in 4 places, maybe this can be made into a macro?

@seanbell
Copy link

Something like this?

/* Fix to avoid registration warnings in pycaffe (#3960) */
#define BP_REGISTER_SHARED_PTR_TO_PYTHON(PTR) do { \
  const boost::python::type_info info = \
    boost::python::type_id<shared_ptr<PTR > >(); \
  const boost::python::converter::registration* reg = \
    boost::python::converter::registry::query(info); \
  if (reg == NULL) { \
     bp::register_ptr_to_python<shared_ptr<PTR > >(); \
  } else if ((*reg).m_to_python == NULL) { \
     bp::register_ptr_to_python<shared_ptr<PTR > >(); \
  } \
} while (0)

...
BP_REGISTER_SHARED_PTR_TO_PYTHON(Net<Dtype>);
...
BP_REGISTER_SHARED_PTR_TO_PYTHON(Blob<Dtype>);
...
BP_REGISTER_SHARED_PTR_TO_PYTHON(Layer<Dtype>);
...
BP_REGISTER_SHARED_PTR_TO_PYTHON(Solver<Dtype>);
...

Note: the do {} while(0) makes the macro behave like a statement.

Also, please run make lint before any PRs, to ensure that the style matches the existing codebase.

@seanbell
Copy link

Ping? It would be great to get this warning fixed; it adds unnecessary noise to log files and to tutorials for caffe (explaining that the warning can be ignored).

@shelhamer
Copy link
Member

@seanbell yeah, I'd be fine with a linted version of this patch turned into a macro. It would be good to resolve this, so we'll have to see if it can be dispatched sometime soon while having a coffee between NIPS experiments.

@seanbell
Copy link

seanbell commented Apr 28, 2016

I made a PR at #4069, containing the above fix turned into a macro.

shelhamer added a commit that referenced this pull request Apr 28, 2016
suppress boost registration warnings in pycaffe (based on #3960)
@shelhamer
Copy link
Member

Closed by fix in #4069 based on this patch. Thanks @TanLingxiao for first suggesting this.

@shelhamer shelhamer closed this Apr 28, 2016
@hongweipeng
Copy link

I don't know why you received email from me

@TanLingxiao
Copy link
Author

It is interesting. @hongweipeng

misaka-10032 pushed a commit to misaka-10032/caffe that referenced this pull request Jul 8, 2016
fxbit pushed a commit to Yodigram/caffe that referenced this pull request Sep 1, 2016
fxbit pushed a commit to Yodigram/caffe that referenced this pull request Sep 1, 2016
suppress boost registration warnings in pycaffe (based on BVLC#3960)
zouxiaochuan pushed a commit to zouxiaochuan/caffe that referenced this pull request Oct 24, 2016
zouxiaochuan pushed a commit to zouxiaochuan/caffe that referenced this pull request Oct 24, 2016
zouxiaochuan pushed a commit to zouxiaochuan/caffe that referenced this pull request Feb 15, 2017
zouxiaochuan pushed a commit to zouxiaochuan/caffe that referenced this pull request Feb 15, 2017
zouxiaochuan pushed a commit to zouxiaochuan/caffe that referenced this pull request Feb 15, 2017
acmiyaguchi pushed a commit to acmiyaguchi/caffe that referenced this pull request Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants