Skip to content
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

Error in ar_topk #33

Open
sinhngoc2008 opened this issue Apr 20, 2021 · 0 comments
Open

Error in ar_topk #33

sinhngoc2008 opened this issue Apr 20, 2021 · 0 comments

Comments

@sinhngoc2008
Copy link

Hello,
I made a TopK function in class Algorithm as below.
Then I created a random array by using Data.RandNormal(4, 225, 16, 292); and pass this array to TopK function with k=4, dim = 0, order = AF_TOPK_MAX.
An exception is happen with "Internal error" message.
Are there any limitation of topk in arrayfire like number of dimensions or number of elements in an dimension?
I do the same test in pytorch. It's work well.

    namespace ArrayFire
    {
        public static class Algorithm
        {
    .
    .
    .
           [MethodImpl(MethodImplOptions.AggressiveInlining)]
            public static Array TopK(out Array indices, Array arr1, int k, int dim, af_topk_function order)
            {
                IntPtr ptr;
                IntPtr idx;
                Internal.VERIFY(AFStatistics.af_topk(out ptr, out idx, arr1._ptr, k, dim, order));
                indices = new Array(idx);
                return new Array(ptr);
            }
        }
    }


    public Form1()
    {
        InitializeComponent();
        Device.SetBackend(Backend.CUDA);
        try
        {
            var arr1 = Data.RandNormal<float>(4, 225, 16, 292);
            ArrayFire.Array indices = null;
            var output = Algorithm.TopK(out indices, arr1, 4, 0, ArrayFire.Interop.af_topk_function.AF_TOPK_MAX);
        }
        catch (Exception ex) { }
        Debug.WriteLine("Done!!");
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant