Re: [swift-users] Wrapping ImageMagick in a Swift Package

2017-10-03 Thread Ankit Aggarwal via swift-users
Hi Toni,

You're not supposed to build the system module package (because there is
nothing to build). Tag and add this package as a dependency and then try to
import the `TestPkg` module that you defined in the modulemap. The error
here is bogus and is tracked by https://bugs.swift.org/browse/SR-5383

On Tue, Oct 3, 2017 at 12:32 AM, Toni Suter via swift-users <
swift-users@swift.org> wrote:

> Hi,
>
> I am trying to create a Swift Package that wraps the ImageMagick C API. So
> I installed ImageMagick using MacPorts and
> I was then able to build the sample program with the following commands:
>
> export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig
> cc main.c `pkg-config --cflags --libs MagickWand`
>
> Then I created a package with the command "swift package init
> --type=system-module" and I modified Package.swift to look
> like this:
>
> // swift-tools-version:4.0
>
> import PackageDescription
>
> let package = Package(
> name: "TestPkg",
> pkgConfig: "MagickWand"
> )
>
> and I modified module.modulemap to the following:
>
> module TestPkg [system] {
>   header "/opt/local/include/ImageMagick-6/wand/MagickWand.h"
>   link "MagickWand-6.Q16"
>   link "MagickCore-6.Q16"
>   export *
> }
>
> Now when I run "swift build", I get the following error message:
>
> :0: error: unexpected 'commands' value (expected map)
> :0: error: unable to load build file
> error: terminated(1): /Library/Developer/Toolchains/swift-4.0-DEVELOPMENT-
> SNAPSHOT-2017-08-27-a.xctoolchain/usr/bin/swift-build-tool -f
> /Users/tonisuter/Desktop/TestPkg/.build/debug.yaml main
>
> Does anybody know how I can fix this error?
>
> Thanks and best regards
> Toni
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Type inference issue with map and filter chained

2017-10-03 Thread Vladimir.S via swift-users

On 03.10.2017 21:32, Will Stanton via swift-users wrote:

Is this a REPL-only issue perhaps? The code below compiles `swift build` 
without error for me (pasted into Sources/main.swift, Ubuntu 17.04, Swift 4 
release; haven’t tried in Xcode).


A similar issue, but apparently not REPL-only:
https://bugs.swift.org/browse/SR-1856

Regards,
Will Stanton


Code compiles fine:
class test {
 let id = 11
}

var dict: [Int: test] = [10: test()]

let filtered = dict.filter({ $0.value.id > 10 })
let sorted = filtered.sorted(by: {$0.value.id > $1.value.id })

print(sorted)

let filteredAndSorted = dict.filter({ $0.value.id > 10 }).sorted(by: {$0.value.id 
> $1.value.id })


Just checked:

XCode 9: "Ambiguous use of 'filter'" error for this line

Vladimir.


print(filteredAndSorted)



On Sep 24, 2017, at 4:52 AM, Trevör ANNE DENISE via swift-users 
 wrote:

Hello everyone, I found this on StackOverflow : 
https://stackoverflow.com/questions/46381752/swift-4-methods-chaining/

Is this a bug of Swift 4 or is this normal ? I don't understand why the problem 
only happens when methods are chained !



.
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Netlib

2017-10-03 Thread Vladimir.S via swift-users

On 03.10.2017 19:02, Edward Connell via swift-users wrote:

Hi All,
Sorry something strange happened with the first post, so I am reposting this.

I've recently wrapped up an ML framework research project that I've been working on 
for some time.
It addresses a lot of difficult design problems, and works around a lot of compiler 
bugs and Linux library deficiencies.


It's written almost entirely in Swift 4.0 with some C and Cuda kernels.
Development and testing were done primarily on Ubuntu 16.04, but it will also build 
on MacOS.
Linux was the primary environment, because there aren't any modern Macs that can host 
big NVIDIA hardware


The framework interfaces with many common C libraries such as: *Cuda, cuDNN, lmdb, 
png, jpeg, zlib*


Anyone in the community that is trying to work with these libraries might benefit 
from the Swift wrapper classes and examples of successful use. There are other 
isolated technology pieces that might be of use also.


Other people's projects and examples helped me along the way, so I am hoping that my 
work will help some of you as well.


The code and overview docs are published on GitHub

docs: https://github.com/ewconnell/Netlib/wiki 

code: https://github.com/ewconnell/Netlib 



Ed, it looks awesome! :-) Thank you for doing this and for sharing this!

I'm a beginner in ML world, so could you clarify some points please:

1. Do I understand correctly, that main purpose of your library is to train the 
model? So, then we can export structure(connections) and use them where we 
need? Or also the purpose is efficient 'calculation' of trained model on Mac/Linux, 
so this could be used in production apps?


2. Currently this library has only Cuda compute service implemented, right? Do you 
plan to implement the same for Metal soon?


3. What are your plans to support iOs and its Metal? So, the same library/code/way 
could be used to train/experiment and to 'use' in apps on all(macOS/Linux/iOS) platforms.


Thank you.
Vladimir.


Happy coding, Ed :)


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Type inference issue with map and filter chained

2017-10-03 Thread Will Stanton via swift-users
Is this a REPL-only issue perhaps? The code below compiles `swift build` 
without error for me (pasted into Sources/main.swift, Ubuntu 17.04, Swift 4 
release; haven’t tried in Xcode).


A similar issue, but apparently not REPL-only:
https://bugs.swift.org/browse/SR-1856

Regards,
Will Stanton


Code compiles fine:
class test {
let id = 11
}

var dict: [Int: test] = [10: test()]

let filtered = dict.filter({ $0.value.id > 10 })
let sorted = filtered.sorted(by: {$0.value.id > $1.value.id })

print(sorted)

let filteredAndSorted = dict.filter({ $0.value.id > 10 }).sorted(by: 
{$0.value.id > $1.value.id })
print(filteredAndSorted)


> On Sep 24, 2017, at 4:52 AM, Trevör ANNE DENISE via swift-users 
>  wrote:
> 
> Hello everyone, I found this on StackOverflow : 
> https://stackoverflow.com/questions/46381752/swift-4-methods-chaining/
> 
> Is this a bug of Swift 4 or is this normal ? I don't understand why the 
> problem only happens when methods are chained !


.
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Is URLSession actually working on Linux

2017-10-03 Thread Geordie Jay via swift-users
2017-10-03 20:10 GMT+02:00 Georgios Moschovitis via swift-users <
swift-users@swift.org>:

> I implemented a simple RSS feed aggregator. I used code like...
>
> let data = try! Data(contentsOf: feedURL)
>
> or
>
> let session = URLSession(configuration: URLSessionConfiguration.default)
> let task = session.dataTask(with: url, completionHandler:
> completionHandler)
> task.resume()
>
> ...to fetch the data.
>
> While my application worked perfectly when running on macOS, when I tried
> to run
> it on Ubuntu it started crashing *randomly* with errors like...
>
> *** Error in `bin/….': double free or corruption (fasttop):
> 0x7f388ff0 ***
> Aborted
>
> or
>
> Illegal instruction
>
> etc.
>


I haven't seen it myself but I've heard from colleagues that we ran into
the same issues on Android. Foundation depends on libcurl (on Linux at
least?), so we're just going to make our own basic libcurl wrapper that
looks and acts like URLSession until the Foundation one works.


>
> When I switched to KituraRequest (in place of URLSession), the application
> started
> running correctly on Ubuntu as well.
>

KituraRequest uses libcurl too, but its dependency tree is too complex for
us to use on Android.


>
> Are there any issues with the implementation of Foundation for Linux?
>

tldr; Pretty sure, yes.


>
>
> -g.
>
>
> PS: I am using swift 4.0
>
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
-g
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Is URLSession actually working on Linux

2017-10-03 Thread Georgios Moschovitis via swift-users
I implemented a simple RSS feed aggregator. I used code like...

let data = try! Data(contentsOf: feedURL)

or

let session = URLSession(configuration: URLSessionConfiguration.default)
let task = session.dataTask(with: url, completionHandler: completionHandler)
task.resume()

...to fetch the data.

While my application worked perfectly when running on macOS, when I tried to run
it on Ubuntu it started crashing randomly with errors like...

*** Error in `bin/….': double free or corruption (fasttop): 0x7f388ff0 
***
Aborted

or

Illegal instruction

etc.

When I switched to KituraRequest (in place of URLSession), the application 
started
running correctly on Ubuntu as well.

Are there any issues with the implementation of Foundation for Linux?


-g.


PS: I am using swift 4.0

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Netlib

2017-10-03 Thread Edward Connell via swift-users
Hi All,
Sorry something strange happened with the first post, so I am reposting
this.

I've recently wrapped up an ML framework research project that I've been
working on for some time.
It addresses a lot of difficult design problems, and works around a lot of
compiler bugs and Linux library deficiencies.

It's written almost entirely in Swift 4.0 with some C and Cuda kernels.
Development and testing were done primarily on Ubuntu 16.04, but it will
also build on MacOS.
Linux was the primary environment, because there aren't any modern Macs
that can host big NVIDIA hardware

The framework interfaces with many common C libraries such as: *Cuda,
cuDNN, lmdb, png, jpeg, zlib*

Anyone in the community that is trying to work with these libraries might
benefit from the Swift wrapper classes and examples of successful use.
There are other isolated technology pieces that might be of use also.

Other people's projects and examples helped me along the way, so I am
hoping that my work will help some of you as well.

The code and overview docs are published on GitHub

docs: https://github.com/ewconnell/Netlib/wiki
code: https://github.com/ewconnell/Netlib

Happy coding, Ed :)
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Netlib now on GitHub

2017-10-03 Thread Edward Connell via swift-users
Hi All,
I've recently wrapped up an ML framework research project that I've been
working on for some time.
It addresses a lot of difficult design problems, and works around a lot of
compiler bugs and Linux library deficiencies.

It's written almost entirely in Swift 4.0 with some C and Cuda kernels.
Development and testing were done primarily on Ubuntu 16.04, but it will
also build on MacOS.
Linux was the primary environment, because there aren't any modern Macs
that can host big NVIDIA hardware

The framework interfaces with many common C libraries such as: *Cuda,
cuDNN, lmdb, png, jpeg, zlib*

Anyone in the community that is trying to work with these libraries might
benefit from the Swift wrapper classes and examples of successful use.
There are other isolated technology pieces that might be of use also.

Other people's projects and examples helped me along the way, so I am
hoping that my work will help some of you as well.

The code and overview docs are published on GitHub

docs: https://github.com/ewconnell/Netlib/wiki
code: https://github.com/ewconnell/Netlib

Happy coding, Ed :)
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Wrapping ImageMagick in a Swift Package

2017-10-03 Thread Toni Suter via swift-users
Hi,

I am trying to create a Swift Package that wraps the ImageMagick C API. So I 
installed ImageMagick using MacPorts and
I was then able to build the sample program with the following commands:

export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig
cc main.c `pkg-config --cflags --libs MagickWand`

Then I created a package with the command "swift package init 
--type=system-module" and I modified Package.swift to look
like this:

// swift-tools-version:4.0

import PackageDescription

let package = Package(
name: "TestPkg",
pkgConfig: "MagickWand"
)

and I modified module.modulemap to the following:

module TestPkg [system] {
  header "/opt/local/include/ImageMagick-6/wand/MagickWand.h"
  link "MagickWand-6.Q16"
  link "MagickCore-6.Q16"
  export *
}

Now when I run "swift build", I get the following error message:

:0: error: unexpected 'commands' value (expected map)
:0: error: unable to load build file
error: terminated(1): 
/Library/Developer/Toolchains/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-08-27-a.xctoolchain/usr/bin/swift-build-tool
 -f /Users/tonisuter/Desktop/TestPkg/.build/debug.yaml main

Does anybody know how I can fix this error?

Thanks and best regards
Toni___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users