| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Signed-off-by: Phidias Chiang <phidias.chiang@gmail.com>
Previous commit does constant mode outside of for-loop, therefore the if-else block in for-loop is not necessary anymore. The diff looks a mess but it just reduces the indent. Signed-off-by: Phidias Chiang <phidias.chiang@gmail.com>
There was a problem hiding this comment.
Thanks @keeper for this initial step. With some work I'm sure we can come up with a nice ways to avoid the costly reallocations.
Some discussion points:
Sorry, something went wrong.
When using constant mode, `auto out = e;` is never used and it causes extra overhead, move it after constant mode handling fixes this. Signed-off-by: Phidias Chiang <phidias.chiang@gmail.com>
Suggestion from: xtensor-stack#1808 (comment) Signed-off-by: Phidias Chiang <phidias.chiang@gmail.com>
|
Sorry for late response.
I did had some compile errors when passing const xarray<T> & to xt::pad() with my version, so I think I'm not dealing with the type in xt::pad() correctly and that's an issue I need to resolve. I'll attach the compile error.
You are right about assigning the value twice, after correcting the issue it is as fast as Numpy :)
I'm sorry that I can't answer this question just yet. I'm not familiar with other modes and need to understand them first, then I can figure out with what approach I may be able to optimize them.
And I'm afraid that I don't fully understand your question. For "branch", do you mean the code path it goes? For example in my implementation when the mode is constant it goes to a block of code for constant mode and return the result, and other modes go their paths? If that's the case I think I prefer this way. But it's just a personal preference when handling different cases.
Neither do I, but it sounds interesting. My only concern is, doesn't it make xt::pad() depend on xsimd? -- [1]: compile log: https://gist.github.com/keeper/32728c812782a44a0cfb81eab068543a |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for tackling this!
General remarks regarding SIMD assignment:
This means that when dealing with SIMD assignment, the only matter to consider is whether the classes involved in the assignment provide a load_simd method or not. If they do, vectorized assignment should work out of the box.
Sorry, something went wrong.
|
@keeper Thanks indeed once more.
My strategy was to do algorithm depend stuff as deep down as possible. Most algorithms just constitute to selecting a different set of indices from the input matrix, the rest of the implementation in generic. This is however somewhat different from constant, as it does not rely on selecting a part of the input matrix. So it could make sense to implement constant differently from the rest. |
Sorry, something went wrong.
|
@keeper I applied your code also to the other pad-modes. I think that this version should be a lot more efficient. Thanks for you help! |
Sorry, something went wrong.
There was a problem hiding this comment.
The minor changes listed below, that could improve performance, can be implemented in a dedicated PR. Indeed this one has been opened for a while, so I'm in favor of merging it.
Sorry, something went wrong.
|
Thanks @JohanMabille ! I integrated your comments. Let's merge once everything turns green. Some further reformatting is needed in the future to make some of the modes recursive. I think I can do it quickly for wrap using the same approach as I used for xt::tile. At the same time I think that neither symmetric nor reflect can be recursive. Or is it just my imagination that is lacking? |
Sorry, something went wrong.
|
I don't see either how it is possible. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This pull request aims to reduce the overhead of xt::pad by creating a new container with padded shape, then copying the source object into the new container when using constant mode.
For example, when padding a 3x3 matrix with ((1, 1), (2, 2)), firstly a 5x7 matrix is created, then the original 3x3 matrix will be put into new_maxtrix[1:4, 2:5].
Although this code passed unittest, however here are something need to be dealt with:
Any suggestions would be appreciated!
Edit:
Fixes #1806