Esempio n. 1
0
def main():
    bm = Benchmark(
        datasets=[
            Dataset(
                factories=[lambda n: make_vec_dataset(n, dtype=np.float16)],
                title='16bits',
                extra_args=dict(dtype=np.uint16, nbits=4)),
            Dataset(
                factories=[lambda n: make_vec_dataset(n, dtype=np.float32)],
                title='32bits',
                extra_args=dict(dtype=np.uint32, nbits=10)),
            Dataset(
                factories=[lambda n: make_vec_dataset(n, dtype=np.float64)],
                title='64bits',
                extra_args=dict(dtype=np.uint64, nbits=20))
        ],
        dataset_sizes=[2**n for n in range(25)],
        kernels=[
            Kernel(
                stmt=
                "vector.encode_vec_to_uint(DATASET, dtype=EXTRA_ARGS['dtype'], nbits=EXTRA_ARGS['nbits'], encoder=fp.encode_fp_to_std_snorm)",
                setup='from fpq import vector\nfrom fpq import fp',
                label='encode_vec_to_uint(std)'),
            Kernel(
                stmt=
                "vector.encode_vec_to_uint(DATASET, dtype=EXTRA_ARGS['dtype'], nbits=EXTRA_ARGS['nbits'], encoder=fp.encode_fp_to_ogl_snorm)",
                setup='from fpq import vector\nfrom fpq import fp',
                label='encode_vec_to_uint(ogl)'),
        ],
        xlabel='dataset sizes',
        title='encode_vec_to_uint')
    bm.run()
    script_name, _ = os.path.splitext(os.path.basename(__file__))
    bm.save_as_html(filepath=script_name + '.html')
def make_dataset(n, *, dtype):
    dataset = make_vec_dataset(n, dtype=dtype)
    max_abs_inds = fpq.utils.get_max_component_indices(np.absolute(dataset))
    sign = np.sign(dataset[max_abs_inds])
    rest_components = fpq.utils.remove_component(dataset, indices=max_abs_inds)
    rest_components *= sign[..., None]
    return rest_components.transpose()
Esempio n. 3
0
def main():
    dataset_size = 100000
    src_dtype = np.float64
    dst_dtype = np.uint64
    nbits = 20

    dataset = make_vec_dataset(dataset_size, dtype=src_dtype)

    mt.trace(
        vector.encode_vec_to_uint,
        target_args=dict(v=dataset, dtype=dst_dtype, nbits=nbits),
        related_traces_output_mode=mt.RelatedTracesOutputMode.FOR_EACH_FILE,
        include_patterns={'*/fpq/*'},
        exclude_patterns=None)
Esempio n. 4
0
def make_dataset(n, *, src_dtype, dst_dtype, nbits, encoder):
    dataset = make_vec_dataset(n, dtype=src_dtype)
    return vector.encode_vec_to_uint(dataset, dtype=dst_dtype, nbits=nbits, encoder=encoder)