serge-sans-paille / pythran

Ahead of Time compiler for numeric kernels
https://pythran.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.99k stars 193 forks source link

Another compile error #2173

Closed cycomanic closed 7 months ago

cycomanic commented 8 months ago

I'm experiencing another compile issue for code that used to work similar to #2132

Fails with GCC 13.2.1 and clang++ 16.0.6 on archlinux.

Minimal example

import numpy as np

# pythran export train_equaliser(complex128[][], complex128[][])
def train_equaliser(E, symbols):
    err = rde_error(E[0, 0], symbols[0], 0)
    return err

def rde_error(Xest, symbs, i):
    codebook, partitions = np.array_split(symbs.real, 2)
    i = partition_value(partitions)
    return codebook[i]

def partition_value(part):
    L = part.shape[0]
    return L//2

however the following compiles fine.

import numpy as np

# pythran export train_equaliser(complex128[][], complex128[][])
def train_equaliser(E, symbols):
    err = rde_error(E[0, 0], symbols[0], 0)
    return err

def rde_error(Xest, symbs, i):
    codebook, partitions = np.array_split(symbs, 2)
    i = partition_value(partitions)
    return codebook[i]

def partition_value(part):
    L = part.shape[0]
    return L//2

moving the .real into the second function again results in failed compilation.

import numpy as np

# pythran export train_equaliser(complex128[][], complex128[][])
def train_equaliser(E, symbols):
    err = rde_error(E[0, 0], symbols[0], 0)
    return err

def rde_error(Xest, symbs, i):
    codebook, partitions = np.array_split(symbs, 2)
    i = partition_value(partitions)
    return codebook[i]

def partition_value(part):
    L = part.real.shape[0]
    return L//2
serge-sans-paille commented 7 months ago

Hey @cycomanic. I can reproduce your issue, I'll have a look this week end. Thanks for your patience :-)

serge-sans-paille commented 7 months ago

Even more minimal (!) reproducer:

import numpy as np
#pythran export foo(complex[:,:])
def foo(x):
    return x[0].real