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

Fix code generation for union inside struct #132

Open
yuhc opened this issue May 16, 2021 · 0 comments
Open

Fix code generation for union inside struct #132

yuhc opened this issue May 16, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@yuhc
Copy link
Member

yuhc commented May 16, 2021

See PR 131.

typedef struct {
    union Algorithm {
        cudnnConvolutionFwdAlgo_t convFwdAlgo;
        cudnnConvolutionBwdFilterAlgo_t convBwdFilterAlgo;
        cudnnConvolutionBwdDataAlgo_t convBwdDataAlgo;
        cudnnRNNAlgo_t RNNAlgo;
        cudnnCTCLossAlgo_t CTCLossAlgo;
    } algo;
} cudnnAlgorithm_t;

The generated code is like:

            cudnnAlgorithm_t *ava_self;                                                                                                                                                                                                                                    
            ava_self = (cudnnAlgorithm_t *) (&algorithm);                                                                                                                                                                                                                  
            union Algorithm *__algorithm_a_0_algo;                                                                                                                                                                                                                         
            __algorithm_a_0_algo = (union Algorithm *)(&(algorithm).algo);                                                                                                                                                                                                 
            union Algorithm *__algorithm_b_0_algo;                                                                                                                                                                                                                         
            __algorithm_b_0_algo = (union Algorithm *)(&(__call->algorithm).algo); {                                                                                                                                                                                       
                union Algorithm *ava_self;                                                                                                                                                                                                                                 
                ava_self = (union Algorithm *)(&*__algorithm_a_0_algo);                                                                                                                                                                                                    
                cudnnCTCLossAlgo_t *__algorithm_a_1_CTCLossAlgo;                                                                                                                                                                                                           
                __algorithm_a_1_CTCLossAlgo = (cudnnCTCLossAlgo_t *) (&(*__algorithm_a_0_algo).CTCLossAlgo);                                                                                                                                                               
                cudnnCTCLossAlgo_t *__algorithm_b_1_CTCLossAlgo;                                                                                                                                                                                                           
                __algorithm_b_1_CTCLossAlgo = (cudnnCTCLossAlgo_t *) (&(*__algorithm_b_0_algo).CTCLossAlgo); {                                                                                                                                                             
                    *__algorithm_a_1_CTCLossAlgo = (cudnnCTCLossAlgo_t) * __algorithm_b_1_CTCLossAlgo;                                                                                                                                                                     
                    *__algorithm_a_1_CTCLossAlgo = *__algorithm_b_1_CTCLossAlgo;                                                                                                                                                                                           
                }
...
@yuhc yuhc added the bug Something isn't working label May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant