-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support nogc concatenation in the outermost dimension #3
Comments
This is slow. ByElement is random access range, but it is slow for random access. |
why would it have to be used in a random-access way? auto a=range0.sliced(m, n0) alternative: auto c=catAllocating(a,b)[2..$-1, 2..$-1].transposed.imwrite("result.jpg"); this is not good as not only it allocates, but it has to call byElement twice: once at the concatenation, and once at the end (inside materializing to an array in imwrite) |
See section
It is possible to implement fast version with input range primitives. However |
But you will be able to use fast version to save images. |
i think I see what you're trying to say: I agree with that but i think it's good to give user the option to allocate or not in this case. Furthermore, instead of
//apologies if it already exists in std.experimental.ndslice, but couldnt' find it! Then: we don't need catAllocating, we can just call:
|
What is the use case for concatenation without allocation? |
Concrete example inspired from http://jackstouffer.com/blog/nd_slice.html "This function does not calculate border cases in which a window overlaps the image partially. However, the function can still be used to carry out such calculations. That can be done by creating an amplified image, with the edges reflected from the original image" This is a perfect use case of cat (at least in the case of upper and lower borders):
[1] same rationale as "only to be assembled at the very end to avoid unnecessary allocations" in http://jackstouffer.com/blog/nd_slice.html |
This is my example. And I am 99.99% sure that median filter will be faster with allocation. |
I know :-), and I like it :-)
haven't tried w your example but see this simple test: https://github.com/timotheecour/dtools/blob/master/dtools/scratch/bench_ndslice/test1.d I'm obviously not saying it'll always be faster without reallocate after cat, but that it can definitely be faster, so that makes it worth it to provide as a library for user. User can choose to reallocate or not for his use case. |
Lazy cat of Slice over Iota (It not allocated at memory at all) VS Lazy cat + allocation into memory. Fair: BTW: indexSlice could help to create fast lazy cat. |
the speedup was also 2X when I replaced:
with
Also, I made a more real-world example, see updated code in The speedup with lazy cat is now 1.4X in this example. I will take a look at indexSlice. |
The idea is to propagate Slice primitives over a simple generic Cat (with multidimensonal |
Partially solved by stack. We can add |
libmir/mir-algorithm#29 fixes this issue. auto s = stack!dim(...);
auto v = s.indexed(s.shape.ndiota);
static assert(isSlice!(typeof(v))); This is more accurate and faster then |
constant padding was added libmir/mir-algorithm#31 |
edge, symmetric and wrap paddings libmir/mir-algorithm#32 |
algo:
generalizes trivially to variadic arguments
The text was updated successfully, but these errors were encountered: