Great Guys ! I see there is some enthousiame from the gurus into binding PDL and Shogun.(there is also Pybrain which is a nice tool of the same mind, but keep it for later!).
I have uploaded some of my fine code in the github... https://github.com/ptizoom/shogun.git branch perl_swig_120921 the most interresting files are ... ./src/interfaces/perldl_modular/pdl.i ./src/interfaces/perldl_modular/swig_typemaps.i beware those are under construction, and I only managed so far to parse a dense vector/matrix in (perl->sg) and out (sg->swig) , but using SWIG, and within the Shogun package, and not using this Inline::PP or so... I can see I will need great advises : -threads, locking, referering: Shogun has its nice ways, but PDL also. now, there is always a memcopy(), used naively for dense objects transfer in/out; but I wonder, if one can reuse this nmap() shared memory business down the line. may be it is a matter in "shogun". although shogun can handle stream data objects (aka nmap())... -slices and sparse objects will be a pain: shogun seems to use a (sorted) map index-value... I do not see yet how to nicely bind sparse n-arry in general ... please give me an example! - shogun does not use parent-children mechanisme: may be this is ok... -shogun does not use autoconf macro and this is a pain to port!! In summary, I seems I have gone done the way to link PDL to shogun, but if you can smartly do a Inline::PP, to link shogun to PDL, it would loop the loop, and in respect it would provide examples to support different approach of binding the packages. so long, Christian Montanari. On Tue, Oct 09, 2012 at 12:01:35PM -0500, David Mertens wrote: > Ah, sorry to David for not forwarding this sooner. > > ---------- Forwarded message ---------- > From: David Oswald <[email protected]> > Date: Mon, Oct 8, 2012 at 12:26 AM > Subject: Re: [Perldl] SWIG and PDL - api > To: David Mertens <[email protected]> > > > I'm not quite sure who I should respond to, so maybe you could forward this. > > I've only spend maybe a half hour looking over SHOGUN docs and code, > and don't have PDL experience. With those caveats: > > One way to interface the SHOGUN toolbox with Perl is by using > Inline::CPP to write wrappers for the classes. However, because some > of the shogun classes and methods are template-based, and also because > of the use of function overloading in the API classes, C++ wrappers > will need to be written to coerce the library's classes and methods > into something more compatible with Inline::CPP's parsing, and Perl's > XS (Inline::CPP can't parse template clases, Perl doesn't do function > overloading... just some basic paradigm mismatches that would have to > be wrapped). The wrappers themselves wouldn't be terribly complex, > but the size of the library is big enough that we're looking at a "big > job". > > If the Wx people have already solved the template issue or the > function overloading issue, they might get you farther along with less > work. Inline::CPP would really trivialize the writing of the > wrappers, but there are a lot of them, and that itself is non-trivial. > > I can't really comment on how it would interface with PDL. > > > > On Sun, Oct 7, 2012 at 8:33 PM, David Mertens <[email protected]> > wrote: > > Forwarding since [email protected] does not allow non-members to send > > mail. > > > > David (Mertens) > > > > On Sun, Oct 7, 2012 at 9:27 PM, David Oswald <[email protected]> wrote: > >> On Sun, Oct 7, 2012 at 6:30 PM, David Mertens <[email protected]> > >> wrote: > >>> BTW, another person who has plenty of experience interfacing Perl and > >>> C++ is David Oswald, the current maintainer of Inline::CPP. He's done > >>> some fantastic work lately on Inline::CPP (dusting off a pretty old > >>> module and bringing it into the modern era) so he may have encountered > >>> some corners that you find yourself in. > >>> > >>> David > >> > >> I'm going to take a look at this, and will let you know if Inline::CPP > >> looks like a reasonable fit. I have no experience with PDL, but as > >> David mentioned, I've had a healthy dose of Inline::CPP. The best > >> case scenario is that the AUTO_WRAP feature will do all the dirty > >> work. The worst case, I wouldn't want to think about. Most likely > >> the reality will fall somewhere between those two points. :) > >> > >> Dave > >> > >> > >>> > >>> On Sun, Oct 7, 2012 at 8:27 PM, David Mertens <[email protected]> > >>> wrote: > >>>> Christian - > >>>> > >>>> I'm sorry nobody has responded sooner to your query, but it's a pretty > >>>> tough question, so I'm not terribly surprised. :-) > >>>> > >>>> For anybody else following along, the shogun project Christian refers > >>>> to is the Shogun Machine Learning Toolbox: > >>>> http://www.shogun-toolbox.org/doc/en/current/index.html. SHOGUN > >>>> supports multiple languages: "SHOGUN is implemented in C++ and > >>>> interfaces to Matlab(tm), R, Octave and Python." And Lua, btw. > >>>> > >>>> Having scanned the docs briefly (especially the developer tutorial: > >>>> http://www.shogun-toolbox.org/doc/en/current/developer_tutorial.html), > >>>> I think that the best route would be to create Perl wrappers for the > >>>> Shogun classes. The Wx folks have extensive experience doing this. You > >>>> should start by looking at http://p3rl.org/ExtUtils::XSpp, and then > >>>> possibly hopping on the Wx and/or Padre mailing lists or IRC channels. > >>>> > >>>> Then, you would want some way to interface PDL data with SHOGUN > >>>> SGMatrix objects. There are a few options here. (1) Create a function > >>>> that copies from one to the other and back. (2) Create a handful of > >>>> PDL wrappers of SGMatrix classes, which requires a little bit of PDL > >>>> (black?) magic, but not much. I could probably point you to useful > >>>> code in this respect. (3) Create a set of C++ classes that know how to > >>>> wrap PDL data in a form derived from SGMatrix. The main drawback here > >>>> is that you would then have to properly handle slices, which is why I > >>>> would prefer the second idea to this third one. > >>>> > >>>> A bystander might ask: why not just wrap SHOGUN's methods into PDL > >>>> routines? Well, SHOGUN uses C++'s object orientation pretty > >>>> extensively, so trying to wrap the SHOGUN methods into PDL methods > >>>> would be very difficult, and very much exploratory. There's a lot of > >>>> meta-information that you'd have to slog around, and keeping track of > >>>> it all---while doable using the header hash, maybe---would likely be a > >>>> suboptimal solution. > >>>> > >>>> So, I propose you aim to create a Perl wrapper for project. Talk to > >>>> the Wx people and get their advice. Once that's working, you can > >>>> quickly hack together a means to copy data between PDL and SHOGUN, and > >>>> then aim for a PDL-side wrapper of the SHOGUN data types. > >>>> > >>>> David > >>>> > >>>> On Fri, Oct 5, 2012 at 4:41 AM, Christian Montanari > >>>> <[email protected]> wrote: > >>>>> Hi, > >>>>> I am attempting to tie the "shogun" package to PDL. > >>>>> "shogun" has already many classes used in PDL, mainly of course, data > >>>>> formats, but also IO classes, so those packages are a tat similare. > >>>>> however PDL is for data parsing, while "shogun" is more for developing > >>>>> algorithms using data. > >>>>> > >>>>> so far I managed a rough interface (it links!), but I am still not > >>>>> very confident in the inner guts of the wrappers. > >>>>> > >>>>> I am looking for advices or support from a PDL experts but > >>>>> particularely nice source code examples for specific usage. > >>>>> > >>>>> I found somewhat the pdl-api is missing a few goodies and I would not > >>>>> mind any expert in the art of PDL show some example of use of...: > >>>>> > >>>>> - affine functions used for parsing PDL structures? > >>>>> > >>>>> - pdl-api for inline operations > >>>>> > >>>>> - strings , storage or RV referenced perl-objects in pdl ? > >>>>> > >>>>> - pdl-api for slices ? > >>>>> > >>>>> - best use of the "threading" > >>>>> > >>>>> - relations beetween pdl data, datasv , sv, hdrsv. > >>>>> > >>>>> - sparse format (sparse vector, matrix, n-gram...) (ie: map/hash (or > >>>>> tie) of arrays index/ranges > >>>>> to pdl.data ) > >>>>> > >>>>> - sub - pdl organisation ? > >>>>> > >>>>> I have somewhat partial answers to a few of those, but might not be > >>>>> the best and the pretiest! > >>>>> > >>>>> also I have two ways to embed te packages: do I wrap PDL into "shogun" > >>>>> or > >>>>> vice versa? (the first I am using a "swig - perl" wrapper, but for the > >>>>> other I suppose one has to use the wonderfull .PL mechanisme!) > >>>>> > >>>>> please, if you are interrested to develop a wrapper likewise, I am > >>>>> happy to send you my 'git' project, or please share your examples.... > >>>>> > >>>>> Thanks for your time. > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> _______________________________________________ > >>>>> Perldl mailing list > >>>>> [email protected] > >>>>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > >>>> > >>>> > >>>> > >>> > >>> > >>> > >> > >> > >> > >> -- > >> > >> David Oswald > >> [email protected] > > > -- ------------------------------------------------------- Dr. Christian Montanari, Consulting Engineer, Hillebrand Consulting Engineers GmbH _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
