-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Pycaffe improvements from OpenCL branch #6209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Looks good to me so far. I'll look over it in more detail after one of the Master branch maintainers had a peek. |
FYI: I pulled the remaining commits, sometimes changing them as I saw fit. Updated the description to reflect the changes, added a short summary below to ask about the issues I see right now. Tests should also pass now. |
28a109e
to
abe8689
Compare
abe8689
to
0754447
Compare
@shelhamer @Noiredd
And it will all be exposed to Python. |
Check the current progress here. It is now in a working state: The really great thing about this tweak is that all new data types are accessible, but the old python code written for caffe still works in it's full extent, without any changes needed. So it's even a non-breaking improvement. |
@naibaf7 That is pretty spectacular! Thanks for giving a preview. Will the new numeric types be somehow documented? I did take a look but I'm not sure how to use them. Also, does that render this PR pointless? I won't mind closing if your change will be incorporated in its place. |
@Noiredd Yes the numeric types will be documented. Float16 can already be used equally to float32 and float64, including unit tests (thanks to Intel, @gongzg, who started the float16 implementation; subsequently perfected by my efforts). |
cherry-picked from 984745d Conflicts: python/caffe/_caffe.cpp src/caffe/solver.cpp
cherry-picked from 52732be Conflicts: python/caffe/__init__.py python/caffe/pycaffe.py
cherry-picked from 03276d4 Conflicts: python/caffe/__init__.py
cherry-picked from 96b84b6 fixed syntax error around bp::enum_
cherry-picked from 8719549
cherry-picked from a4c269e removed dependency on MemoryDataLayer modifications Conflicts: python/caffe/__init__.py python/caffe/_caffe.cpp python/caffe/pycaffe.py
cherry-picked from 188aeae
cherry-picked from 77c3428 Conflicts: python/caffe/_caffe.cpp
0754447
to
cd100c0
Compare
@shelhamer What's our status on this? Since we merged #6238, this causes some conflicts. Should I fix those and marge or is there an alternative plan? |
I'm bringing @naibaf7's pycaffe improvements from OpenCL branch to Master. Some pretty cool features have been implemented, most importantly exposure of
SolverParameter
, possibility to reinstatiate Solver, which would address #2766, and even update its parameters on-the-fly (#2686).Somewhat related PRs: #4342, #5549 and #6238.
Unfortunately many of the changes are interleaved with the evolution of that branch itself (modifications of
MemoryDataLayer
, adoption ofint_tp
type, some multi-device stuff, etc.) so it's not possible to just pull them over to master - plenty of conflicts arise due to interdependencies.This is a WIP with a request for feedback or ideas, especially from you @naibaf7 as the original author of those changes. I have tracked the history of OpenCL's pycaffe, dissecting every commit since July 2015, cherry-picking the relevant ones and cleaning them from OpenCL-specific code. Here is my plan of attack for this (ticked the already copied commits):
Python update, Lint fixes.
and d82979bSoftmax fix for >4 shape dims.
A heavy modification of the
MemoryDataLayer
and other stuff which I do not want to incorporate here; however, it exposesSolver::max_iter
and allows passing a layer index inNet_SetInputArrays
, so I just took the relevant pieces as a new commit.Pycaffe check update.
and 5ebebfbPycaffe fixed.
ignored, follow-ups to the
MemoryDataLayer
andint_tp
changesFix for Malis, Softmax.
and 165d231Removed duplicate function.
ignored, irrelevant to Master but introduce some conflicts around
.def("step")
Expose SolverParameter to Python.
This introduces an issue because we already have a binding to
SolverParameter
(added in e21b420Python Multi-GPU
). Since this commit registers a new binding, every time weimport caffe
Python interpreter will now output the following warning:/usr/local/caffe/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for caffe::SolverParameter already registered; second conversion method ignored.
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
I am tempted to remove the old binding (perhaps moving the
layer_wise_reduce
accessor to the new one since unlikemax_iter
anddisplay
it isn't doubled) but I'm not sure what consequences will that have. What do you think @naibaf7?Improved pycaffe interface.
Changes meaning of
get_solver
- will causemake pytest
throw errors until 188aeae is merged.Extended python interface.
ignored, requires some other commit for
Caffe::EnumerateDevices
Merge, stronger PyCaffe interface.
(renamesSolverParam
toSolverParameter
)Multi-device advancements.
ignored, the change only relevant to OpenC's multi-device support
updated pycaffe init
(addsget_solver_from_file
to__init__.py
)Expose snapshot format to python
(I fixed a minor syntax error here)Python expose layers like blobs.
with its lint fixing commits, c65e85b and 6b88d6f, and a bugfix 8719549Adds
Net_SetLayerInputArrays
which is specific to OpenCL'sMemoryDataLayer
modifications. For now I rolled back the function to use legacy accessors, but let me know if you have a better idea.Python interface extensions.
Exposes
NetParameter
andNetState
. I made sure the changes toNet_Init_Load
andNet_SetLayerInputArrays
it introduces stay in line with the rollback.PyCaffe fixes for solver interface, ensure GIL lock in python layer.
Solves test problems introduced in e2f8e70, also changes behavior of the Python layer. Tests pass however so I'm leaving this for now.
Python NetSpec extension for layer bundles
and its bugfix, 1d82ba2ignored, it looks like an OpenCL specific thing. Am I right, @naibaf7?
LINT fixes.
ignored, a large collection of fixes which will instead be put in respective commits
Removed duplicate layer parameter in PyCaffe.
ignored, it fixes duplicated
LayerParameter
which does not appear here (for some reason)PyCaffe fixes.
ignored, I fixed lint stuff on the fly, and changes to
draw.py
already are in masterFix MSVC error for PyCaffe.
-- is this needed on master too?SolverParameter
binding to avoid the "already registered" issue.I'd like to hear comments on:
SolverParameter
issue? (for now I removed the old binding, moving thelayer_wise_reduce
accessor to the new one)EDIT: rebased this to most recent master,
added the exposed.ApplyUpdate
method