def _memcpy_gather():
    return cuda.elementwise('raw T ptrs, raw X dtypes, raw Y info', 'raw float32 dst', '\n            int id_min = id_pre;\n            int id_max = num_src;\n            while (id_max - id_min > 1) {\n                int id = (id_max + id_min) / 2;\n                if (i < info[id]) id_max = id;\n                else              id_min = id;\n            }\n            int id = id_min;\n\n            int i_dst = i;\n            int i_src = i;\n            if (id > 0) i_src -= info[id];\n\n            dst[i_dst] = 0;\n            if (ptrs[id] != NULL) {\n                if (dtypes[id] == 0) { // fp32\n                    float *src = reinterpret_cast<float *>(ptrs[id]);\n                    dst[i_dst] = src[i_src];\n                }\n                else { // fp16\n                    float16 *src = reinterpret_cast<float16 *>(ptrs[id]);\n                    dst[i_dst] = static_cast<float>(src[i_src]);\n                }\n            }\n            id_pre = id;\n        ', '_memcpy_gather', loop_prep='\n                int num_src = info[0];\n                int id_pre = 0;\n            ')
def _memcpy_gather():
    return cuda.elementwise('raw T ptrs, raw X dtypes, raw Y info', 'raw float32 dst', '\n            int id_min = id_pre;\n            int id_max = num_src;\n            while (id_max - id_min > 1) {\n                int id = (id_max + id_min) / 2;\n                if (i < info[id]) id_max = id;\n                else              id_min = id;\n            }\n            int id = id_min;\n\n            int i_dst = i;\n            int i_src = i;\n            if (id > 0) i_src -= info[id];\n\n            dst[i_dst] = 0;\n            if (ptrs[id] != NULL) {\n                if (dtypes[id] == 0) { // fp32\n                    float *src = reinterpret_cast<float *>(ptrs[id]);\n                    dst[i_dst] = src[i_src];\n                }\n                else { // fp16\n                    float16 *src = reinterpret_cast<float16 *>(ptrs[id]);\n                    dst[i_dst] = static_cast<float>(src[i_src]);\n                }\n            }\n            id_pre = id;\n        ', '_memcpy_gather', loop_prep='\n                int num_src = info[0];\n                int id_pre = 0;\n            ')