Hi, my name is Rob, this is the link here.
We'll try to convince you that if you're using arrow or per k or something in that ecosystem,
you should try a patchy, I mean, you should try tensor arrays to store your tensor data or multi-dimensional array data.
So our talk will compose and shortly talking about error attention times,
then we'll talk about fixed-shaped tensor, variable-shaped tensor,
a little bit about the integration with numpy, and then finally the alpac.
So what are arrow extension types?
So arrow currently provides several data times, but of course, people always want more.
So at some point we decided to add user extension types to enable people to build their own.
However, because some extension types are more often used than others,
we also decided to make a registry of well-known extension types,
or rather canonical types that live in the arrow namespace.
And with the current implement, we have implement that arrow fixed-shaped tensor,
arrow variable-shaped tensor, json, opaque, and a bit bullet.
These are currently available specs for extension arrays.
So let's first talk about the fixed-shaped tensor.
So, fixed-shaped tensor arrays are multi-dimensional arrays of certain type,
and we represent them in arrow with the fixed-sized list,
which means that we have an array where you can see this.
Each row is set of values, and there need to be as many values as there are.
If you multiply all the shape numbers, right?
So if you have a 2 by 2 tensor, you should have 4 values there.
And besides the date itself, we also carry a metadata which is the shape of these tensors.
And, actually, we also bring dimension names and permutation,
so permutation kind of helps you to calculate strides of the tensors out of the shape.
Yeah, basically that's it.
Data itself is stored in this fixed-sized list,
in order to call this second, second-figuous or row major order.
So that means that you can slice the array, right?
And you can each of these rows is a second-figuous data for a tensor.
So every cell in this array is a tensor by cell, right?
So here's an example of how many of that of such a tensor arrays is serialized.
So we have shape, we have the names of dimensions, and then the permutation of dimensions.
So, out of the permutation, again, you can calculate the strides of the tensors.
Now, on to the second one, the variable shape tensor array.
So this case is a little bit more complicated.
Every row of the array is struck,
because not only do we carry the data of the tensors,
we also need to carry its shape.
So the way that struck the arrays are done in arrow,
it basically means you have two child arrays next to each other.
Correct me if I'm wrong guys.
Yeah? Yeah, okay.
So these are, yeah, we carry them.
And one contains the actual data.
Was I muted?
Yes.
Oh.
There goes our promotions.
High stream, nice to meet you.
So yeah, the variable.
So the first we have the data, as the first child array in the second child array,
carries the shape of each individual tensor.
Besides that, we also carry, of course, the dimension names,
permutations to again to calculate strides out of the shapes.
And then we have this uniform shape.
So this is in case we only one of the dimensions is being changed in the data.
Let's say you don't need to read the whole shape every for every row.
And data is also stored in row major or contiguous,
secontiguous order.
So here's an example of the uniform shape parameter.
You can see that, like, the here the convention is the first,
the first value of shape will always be 400.
The second one can change the third one will always be three.
So when the reader or writer, when the reader works with this,
they don't need to read the first and third parameter.
Yeah, oh yeah.
And here the shape changes from row to row,
but the dimension number always stays the same.
That was kind of the design decision that we made.
Yeah, and to you, Alenko.
Okay, so this is strange because this is for video.
And I have to.
The this canonical extension type, the fixed shape one is implemented in C++,
ROC++, and it has bindings in Python.
So we can check it out play with it.
I thought it would be nice to have an example of Python because it's nice to visualize.
Here we import, we define which type we want.
This is the extension type that's already in pyro.
You can use it, you have to tell it which data type you need and you tell the shape of individual tensor.
Then you give it the data from wherever you need it.
And you define the storage type, which is as we saw the list.
It has to have the same data type and the length of the list has to match.
So then you define the extension the extension area out of this function with this method.
So you go from storage, which is the list created out with the data.
And then you give it the tensor type you need.
Thank you.
I had to trim it out a little bit, so it would be visible.
This is how the object looks like in pyro if you print it out.
So there's a list and each element of the list is a tensor element of the area of the tensor type.
Now if you go to numpy, you can see it's an end the array with the shape 422.
And if you go back, the four shape is the length of the array.
Okay, is that clear?
Yeah, so the first dimension is the length of the array.
And then you have individual elements which are individual rows, tensors in the pyro will then if you go back to numpy to numpy.
Yeah, so this are the individual tensors in the pyro array.
Okay, and then you can also have a numpy and end the array and go back.
So you go forward.
Another one, another one.
Yes.
So you could also have a numpy array and go back to the pyro tensor array.
Okay, so you can go fourth and back between.
Okay, so this is for an example.
I hope that was useful.
I would like to take a minute or so full deal pack deal pack is a protocol.
And then it enables interchange between python libraries that have arrays, the array libraries or tensor libraries.
To have a device aware.
So you can live on CPU or GPU.
It's aware of that and it's it's meant to be on a zero copy interchange.
We would like to have this nicely implemented in arrow and pyro also for now it's implemented for pyro for arrow arrays.
Only to produce we would like to have the consumption also.
And we would like to connect this extension tensor arrays with this methods to have the seamless interchange between other python libraries that use tensors.
For example, Q pythons of role pythorge, etc.
Okay, so now it's implemented for arrays.
You can go from pyro array to any of those.
So consumption you can.
Sorry to use you could go into any of those.
But not go back and it's not implemented for the extension arrays yet, but that's what we would like to do.
If there's any wish for that and thumbs up, that would be awesome.
Thank you.