Coder Social home page Coder Social logo

Span<T> and Slice? about numsharp HOT 24 CLOSED

scisharp avatar scisharp commented on June 19, 2024
Span and Slice?

from numsharp.

Comments (24)

Oceania2018 avatar Oceania2018 commented on June 19, 2024 1

@fdncred I've read this article, I realized that Span<T> is important to NumSharp's performance, we might have to give up the net472, only support .NET Core 2.1. That would bring best performance without coping memory. @dotChris90 Do you agree with that? We can still moving forward in current T[] way, I'm saying we would replace it with Span<T>. Keep this issue open.

from numsharp.

dotChris90 avatar dotChris90 commented on June 19, 2024 1

@Oceania2018 I agree 100% that we need the Span and I see that the slicing and views could give us the best benefits than :D Means we slicing matrix to multiple vectors (as an example) and do operations on vectors - the matrix could be also updated if we using this nice "managed pointers" :D

from numsharp.

Oceania2018 avatar Oceania2018 commented on June 19, 2024

Only can be used in .NET Core 2.1, NumSharp is using .net standard 2.0. We will change TargetFrameworks if needed.
https://www.codemag.com/article/1807051/Introducing-.NET-Core-2.1-Flagship-Types-Span-T-and-Memory-T

from numsharp.

dotChris90 avatar dotChris90 commented on June 19, 2024

@Oceania2018 @fdncred just for curiosity. Do u use at moment . NET CORE or Full?
I think at moment we 3 are the main workers at this repo and I really like the span if we e.g. Slice arrays or generate different views for the same arrays. I think it could be also great when parallel operations.

from numsharp.

Oceania2018 avatar Oceania2018 commented on June 19, 2024

Seem like just install System.Memory through NuGet, NumSharp will support Span<T>, we store all data in a 1-d array, acutally, we don't need slice any data. Span<T> looks great, agree with you. Everything could be tried and test. Appriciate.

from numsharp.

fdncred avatar fdncred commented on June 19, 2024

I used dotnet full i.e. net472 however, if we're going to make a numpy clone that as fast as the real numpy the only way to do it is either with p/invoke or span. I think the netstandard, full, and core are slowly merging into one framework. The future is definitely core. Even WinForms and Xaml/Wpf are being rewritten in dotnet core right now. It's scheduled for 3.0 release.

This bit of code was made me think of Span. The Skip and Take specifically.
https://github.com/Oceania2018/NumSharp/blob/4bbca14e07066aa4692c8df27dae0a097bdfb215/src/NumSharp/NdArray.cs#L109

The downside to dotnet core is that it brings a lot of baggage with it in the form of dozens of assemblies/dlls.

For now I would suggest doing something like this:

#if FULL
// do dotnet full stuff
#else
// do dotnet core stuff
#endif

from numsharp.

fdncred avatar fdncred commented on June 19, 2024

One other benefit with dotnet core is that it runs on Windows/Mac/Linux. It's designed to be cross-platform.

from numsharp.

dotChris90 avatar dotChris90 commented on June 19, 2024

Totally agree. Honestly at moment try our code on windows 10 and a Linux MX (Debian base). It's simple awesome to see we can target multiple platforms.

And we targeting multiple languages. C#, F#, VB and I often try powershell.

Beside this there is the cool project peachpie which bring php to the dotnet world.

On top of this. There exist bindings for Matlab and python. We could use NumSharp in python lol

So it's cool time to be dotnet developer.

But I guess soon or later there will be a new dotnet standard and with this we get the span in all frameworks.

:)

from numsharp.

dotChris90 avatar dotChris90 commented on June 19, 2024

@fdncred @Oceania2018 did you hear something like a NetStadard2.1 or 3.0?
The last Update I hear is that 2.0 is the latest standard.
If we know a new standard we could plan if changing the Standard can be done now, in some weeks or .... other date

from numsharp.

fdncred avatar fdncred commented on June 19, 2024

I have not heard of a new netstandard however i have heard of netcore3 which will include winforms and wpf cross platform.

from numsharp.

fdncred avatar fdncred commented on June 19, 2024

@dotChris90, @Oceania2018 Before moving forward with Span could you please test my latest push d1bed10? I've only been able to test with my MacBook and OSX. Tomorrow I should be able to get back on Visual Studio. I just want confirmation that you can build all and run all the tests and they all succeed.

This is from vscode on my mac.
screen shot 2018-11-04 at 2 10 20 pm

from numsharp.

dotChris90 avatar dotChris90 commented on June 19, 2024

@fdncred mine works fine. First it shows such red lines like on the image. But after build, test and restart all works fine. Idk why .... but as long as it works. all ok. but at moment just on Windows 10. Maybe tomorrow should try it again on Linux.

from numsharp.

fdncred avatar fdncred commented on June 19, 2024

@dotChris90 are you using vscode or Visual Studio on Win10?

from numsharp.

dotChris90 avatar dotChris90 commented on June 19, 2024

@fdncred VS Code. Honestly spoken now got used to it and like it more lol. Except on razor stuff... In cshtml stuff it still need some little more improvement

from numsharp.

fdncred avatar fdncred commented on June 19, 2024

Committed first Span code with 01e2de1. Ideally NDArray's T[] Data would be a Span<T> Data but it's not allowed. So, we'll have to figure out how and where to use it best. It's benefit is speed and reduced memory allocations.

from numsharp.

dotChris90 avatar dotChris90 commented on June 19, 2024

Ok glade to see everybody of us seems to agree go with 2.1 core lol.

OK cool to see there are first push with itπŸ‘

from numsharp.

fdncred avatar fdncred commented on June 19, 2024

If we're going to use Span I don't think there is any other choice. I don't think netstandard nor netfull support Span.

from numsharp.

dotChris90 avatar dotChris90 commented on June 19, 2024

By the way net standard 2.1 has the span

from numsharp.

Oceania2018 avatar Oceania2018 commented on June 19, 2024

Hooray

from numsharp.

fdncred avatar fdncred commented on June 19, 2024

@dotChris90 Is it released yet? or do you know when it will be released?

from numsharp.

dotChris90 avatar dotChris90 commented on June 19, 2024

hm did not find any concrete date and on https://github.com/dotnet/standard/milestone/3 it seems there still some progress. I am not sure when it will be released. But I am sure it is not yet released. :(

from numsharp.

fdncred avatar fdncred commented on June 19, 2024

We can also see some things it doesn't include here. I assumed there would be a preview but I don't see one. Maybe they're not that far yet.

from numsharp.

dotChris90 avatar dotChris90 commented on June 19, 2024

Yes this is correct. But I say - Oceania2018 already changed the csproj - so all work. So it is not critical to change to 2.1 standard. ;) anyway - the first day it is released, we should change the csproj. ;)

from numsharp.

Oceania2018 avatar Oceania2018 commented on June 19, 2024

image

from numsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.