EmbCacheEmbeddingConfig

Function

EmbCacheEmbeddingConfig is a configuration class API of EmbCacheEmbeddingCollection. It is used to configure the table size, dimension, and data type.

Prototype

1
2
class EmbCacheEmbeddingConfig:
    def __init__(**kwargs):

Parameters

Parameter

Data Type

Mandatory/Optional

Description

num_embeddings

int

Mandatory

Number of rows in a sparse table. Value range: [1, 1 billion]

When row_wise is used, the number of rows in at least one sparse table is greater than or equal to the number of used cards.

embedding_dim

int

Mandatory

Number of columns in a sparse table. Value range: [8, 4096] The value must be a multiple of 8.

name

str

Mandatory

Name of a sparse table. The value can contain only digits, letters, and underscores (_).

data_type

torchrec.types.DataType

Optional

Data type of a sparse table. The default value is DataType.FP32.

feature_names

List[str]

Mandatory

Name of the feature queried in a sparse table. The value can contain only digits, letters, and underscores (_).

weight_init_max

float

Optional

The default value is None or 1.0. User-defined values are not supported.

weight_init_min

float

Optional

The default value is None or 0.0. User-defined values are not supported.

num_embeddings_post_pruning

int

Optional

The default value is None. User-defined values are not supported.

init_fn

Callable

Optional

Functions of the nn.Parameter type can be passed. Ensure that the function is correct. The default value is None.

need_pos

bool

Optional

The default value is False. User-defined values are not supported.

weight_init_mean

float

Optional

Mean value for weight initialization. This parameter is used for the UNIFORM initialization type. The default value is 0.0.

weight_init_stddev

float

Optional

Standard deviation for weight initialization. This parameter is used for the UNIFORM initialization type. The default value is 0.05.

initializer_type

InitializerType

Optional

Weight initialization type. The value can be LINEAR, TRUNCATED_NORMAL, or UNIFORM. The default value is LINEAR.

admit_and_evict_config

AdmitAndEvictConfig

Optional

Feature admission and elimination configuration. By default, the admission and elimination functions are disabled.

Return Value

  • Success: The EmbCacheEmbeddingConfig object is returned.
  • Failure: An exception is thrown.