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

Add operator can be write in macro without type #98

Open
ChenHuaYou opened this issue Aug 24, 2021 · 1 comment
Open

Add operator can be write in macro without type #98

ChenHuaYou opened this issue Aug 24, 2021 · 1 comment

Comments

@ChenHuaYou
Copy link

#define tensorAdd(type,o_C,i_A,i_B)
do{
if(!tensorCheckBroadcasting(i_A,i_B)){
TRACE_LEVEL0("invalid broadcasting");
exit(EXIT_FAILURE);
}else{
int subscript = malloc(o_C->n_dimssizeof(int));
for(int i=0; i<o_C->n_##type##_data; i++){
tensorIdxToSubscript(o_C, subscript, i);
o_C->type##_data[i] = i_A->type##_data[tensorSubscriptToIdx(i_A,subscript)]
+ i_B->type##_data[tensorSubscriptToIdx(i_B,subscript)];
}
free(subscript);
}
}while(0)

@nopeslide
Copy link
Collaborator

Would prefer using the stack or pointer instead of a malloc call,
since we wanted to reduce malloc calls in helpers.
What do you think about introducing a macro library for these things?

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

2 participants