Skip to content

Commit

Permalink
fix initialization of sliding_window
Browse files Browse the repository at this point in the history
  • Loading branch information
thucpham committed Nov 3, 2023
1 parent c92641a commit 6c90bcf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python/ctranslate2/specs/transformer_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def __init__(
self.alibi_use_positive_positions = alibi_use_positive_positions
self.scale_alibi = scale_alibi
if sliding_window is not None:
self.sliding_window = sliding_window
self.sliding_window = np.dtype("int32").type(sliding_window)
if (
not relative_position
and not relative_attention_bias
Expand Down
2 changes: 1 addition & 1 deletion src/layers/attention.cc
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ namespace ctranslate2 {
&& !_relative_position_keys
&& !_relative_position_values)
, _cache_time_dim(_merge_time_and_head_dims ? 1 : 2)
, _sliding_window(model.get_attribute_with_default<int>(scope + "/sliding_window", 0))
, _sliding_window(model.get_attribute_with_default<dim_t>(scope + "/sliding_window", 0))
{
if (_relative_position_keys)
_maximum_relative_position = (_relative_position_keys->dim(0) - 1) / 2;
Expand Down
2 changes: 1 addition & 1 deletion src/layers/transformer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ namespace ctranslate2 {
: build_position_encoder(model, scope + "/position_encodings", _embeddings))
, _with_encoder_attention(_layers.front()->has_cross_attention())
, _proj(model, scope + "/projection")
, _sliding_window(model.get_attribute_with_default<int>(scope + "/sliding_window", 0)) {
, _sliding_window(model.get_attribute_with_default<dim_t>(scope + "/sliding_window", 0)) {

dim_t alignment_layer = (
model.get_attribute_with_default<int32_t>(scope + "/alignment_layer", -1));
Expand Down

0 comments on commit 6c90bcf

Please sign in to comment.