Dear Karl,
Karl Rupp <[email protected]> writes:
> * Installation: Works nicely from the PPA, no problems with my Linux
> Mint Maya (based on Ubuntu 12.04, so this is expected).
Good! :)
> * Found the PyViennaCL documentation, but it was *not* installed
> automatically, but listed as 'suggested' package. I think this can be
> addressed in the installation instructions and does not require a change
> in behavior.
Sure, I only listed it as suggested because the HTML docs are the same
as what you get if you do "import pyviennacl; help(pyviennacl)" in the
interpreter, which I expect people to do.
> * Okay, so let's try to print individual elements of A and B:
> A(1,1); # error!
> A.item(1,1); # error!
> A[1,1]; # returns pyviennacl.pycore.HostScalar information
> print(A[1,1]); # works!
> Okay, this was a bit lengthy, we should have some more 'newbie
> information' in the docs :-)
Hmm.. I think I might set it so that doing 'A[1,1]' at the interpreter
prompt prints the object, rather than the class info; but see below for
more about this. Also be aware that PyViennaCL supports ranges and
slices :)
> * Let's assign some elements:
> A[1,1].assign(2.0); # error: Cannot assign to HostScalar
> A[1,1] = 2.0; # same
> Here I searched the docs and found that it's not possible to assign
> stuff directly. Okay, so I created a numpy array (which I had to look up
> how to do that, of course ;-) ) and got:
> Drow = numpy.array([1, 2, 3, 4, 5]);
For convenience, the numpy.array function is aliased in PyViennaCL as
pyviennacl.array. Also, you can do this to be clear about the 'dtype':
>>> Drow = p.array([1, 2, 3, 4, 5], dtype=p.float64)
(which converts the integers to the float64 (double) type)
> D = numpy.array([Drow, Drow, Drow, Drow, Drow]);
> C = B + A; # error!
> Type conversion tricked me, A became a matrix of integers. Here I see
> the motivation for allowing mixed precision operations in ViennaCL
> asap... Alright, so restart with
> Drow = numpy.array([1.0, 2.0, 3.0, 4.0, 5.0]);
> D = numpy.array([Drow, Drow, Drow, Drow, Drow]);
> C = B + A;
Did you mean
>>> C = D + A
? Because that works, too! (ie, you can add PyViennaCL and NumPy
matrices together, as long as they have compatible sizes and types)
> Okay, let's stop here for now. Summary: Great, simple operations just
> work nicely and it integrates well in the Python environment. What can
> be done to make the user experience even better?
> - Allow element-wise manipulation. Sure, this is terribly slow, but it
> helps a lot with prototyping, which is an important use case with
> Python.
Mrrgh. OK :)
> - Provide a few 'first steps' tutorials with the documentation. If
> that's already there and I simply couldn't find it, make it more
> visible. This way more emphasis is on the 'get simple stuff going'
> rather than internals of the scheduler which people won't read through
> for a start.
Yes, I should probably do this. In large part, I was relying on people
knowing NumPy and assuming that PyViennaCL would be similar -- but a few
such tutorials certainly wouldn't go amiss.
> - Ideally, each of the items in the linalg package has a short code
> snippet on how to call/use it.
> - Correct the version number in the 'PyViennaCL 1.5.0 documentation'
> string in the HTML docs. ;-)
OK.
> - Think about numeric type conversions. If a numpy-array of numeric
> type T1 is assigned to a PyViennaCL matrix of type T2, should the
> PyViennaCL matrix change to T1? Maybe issue a warning?
The thing is, in Python, you don't tend to create objects and then
assign values to them -- both happen at the same time, and the things
you manipulate are really just references. So if you create a Matrix A,
and then try to use the = operator to assign something else to it, you
just change the thing that A refers to (and if the old Matrix has no
other references, it is deleted). I think this is what is happening when
you talk about the PyViennaCL matrix "changing" :)
In PyViennaCL, you can just about get around this, by doing something
like `A[:,:] = B`, but that at least forces you to be explicit about the
assignment. If you have A and B of different dtypes in this example, you
get a TypeError exception saying "Cannot assign across different
dtypes!".
If you want to be very careful about the numeric types, you can wrap
every number you write in a dtype:
>>> a = p.Matrix(5, 5, p.float32(0.5)) * p.float32(2.0)
>>> a.value
array([[ 1., 1., 1., 1., 1.],
[ 1., 1., 1., 1., 1.],
[ 1., 1., 1., 1., 1.],
[ 1., 1., 1., 1., 1.],
[ 1., 1., 1., 1., 1.]], dtype=float32)
Also note that the way I recommend getting access to the values of
objects at the interpreter is by using the ".value" attribute, because
this does separate the container object A and whatever data A contains,
and because the expression-tree representation of a lot of PyViennaCL
stuff means that even if the object A contains matrix data, its type
might not be Matrix, but an expression Node subclass, like Add..
In any case, as I say, I could change this -- but I think it should be
easy to be aware of the slightly different semantics here, in case
debugging is needed. I suppose people always have the "type" keyword...
This does remind me that there is one thing I ought to fix:
>>> A = p.Matrix(10, 10, 0.5)
>>> B = p.Matrix(10, 10, 0.9)
>>> C = A + B
>>> D = p.Matrix(5, 5, 3.0)
>>> C[0:5,6:10] = D
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'Add' object does not support item assignment
>>> C[0:5, 6:10]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'Add' object has no attribute '__getitem__'
> Anyway, I think we are pretty close to a release here, I'll give the
> whole installation a try on Windows as well :-)
Thanks. I've yet to try on Windows, so I suspect you'll have some
errors...
Best,
Toby
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
ViennaCL-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/viennacl-devel