-
Notifications
You must be signed in to change notification settings - Fork 5
Subtensor Home
This project aims to add subtensor
in the existing tensor
implementation in Boost.uBLAS. The tensor implementation does not allow the user to take arbitrary tensor slices and use them in expressions. These slices only represent but do not own the parent tensor from which they were created. The project aims to provide the functionality similar as illustrated in this piece of code.
auto ts = dynamic_tensor<float>{3, 4, 5, 20};
auto subts = ts(span(2), span(0, end), span(2, 4), span(0));
The above expression creates a subtensor
of the tensor
ts where the entries i
,j
correspond to index 2 in the first dimension of ts
, index i
in the second dimension, j+2
in the third dimension, and 0
in the fourth dimension.
The created subtensor
subts
only reference the elements held by ts
as a view, and elements of ts
are not copied. Moreover, the created subtensor
has to behave exactly like a tensor
in expressions.
The project scope as decided by my mentor Cem Bassoy and Me was to provide a stable and well tested implementation for both dynamic_tensor
and static_rank_tensor
. The latter shall become the base for implementing submatrices
and subvectors
.
The previous implementation in Boost.uBLAS had a special subtensor
type. This made it hard to extend the subtensor type to behave like a tensor in as it would require a lot of code duplication.
But In my project proposal I highlighted another way to create subtensor i.e to model it as an engine to tensor
objects. Thus the first part of my project was to finalize this idea with my mentor and to check the feasibility for this idea.
Therefore we went through many iterations of the subtensor_engine
in terms of template parameters finally landing on the type:
template<typename T>
subtensor_engine;
Where T
is the type of the parent tensor. Therefore the type of a subtensor would be as follows:
`tensor_core<subtensor_engine<parent_engine_type>>
When we create a subtensor of subtensor the type shall remain the same.
For more information I shall point you to the following discussions
- https://github.com/BoostGSoC21/ublas/discussions/29
- https://github.com/BoostGSoC21/ublas/discussions/27
As mentioned the project had scope of creating subtensor types for both static_rank_tensor
and dynamic_rank_tensor
. Here are the links to the respective docs:
To have expressiveness in creating subtensors
there must be a way to create tensor spans(subtensors
) that are easy to reason and think about. This is where auxiliary types such as span
come in place. Earlier the span
type had two interfaces span<sliced>
and span<strided>
. My proposal was to merge these two into one cohesive span
type.
Here is the link to the documentation of the span
type:
I believe that this implementation would be a welcome addition in Boost.uBlas and would become a part of the library.
Due to time constraints I wasn't able to implement iterators for subtensor during Google Summer of Code, so I'll be working on that in the future along with the various other span
types for creating subtensors such as all()
, keep()
etc. As mentioned before, The subtensor implementation done during this Summer of Code shall provide the base for submatrix and subvectors. I believed I have learned a lot during this GSoC and would like to extend thanks to my mentor Cem Bassoy for the help he provided in this project.
We both would like to thank our mentor Cem Bassoy for his constant support and help in achieving our milestones. From conducting regular meetings and providing indispensable information and suggestions, to the helpfulness in always answering our queries we always find him extremely helpful and his contribution towards our projects is massive. We are grateful for the time and efforts he devoted towards our projects. We would also like to thank Google for the Google Summer of Code Programme, without which all these wouldn't be possible. We would like to take the opportunity to thank the members of the of Boost Community for letting us be a part of this wonderful journey.