digitalmars.D.learn - I need some help for my DCV update
- Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (70/70) Nov 26 2021 I am working on the DCV to make it compilable with the recent
- Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (10/16) Nov 26 2021 Upps
- drug (10/77) Nov 26 2021 Didn't test it, just read the error output. `conv` takes (InputTensor,
- Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (2/9) Nov 26 2021 Yes, but this is how the original code was written.
- Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (17/23) Nov 27 2021 After dealing with, various problems, it turns out the main
- Salih Dincer (4/29) Nov 27 2021 I also found similar errors but couldn't solve them. I think it
- Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (3/5) Nov 27 2021 I won't use parallel for it as a workaround until it is solved in
- 9il (4/10) Dec 11 2021 Linker bug is a compiler bug. We can only find a workaround. The
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!
Nov 26 2021
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);
Nov 26 2021
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.
Nov 26 2021
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.
Nov 26 2021
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/ddcvAfter 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__TQ mTQGfVmi1VQDli2ZQHe referenced in function _D3mir7ndslice5slice__T9mir_sliceTSQBhQBg8iterator__T13FieldIteratorTSQCqQCp5field__T11ndIotaFieldVmi2ZQsZQCbVmi1VEQEjQEiQEd14mir_slice_kindi2ZQEq__T8opEqualsTQEvVQBxi2ZQuMxFNaNbNiNeKxSQHbQHaQGv__TQGsTQGlVmi1VQDri2ZQHkZb .dub\build\application-debug-windows-x86_64-ldc_v1.28.0-24645713CE34BFE817BFD D964187D0E\ddcv.exe : fatal error LNK1120: 1 unresolved externals
Nov 27 2021
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 also found similar errors but couldn't solve them. I think it has to do with mir.slice.kind. Exactly Kind Topology...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/ddcvAfter 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__TQ mTQGfVmi1VQDli2ZQHe referenced in function _D3mir7ndslice5slice__T9mir_sliceTSQBhQBg8iterator__T13FieldIteratorTSQCqQCp5field__T11ndIotaFieldVmi2ZQsZQCbVmi1VEQEjQEiQEd14mir_slice_kindi2ZQEq__T8opEqualsTQEvVQBxi2ZQuMxFNaNbNiNeKxSQHbQHaQGv__TQGsTQGlVmi1VQDri2ZQHkZb .dub\build\application-debug-windows-x86_64-ldc_v1.28.0-24645713CE34BFE817BFD D964187D0E\ddcv.exe : fatal error LNK1120: 1 unresolved externals
Nov 27 2021
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.
Nov 27 2021
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:Linker bug is a compiler bug. We can only find a workaround. The best workaround is to avoid using ndiota with std.parallelism.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.
Dec 11 2021