Re: I need some help for my DCV update

2021-12-11 Thread 9il via Digitalmars-d-learn
On Saturday, 27 November 2021 at 12:16:39 UTC, Ferhat Kurtulmuş 
wrote:
On Saturday, 27 November 2021 at 11:35:21 UTC, Salih Dincer 
wrote:


I also found similar errors but couldn't solve them. I think 
it has to do with mir.slice.kind. Exactly Kind Topology...


I won't use parallel for it as a workaround until it is solved 
in the mir-algorithm.


Linker bug is a compiler bug. We can only find a workaround. The 
best workaround is to avoid using ndiota with std.parallelism.


Re: I need some help for my DCV update

2021-11-27 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Saturday, 27 November 2021 at 11:35:21 UTC, Salih Dincer wrote:

I also found similar errors but couldn't solve them. I think it 
has to do with mir.slice.kind. Exactly Kind Topology...


I won't use parallel for it as a workaround until it is solved in 
the mir-algorithm.


Re: I need some help for my DCV update

2021-11-27 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 27 November 2021 at 11:19:18 UTC, Ferhat Kurtulmuş 
wrote:
On Friday, 26 November 2021 at 09:16:56 UTC, Ferhat Kurtulmuş 
wrote:
I am working on the DCV to make it compilable with the recent 
versions of LDC, mir libraries, and stuff. I have not yet 
simply forked it to work on it. I am including modules one by 
one for my convenience instead. Hope, I am close to the end. 
Here is my temporary repo:


https://github.com/aferust/ddcv



After dealing with, various problems, it turns out the main 
problem was ndiota with pool.parallel.

https://github.com/aferust/ddcv/blob/main/source/dcv/imgproc/filter.d#L564
```
foreach (row; /*pool.parallel(*/ndiota(input.shape)/*)*/) // 
parallel loop causes a linker error

{
row.each!(i => calcGradientsImpl(fx[i], fy[i], mag[i], 
orient[i]));

}
```
The parallel loop causes a linker error here?

 error LNK2019: unresolved external symbol 
_D3mir7ndslice5slice__T9mir_sliceTSQBhQBg8iterator__T13FieldIteratorTSQCqQCp5field__T11ndIotaFieldVmi2ZQsZQCbVmi1VEQEjQEiQEd14mir_slice_kindi2ZQEq__T10lightScopeZQnMxFNaNbNdNiNfZSQGvQGuQGp__TQGmTQGfVmi1VQDli2ZQHe referenced in function _D3mir7ndslice5slice__T9mir_sliceTSQBhQBg8iterator__T13FieldIteratorTSQCqQCp5field__T11ndIotaFieldVmi2ZQsZQCbVmi1VEQEjQEiQEd14mir_slice_kindi2ZQEq__T8opEqualsTQEvVQBxi2ZQuMxFNaNbNiNeKxSQHbQHaQGv__TQGsTQGlVmi1VQDri2ZQHkZb

.dub\build\application-debug-windows-x86_64-ldc_v1.28.0-24645713CE34BFE817BFD3D964187D0E\ddcv.exe
 : fatal error LNK1120: 1 unresolved externals


I also found similar errors but couldn't solve them. I think it 
has to do with mir.slice.kind. Exactly Kind Topology...


Re: I need some help for my DCV update

2021-11-27 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 26 November 2021 at 09:16:56 UTC, Ferhat Kurtulmuş 
wrote:
I am working on the DCV to make it compilable with the recent 
versions of LDC, mir libraries, and stuff. I have not yet 
simply forked it to work on it. I am including modules one by 
one for my convenience instead. Hope, I am close to the end. 
Here is my temporary repo:


https://github.com/aferust/ddcv



After dealing with, various problems, it turns out the main 
problem was ndiota with pool.parallel.

https://github.com/aferust/ddcv/blob/main/source/dcv/imgproc/filter.d#L564
```
foreach (row; /*pool.parallel(*/ndiota(input.shape)/*)*/) // 
parallel loop causes a linker error

{
row.each!(i => calcGradientsImpl(fx[i], fy[i], mag[i], 
orient[i]));

}
```
The parallel loop causes a linker error here?

 error LNK2019: unresolved external symbol 
_D3mir7ndslice5slice__T9mir_sliceTSQBhQBg8iterator__T13FieldIteratorTSQCqQCp5field__T11ndIotaFieldVmi2ZQsZQCbVmi1VEQEjQEiQEd14mir_slice_kindi2ZQEq__T10lightScopeZQnMxFNaNbNdNiNfZSQGvQGuQGp__TQGmTQGfVmi1VQDli2ZQHe referenced in function _D3mir7ndslice5slice__T9mir_sliceTSQBhQBg8iterator__T13FieldIteratorTSQCqQCp5field__T11ndIotaFieldVmi2ZQsZQCbVmi1VEQEjQEiQEd14mir_slice_kindi2ZQEq__T8opEqualsTQEvVQBxi2ZQuMxFNaNbNiNeKxSQHbQHaQGv__TQGsTQGlVmi1VQDri2ZQHkZb

.dub\build\application-debug-windows-x86_64-ldc_v1.28.0-24645713CE34BFE817BFD3D964187D0E\ddcv.exe
 : fatal error LNK1120: 1 unresolved externals


Re: I need some help for my DCV update

2021-11-26 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Friday, 26 November 2021 at 09:31:42 UTC, drug wrote:

On 26.11.2021 12:16, Ferhat Kurtulmuş wrote:


InputTensor = Slice!(ubyte*, 2LU, mir_slice_kind.contiguous) 
and KernelTensor = Slice!(float*, 2LU, 
mir_slice_kind.contiguous). The key argument of slices is a 
pointee type - InputTensor pointee has ubyte type and 
KernelTensor has float. I'm not sure this solves your problem 
but at least I'd start from here.


Yes, but this is how the original code was written.


Re: I need some help for my DCV update

2021-11-26 Thread drug via Digitalmars-d-learn

On 26.11.2021 12:16, Ferhat Kurtulmuş wrote:
I am working on the DCV to make it compilable with the recent versions 
of LDC, mir libraries, and stuff. I have not yet simply forked it to 
work on it. I am including modules one by one for my convenience 
instead. Hope, I am close to the end. Here is my temporary repo:


https://github.com/aferust/ddcv

I run into some problems with module convolution, especially the 
function conv invoked by the below code which calls canny edge filter:

```
Image image = imread("lena.png");
auto slice = image.sliced.rgb2gray;
//auto equalized = slice.histEqualize(slice.flattened.calcHistogram);

slice.asImage.imshow("Original");
auto edge = slice.canny!ubyte(15);
edge.asImage.imshow("edge");
waitKey();
```
Somehow, the compiler fails in deducting the types. I need some help 
from Ilya or other people familiar with mir.ndslice.


To reproduce it, download my repo and try to compile it as it is. There 
is a main with the test code in the repo. Just be sure you have a 
glfw3.dll/.so.


```
source\dcv\imgproc\filter.d(547,18): Error: template 
`dcv.imgproc.convolution.conv` cannot deduce function from argument 
types `!()(Slice!(ubyte*, 2LU, mir_slice_kind.contiguous), 
Slice!(float*, 2LU, mir_slice_kind.contiguous), Slice!(float*, 2LU, 
mir_slice_kind.contiguous), Slice!(float*, 2LU, 
mir_slice_kind.contiguous), TaskPool)`
source\dcv\imgproc\filter.d(548,18): Error: template 
`dcv.imgproc.convolution.conv` cannot deduce function from argument 
types `!()(Slice!(ubyte*, 2LU, mir_sut, KernelTensor 
kerlice_kind.contiguous), Slice!(float*, 2LU, 
mir_slice_kind.contiguous), Slice!(float*, 2LU, 
mir_slice_kind.contiguous), Slice!(float*, 2LU, 
mir_slice_kind.contiguous), TaskPool)` 
    lice_kind.contiguous
source\dcv\imgproc\convolution.d(78,13):    Candidate is: 
`conv(alias bc = neumann, InputTensor, KernelTensor, MaskTensor = 
KernelTensor)(InputTensor input, KernelTensor kernel, InputTensor 
prealloc = InputTensor.init, MaskTensor mask = MaskTensor.init, TaskPool 
pool = taskPool)`  ut, KernelTensor ker
source\dcv\imgproc\filter.d(674,18): Error: template instance 
`dcv.imgproc.filter.calcGradients!(Slice!(ubyte*, 2LU, 
mir_slice_kind.contiguous), float)` error instantiating r instantiating
source\dcv\imgproc\filter.d(694,24):    instantiated from here: 
`canny!(ubyte, ubyte, mir_slice_kind.contiguous)`
source\app.d(48,34):    instantiated from here: `canny!(ubyte, 
ubyte, mir_slice_kind.contiguous)`

```

I tried explicitly passing template parameters in 
dcv.imgproc.filter.calcGradients like below, but in that way, I am 
getting some other compilation errors:

```
alias Empty2Type = Slice!(V*, 2LU, SliceKind.contiguous);
fx = input.conv(neumann, typeof(input), Empty2Type, Empty2Type)
     (kx, emptySlice!(2LU, V), emptySlice!(2LU, V), pool);
fy = input.convinput.conv(neumann, typeof(input), Empty2Type, Empty2Type)
  (ky, emptySlice!(2LU, V), emptySlice!(2LU, V), pool);
```

Thanks in advance!


Didn't test it, just read the error output. `conv` takes (InputTensor, 
KernelTensor, InputTensor, MaskTensor = KernelTensor) but you pass to it 
(InputTensor, KernelTensor, KernelTensor, KernelTensor) and InputTensor 
!is KernelTensor.


InputTensor = Slice!(ubyte*, 2LU, mir_slice_kind.contiguous) and 
KernelTensor = Slice!(float*, 2LU, mir_slice_kind.contiguous). The key 
argument of slices is a pointee type - InputTensor pointee has ubyte 
type and KernelTensor has float. I'm not sure this solves your problem 
but at least I'd start from here.


I need some help for my DCV update

2021-11-26 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
I am working on the DCV to make it compilable with the recent 
versions of LDC, mir libraries, and stuff. I have not yet simply 
forked it to work on it. I am including modules one by one for my 
convenience instead. Hope, I am close to the end. Here is my 
temporary repo:


https://github.com/aferust/ddcv

I run into some problems with module convolution, especially the 
function conv invoked by the below code which calls canny edge 
filter:

```
Image image = imread("lena.png");
auto slice = image.sliced.rgb2gray;
//auto equalized = 
slice.histEqualize(slice.flattened.calcHistogram);


slice.asImage.imshow("Original");
auto edge = slice.canny!ubyte(15);
edge.asImage.imshow("edge");
waitKey();
```
Somehow, the compiler fails in deducting the types. I need some 
help from Ilya or other people familiar with mir.ndslice.


To reproduce it, download my repo and try to compile it as it is. 
There is a main with the test code in the repo. Just be sure you 
have a glfw3.dll/.so.


```
source\dcv\imgproc\filter.d(547,18): Error: template 
`dcv.imgproc.convolution.conv` cannot deduce function from 
argument types `!()(Slice!(ubyte*, 2LU, 
mir_slice_kind.contiguous), Slice!(float*, 2LU, 
mir_slice_kind.contiguous), Slice!(float*, 2LU, 
mir_slice_kind.contiguous), Slice!(float*, 2LU, 
mir_slice_kind.contiguous), TaskPool)`
source\dcv\imgproc\filter.d(548,18): Error: template 
`dcv.imgproc.convolution.conv` cannot deduce function from 
argument types `!()(Slice!(ubyte*, 2LU, mir_sut, KernelTensor 
kerlice_kind.contiguous), Slice!(float*, 2LU, 
mir_slice_kind.contiguous), Slice!(float*, 2LU, 
mir_slice_kind.contiguous), Slice!(float*, 2LU, 
mir_slice_kind.contiguous), TaskPool)`
  
   lice_kind.contiguous
source\dcv\imgproc\convolution.d(78,13):Candidate is: 
`conv(alias bc = neumann, InputTensor, KernelTensor, MaskTensor = 
KernelTensor)(InputTensor input, KernelTensor kernel, InputTensor 
prealloc = InputTensor.init, MaskTensor mask = MaskTensor.init, 
TaskPool pool = taskPool)`  ut, 
KernelTensor ker
source\dcv\imgproc\filter.d(674,18): Error: template instance 
`dcv.imgproc.filter.calcGradients!(Slice!(ubyte*, 2LU, 
mir_slice_kind.contiguous), float)` error instantiating   
  
 
r instantiating
source\dcv\imgproc\filter.d(694,24):instantiated from 
here: `canny!(ubyte, ubyte, mir_slice_kind.contiguous)`
source\app.d(48,34):instantiated from here: 
`canny!(ubyte, ubyte, mir_slice_kind.contiguous)`

```

I tried explicitly passing template parameters in 
dcv.imgproc.filter.calcGradients like below, but in that way, I 
am getting some other compilation errors:

```
alias Empty2Type = Slice!(V*, 2LU, SliceKind.contiguous);
fx = input.conv(neumann, typeof(input), Empty2Type, Empty2Type)
(kx, emptySlice!(2LU, V), emptySlice!(2LU, V), pool);
fy = input.convinput.conv(neumann, typeof(input), Empty2Type, 
Empty2Type)

 (ky, emptySlice!(2LU, V), emptySlice!(2LU, V), pool);
```

Thanks in advance!


Re: I need some help for my DCV update

2021-11-26 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 26 November 2021 at 09:16:56 UTC, Ferhat Kurtulmuş 
wrote:
I am working on the DCV to make it compilable with the recent 
versions of LDC, mir libraries, and stuff. I have not yet 
simply forked it to work on it. I am including modules one by 
one for my convenience instead. Hope, I am close to the end. 
Here is my temporary repo:


[...]


Upps
alias Empty2Type = Slice!(V*, 2LU, SliceKind.contiguous);
fx = input.conv!(neumann, typeof(input), Empty2Type, 
Empty2Type)

(kx, emptySlice!(2LU, V), emptySlice!(2LU, V), pool);
fy = input.conv!(neumann, typeof(input), Empty2Type, 
Empty2Type)

 (ky, emptySlice!(2LU, V), emptySlice!(2LU, V), pool);