Skip to content

[BUG] NAN not being replaced by af_product_by_key_nan and af_sum_by_key_nan #3255

Description

@danil-osipchuk

Description

Both af_product_by_key_nan and af_sum_by_key_nan are not replacing NANs at some locations of the input making them go to the output.

I would hazard a guess, that problematic spots are the beginning of the next keyed groupings.
For the example below having the following key set {0, 0, 1, 1, 1, 2, 2, 0} the indexes are 2, 5 and 7.

Official installer Linux 3.8.1 Cuda 11.4, CPU backend

Reproducible Code and/or Steps

#include <stdio.h>
#include <math.h>
#include "/opt/arrayfire/include/arrayfire.h"

int main()
{
	char *info_str;
	af_array  ikeys, ivals, okeys, ovals;
	dim_t dims[1] = {8};
	af_info_string(&info_str, true);
	printf("%s\n", info_str);

	int ikeys_src[8] =    {0, 0,  1, 1, 1,  2, 2,  0};
	af_create_array(&ikeys, ikeys_src, 1, dims, u32);

	int i;
	for (i=0; i<8; i++) {
		double ivals_src[8] = {1, 2,  3, 4, 5,  6, 7,  8};
		ivals_src[i] = NAN;
		af_create_array(&ivals, ivals_src, 1, dims, f64);
		printf("NAN index in input = %d\n", i);

		af_product_by_key_nan(&okeys, &ovals, ikeys, ivals, 0, 1.0);
		printf("af_product_by_key_nan values:\n");
		af_print_array(ovals);

		af_sum_by_key_nan(&okeys, &ovals, ikeys, ivals, 0, 1.0);
		printf("af_sum_by_key_nan values:\n");
		af_print_array(ovals);
	}
}


==

danil@dprog:~/Sandbox$ gcc -I/opt/arrayfire/include af_by_key_nan.c -L/opt/arrayfire/lib64 -lafcpu -laf  
danil@dprog:~/Sandbox$ ./a.out 
ArrayFire v3.9.0 (CPU, 64-bit Linux, build 1d03d07)
[0] Intel: Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz
NAN index in input = 0
af_product_by_key_nan values:
No Name Array
[4 1 1 1]
    2.0000 
   60.0000 
   42.0000 
    8.0000 

af_sum_by_key_nan values:
No Name Array
[4 1 1 1]
    3.0000 
   12.0000 
   13.0000 
    8.0000 

NAN index in input = 1
af_product_by_key_nan values:
No Name Array
[4 1 1 1]
    1.0000 
   60.0000 
   42.0000 
    8.0000 

af_sum_by_key_nan values:
No Name Array
[4 1 1 1]
    2.0000 
   12.0000 
   13.0000 
    8.0000 

NAN index in input = 2
af_product_by_key_nan values:
No Name Array
[4 1 1 1]
    2.0000 
       nan 
   42.0000 
    8.0000 

af_sum_by_key_nan values:
No Name Array
[4 1 1 1]
    3.0000 
       nan 
   13.0000 
    8.0000 

NAN index in input = 3
af_product_by_key_nan values:
No Name Array
[4 1 1 1]
    2.0000 
   15.0000 
   42.0000 
    8.0000 

af_sum_by_key_nan values:
No Name Array
[4 1 1 1]
    3.0000 
    9.0000 
   13.0000 
    8.0000 

NAN index in input = 4
af_product_by_key_nan values:
No Name Array
[4 1 1 1]
    2.0000 
   12.0000 
   42.0000 
    8.0000 

af_sum_by_key_nan values:
No Name Array
[4 1 1 1]
    3.0000 
    8.0000 
   13.0000 
    8.0000 

NAN index in input = 5
af_product_by_key_nan values:
No Name Array
[4 1 1 1]
    2.0000 
   60.0000 
       nan 
    8.0000 

af_sum_by_key_nan values:
No Name Array
[4 1 1 1]
    3.0000 
   12.0000 
       nan 
    8.0000 

NAN index in input = 6
af_product_by_key_nan values:
No Name Array
[4 1 1 1]
    2.0000 
   60.0000 
    6.0000 
    8.0000 

af_sum_by_key_nan values:
No Name Array
[4 1 1 1]
    3.0000 
   12.0000 
    7.0000 
    8.0000 

NAN index in input = 7
af_product_by_key_nan values:
No Name Array
[4 1 1 1]
    2.0000 
   60.0000 
   42.0000 
       nan 

af_sum_by_key_nan values:
No Name Array
[4 1 1 1]
    3.0000 
   12.0000 
   13.0000 
       nan 


  • Using the latest available ArrayFire release
  • [x ] GPU drivers are up to date

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions