def fetch_and_compile_antares_kernel(expression, expr_hash, server_addr):
    print('+ [Antares Op]', expression)
    h = http_client.HTTPConnection(server_addr, timeout=10)
    try:
        h.request('GET', '/', headers={'COMPUTE_V1': expression})
    except:
        raise Exception(('Failed to contact with Antares server: %s (not started?)' % server_addr))
    res = h.getresponse()
    if (res.status != 200):
        raise Exception(('Fail to get server response, reason: %s' % res.reason))
    source = res.read().decode()
    try:
        meta_bgn = (source.index('///') + len('///'))
    except:
        raise Exception(('Illegal syntax for Antares expression: %s' % expression))
    meta_pos = source.index(':', meta_bgn)
    meta_end = source.index('\n', meta_pos)
    meta_inputs = source[meta_bgn:meta_pos].split(',')
    meta_outputs = source[(meta_pos + 1):meta_end].split(',')
    code_name = ('Antares' + expr_hash)
    source_path = ('/tmp/antares_torch_%s.cc.kernel.cu' % code_name)
    with open(source_path, 'w') as fp:
        fp.write(source)
    return (source, source_path, expr_hash, meta_inputs, meta_outputs)
def fetch_and_compile_antares_kernel(expression, expr_hash, server_addr):
    print('+ [Antares Op]', expression)
    h = http_client.HTTPConnection(server_addr, timeout=10)
    try:
        h.request('GET', '/', headers={'COMPUTE_V1': expression})
    except:
        raise Exception(('Failed to contact with Antares server: %s (not started?)' % server_addr))
    res = h.getresponse()
    if (res.status != 200):
        raise Exception(('Fail to get server response, reason: %s' % res.reason))
    source = res.read().decode()
    try:
        meta_bgn = (source.index('///') + len('///'))
    except:
        raise Exception(('Illegal syntax for Antares expression: %s' % expression))
    meta_pos = source.index(':', meta_bgn)
    meta_end = source.index('\n', meta_pos)
    meta_inputs = source[meta_bgn:meta_pos].split(',')
    meta_outputs = source[(meta_pos + 1):meta_end].split(',')
    code_name = ('Antares' + expr_hash)
    source_path = ('/tmp/antares_torch_%s.cc.kernel.cu' % code_name)
    with open(source_path, 'w') as fp:
        fp.write(source)
    return (source, source_path, expr_hash, meta_inputs, meta_outputs)