Quantize#

This page provides C++ class references for the publicly-exposed elements of the cuvs/preprocessing/quantize package.

Scalar#

#include <cuvs/preprocessing/quantize/scalar.hpp>

namespace cuvs::preprocessing::quantize::scalar

group scalar

Functions

quantizer<double> train(raft::resources const &res, const params params, raft::device_matrix_view<const double, int64_t> dataset)#

Initializes a scalar quantizer to be used later for quantizing the dataset.

Usage example:

raft::handle_t handle;
cuvs::preprocessing::quantize::scalar::params params;
auto quantizer = cuvs::preprocessing::quantize::scalar::train<double, int8_t>(handle, params,
dataset);

Parameters:
  • res[in] raft resource

  • params[in] configure scalar quantizer, e.g. quantile

  • dataset[in] a row-major matrix view on device

Returns:

quantizer

quantizer<double> train(raft::resources const &res, const params params, raft::host_matrix_view<const double, int64_t> dataset)#

Initializes a scalar quantizer to be used later for quantizing the dataset.

Usage example:

raft::handle_t handle;
cuvs::preprocessing::quantize::scalar::params params;
auto quantizer = cuvs::preprocessing::quantize::scalar::train<double, int8_t>(handle, params,
dataset);

Parameters:
  • res[in] raft resource

  • params[in] configure scalar quantizer, e.g. quantile

  • dataset[in] a row-major matrix view on host

Returns:

quantizer

void transform(raft::resources const &res, const quantizer<double> &quantizer, raft::device_matrix_view<const double, int64_t> dataset, raft::device_matrix_view<int8_t, int64_t> out)#

Applies quantization transform to given dataset.

Usage example:

raft::handle_t handle;
cuvs::preprocessing::quantize::scalar::params params;
auto quantizer = cuvs::preprocessing::quantize::scalar::train<double, int8_t>(handle, params,
dataset); auto quantized_dataset = raft::make_device_matrix<int8_t, int64_t>(handle, samples,
features); cuvs::preprocessing::quantize::scalar::transform(handle, quantizer, dataset,
quantized_dataset.view());

Parameters:
  • res[in] raft resource

  • quantizer[in] a scalar quantizer

  • dataset[in] a row-major matrix view on device

  • out[out] a row-major matrix view on device

void transform(raft::resources const &res, const quantizer<double> &quantizer, raft::host_matrix_view<const double, int64_t> dataset, raft::host_matrix_view<int8_t, int64_t> out)#

Applies quantization transform to given dataset.

Usage example:

raft::handle_t handle;
cuvs::preprocessing::quantize::scalar::params params;
auto quantizer = cuvs::preprocessing::quantize::scalar::train<double, int8_t>(handle, params,
dataset); auto quantized_dataset = raft::make_host_matrix<int8_t, int64_t>(samples, features);
cuvs::preprocessing::quantize::scalar::transform(handle, quantizer, dataset,
quantized_dataset.view());

Parameters:
  • res[in] raft resource

  • quantizer[in] a scalar quantizer

  • dataset[in] a row-major matrix view on host

  • out[out] a row-major matrix view on host

void inverse_transform(raft::resources const &res, const quantizer<double> &quantizer, raft::device_matrix_view<const int8_t, int64_t> dataset, raft::device_matrix_view<double, int64_t> out)#

Perform inverse quantization step on previously quantized dataset.

Note that depending on the chosen data types train dataset the conversion is not lossless.

Usage example:

auto quantized_dataset = raft::make_device_matrix<int8_t, int64_t>(handle, samples, features);
cuvs::preprocessing::quantize::scalar::transform(handle, quantizer, dataset,
quantized_dataset.view()); auto dataset_revert = raft::make_device_matrix<double,
int64_t>(handle, samples, features);
cuvs::preprocessing::quantize::scalar::inverse_transform(handle, quantizer,
dataset_revert.view());

Parameters:
  • res[in] raft resource

  • quantizer[in] a scalar quantizer

  • dataset[in] a row-major matrix view on device

  • out[out] a row-major matrix view on device

void inverse_transform(raft::resources const &res, const quantizer<double> &quantizer, raft::host_matrix_view<const int8_t, int64_t> dataset, raft::host_matrix_view<double, int64_t> out)#

Perform inverse quantization step on previously quantized dataset.

Note that depending on the chosen data types train dataset the conversion is not lossless.

Usage example:

auto quantized_dataset = raft::make_host_matrix<int8_t, int64_t>(samples, features);
cuvs::preprocessing::quantize::scalar::transform(handle, quantizer, dataset,
quantized_dataset.view()); auto dataset_revert = raft::make_host_matrix<double, int64_t>(samples,
features); cuvs::preprocessing::quantize::scalar::inverse_transform(handle, quantizer,
dataset_revert.view());

Parameters:
  • res[in] raft resource

  • quantizer[in] a scalar quantizer

  • dataset[in] a row-major matrix view on host

  • out[out] a row-major matrix view on host

quantizer<float> train(raft::resources const &res, const params params, raft::device_matrix_view<const float, int64_t> dataset)#

Initializes a scalar quantizer to be used later for quantizing the dataset.

Usage example:

raft::handle_t handle;
cuvs::preprocessing::quantize::scalar::params params;
auto quantizer = cuvs::preprocessing::quantize::scalar::train<float, int8_t>(handle, params,
dataset);

Parameters:
  • res[in] raft resource

  • params[in] configure scalar quantizer, e.g. quantile

  • dataset[in] a row-major matrix view on device

Returns:

quantizer

quantizer<float> train(raft::resources const &res, const params params, raft::host_matrix_view<const float, int64_t> dataset)#

Initializes a scalar quantizer to be used later for quantizing the dataset.

Usage example:

raft::handle_t handle;
cuvs::preprocessing::quantize::scalar::params params;
auto quantizer = cuvs::preprocessing::quantize::scalar::train<float, int8_t>(handle, params,
dataset);

Parameters:
  • res[in] raft resource

  • params[in] configure scalar quantizer, e.g. quantile

  • dataset[in] a row-major matrix view on host

Returns:

quantizer

void transform(raft::resources const &res, const quantizer<float> &quantizer, raft::device_matrix_view<const float, int64_t> dataset, raft::device_matrix_view<int8_t, int64_t> out)#

Applies quantization transform to given dataset.

Usage example:

raft::handle_t handle;
cuvs::preprocessing::quantize::scalar::params params;
auto quantizer = cuvs::preprocessing::quantize::scalar::train<float, int8_t>(handle, params,
dataset); auto quantized_dataset = raft::make_device_matrix<int8_t, int64_t>(handle, samples,
features); cuvs::preprocessing::quantize::scalar::transform(handle, quantizer, dataset,
quantized_dataset.view());

Parameters:
  • res[in] raft resource

  • quantizer[in] a scalar quantizer

  • dataset[in] a row-major matrix view on device

  • out[out] a row-major matrix view on device

void transform(raft::resources const &res, const quantizer<float> &quantizer, raft::host_matrix_view<const float, int64_t> dataset, raft::host_matrix_view<int8_t, int64_t> out)#

Applies quantization transform to given dataset.

Usage example:

raft::handle_t handle;
cuvs::preprocessing::quantize::scalar::params params;
auto quantizer = cuvs::preprocessing::quantize::scalar::train<float, int8_t>(handle, params,
dataset); auto quantized_dataset = raft::make_host_matrix<int8_t, int64_t>(samples, features);
cuvs::preprocessing::quantize::scalar::transform(handle, quantizer, dataset,
quantized_dataset.view());

Parameters:
  • res[in] raft resource

  • quantizer[in] a scalar quantizer

  • dataset[in] a row-major matrix view on host

  • out[out] a row-major matrix view on host

void inverse_transform(raft::resources const &res, const quantizer<float> &quantizer, raft::device_matrix_view<const int8_t, int64_t> dataset, raft::device_matrix_view<float, int64_t> out)#

Perform inverse quantization step on previously quantized dataset.

Note that depending on the chosen data types train dataset the conversion is not lossless.

Usage example:

auto quantized_dataset = raft::make_device_matrix<int8_t, int64_t>(handle, samples, features);
cuvs::preprocessing::quantize::scalar::transform(handle, quantizer, dataset,
quantized_dataset.view()); auto dataset_revert = raft::make_device_matrix<float, int64_t>(handle,
samples, features); cuvs::preprocessing::quantize::scalar::inverse_transform(handle, quantizer,
dataset_revert.view());

Parameters:
  • res[in] raft resource

  • quantizer[in] a scalar quantizer

  • dataset[in] a row-major matrix view on device

  • out[out] a row-major matrix view on device

void inverse_transform(raft::resources const &res, const quantizer<float> &quantizer, raft::host_matrix_view<const int8_t, int64_t> dataset, raft::host_matrix_view<float, int64_t> out)#

Perform inverse quantization step on previously quantized dataset.

Note that depending on the chosen data types train dataset the conversion is not lossless.

Usage example:

auto quantized_dataset = raft::make_host_matrix<int8_t, int64_t>(samples, features);
cuvs::preprocessing::quantize::scalar::transform(handle, quantizer, dataset,
quantized_dataset.view()); auto dataset_revert = raft::make_host_matrix<float, int64_t>(samples,
features); cuvs::preprocessing::quantize::scalar::inverse_transform(handle, quantizer,
dataset_revert.view());

Parameters:
  • res[in] raft resource

  • quantizer[in] a scalar quantizer

  • dataset[in] a row-major matrix view on host

  • out[out] a row-major matrix view on host

quantizer<half> train(raft::resources const &res, const params params, raft::device_matrix_view<const half, int64_t> dataset)#

Initializes a scalar quantizer to be used later for quantizing the dataset.

Usage example:

raft::handle_t handle;
cuvs::preprocessing::quantize::scalar::params params;
auto quantizer = cuvs::preprocessing::quantize::scalar::train<half, int8_t>(handle, params,
dataset);

Parameters:
  • res[in] raft resource

  • params[in] configure scalar quantizer, e.g. quantile

  • dataset[in] a row-major matrix view on device

Returns:

quantizer

quantizer<half> train(raft::resources const &res, const params params, raft::host_matrix_view<const half, int64_t> dataset)#

Initializes a scalar quantizer to be used later for quantizing the dataset.

Usage example:

raft::handle_t handle;
cuvs::preprocessing::quantize::scalar::params params;
auto quantizer = cuvs::preprocessing::quantize::scalar::train<half, int8_t>(handle, params,
dataset);

Parameters:
  • res[in] raft resource

  • params[in] configure scalar quantizer, e.g. quantile

  • dataset[in] a row-major matrix view on host

Returns:

quantizer

void transform(raft::resources const &res, const quantizer<half> &quantizer, raft::device_matrix_view<const half, int64_t> dataset, raft::device_matrix_view<int8_t, int64_t> out)#

Applies quantization transform to given dataset.

Usage example:

raft::handle_t handle;
cuvs::preprocessing::quantize::scalar::params params;
auto quantizer = cuvs::preprocessing::quantize::scalar::train<half, int8_t>(handle, params,
dataset); auto quantized_dataset = raft::make_device_matrix<int8_t, int64_t>(handle, samples,
features); cuvs::preprocessing::quantize::scalar::transform(handle, quantizer, dataset,
quantized_dataset.view());

Parameters:
  • res[in] raft resource

  • quantizer[in] a scalar quantizer

  • dataset[in] a row-major matrix view on device

  • out[out] a row-major matrix view on device

void transform(raft::resources const &res, const quantizer<half> &quantizer, raft::host_matrix_view<const half, int64_t> dataset, raft::host_matrix_view<int8_t, int64_t> out)#

Applies quantization transform to given dataset.

Usage example:

raft::handle_t handle;
cuvs::preprocessing::quantize::scalar::params params;
auto quantizer = cuvs::preprocessing::quantize::scalar::train<half, int8_t>(handle, params,
dataset); auto quantized_dataset = raft::make_host_matrix<int8_t, int64_t>(samples, features);
cuvs::preprocessing::quantize::scalar::transform(handle, quantizer, dataset,
quantized_dataset.view());

Parameters:
  • res[in] raft resource

  • quantizer[in] a scalar quantizer

  • dataset[in] a row-major matrix view on host

  • out[out] a row-major matrix view on host

void inverse_transform(raft::resources const &res, const quantizer<half> &quantizer, raft::device_matrix_view<const int8_t, int64_t> dataset, raft::device_matrix_view<half, int64_t> out)#

Perform inverse quantization step on previously quantized dataset.

Note that depending on the chosen data types train dataset the conversion is not lossless.

Usage example:

auto quantized_dataset = raft::make_device_matrix<int8_t, int64_t>(handle, samples, features);
cuvs::preprocessing::quantize::scalar::transform(handle, quantizer, dataset,
quantized_dataset.view()); auto dataset_revert = raft::make_device_matrix<half, int64_t>(handle,
samples, features); cuvs::preprocessing::quantize::scalar::inverse_transform(handle, quantizer,
dataset_revert.view());

Parameters:
  • res[in] raft resource

  • quantizer[in] a scalar quantizer

  • dataset[in] a row-major matrix view on device

  • out[out] a row-major matrix view on device

void inverse_transform(raft::resources const &res, const quantizer<half> &quantizer, raft::host_matrix_view<const int8_t, int64_t> dataset, raft::host_matrix_view<half, int64_t> out)#

Perform inverse quantization step on previously quantized dataset.

Note that depending on the chosen data types train dataset the conversion is not lossless.

Usage example:

auto quantized_dataset = raft::make_host_matrix<int8_t, int64_t>(samples, features);
cuvs::preprocessing::quantize::scalar::transform(handle, quantizer, dataset,
quantized_dataset.view()); auto dataset_revert = raft::make_host_matrix<half, int64_t>(samples,
features); cuvs::preprocessing::quantize::scalar::inverse_transform(handle, quantizer,
dataset_revert.view());

Parameters:
  • res[in] raft resource

  • quantizer[in] a scalar quantizer

  • dataset[in] a row-major matrix view on host

  • out[out] a row-major matrix view on host

struct params#
#include <scalar.hpp>

quantizer parameters.

template<typename T>
struct quantizer#
#include <scalar.hpp>

Defines and stores scalar for quantisation upon training.

The quantization is performed by a linear mapping of an interval in the float data type to the full range of the quantized int type.

Template Parameters:

T – data element type