Skip to content

Commit e52bcb0

Browse files
committed
[DLRM/PyT] Fix np.bool API deprecation
1 parent 6f3a71a commit e52bcb0

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

PyTorch/Recommendation/DLRM/dlrm/data/datasets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def __init__(
9393
self._label_file = None
9494
self._numerical_bytes_per_batch = bytes_per_feature[numerical_features[0]] * \
9595
len(numerical_features) * batch_size
96-
self._label_bytes_per_batch = np.dtype(np.bool).itemsize * batch_size
96+
self._label_bytes_per_batch = np.dtype(bool).itemsize * batch_size
9797
self._number_of_numerical_features = len(numerical_features)
9898

9999
chosen_mapping = feature_spec.source_spec[mapping]
@@ -187,7 +187,7 @@ def _get_item(self, idx: int) -> Tuple[torch.Tensor, Optional[torch.Tensor], Opt
187187
def _get_label(self, idx: int) -> torch.Tensor:
188188
raw_label_data = os.pread(self._label_file, self._label_bytes_per_batch,
189189
idx * self._label_bytes_per_batch)
190-
array = np.frombuffer(raw_label_data, dtype=np.bool)
190+
array = np.frombuffer(raw_label_data, dtype=bool)
191191
return torch.from_numpy(array).to(torch.float32)
192192

193193
def _get_numerical_features(self, idx: int) -> Optional[torch.Tensor]:

PyTorch/Recommendation/DLRM/dlrm/data/feature_spec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def check_feature_spec(self):
172172
assert len(contained_features) == 1
173173

174174
# check label dtype
175-
assert np.dtype(self.feature_spec[first_feature][DTYPE_SELECTOR]) == np.bool
175+
assert np.dtype(self.feature_spec[first_feature][DTYPE_SELECTOR]) == bool
176176

177177
else:
178178
assert False, "Feature of unknown type"
@@ -202,7 +202,7 @@ def get_default_feature_spec(number_of_numerical_features, categorical_feature_c
202202
zip(categorical_feature_names, cat_feature_types, categorical_feature_cardinalities)}
203203
for f_name in numerical_feature_names:
204204
feature_dict[f_name] = {DTYPE_SELECTOR: str(np.dtype(np.float16))}
205-
feature_dict[label_feature_name] = {DTYPE_SELECTOR: str(np.dtype(np.bool))}
205+
feature_dict[label_feature_name] = {DTYPE_SELECTOR: str(np.dtype(bool))}
206206

207207
channel_spec = {CATEGORICAL_CHANNEL: categorical_feature_names,
208208
NUMERICAL_CHANNEL: numerical_feature_names,

PyTorch/Recommendation/DLRM/preproc/split_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def split_binary_file(
7070
numerical_f.write(numerical_features.astype(np.float16).tobytes())
7171

7272
label = batch_data[:, 0]
73-
label_f.write(label.astype(np.bool).tobytes())
73+
label_f.write(label.astype(bool).tobytes())
7474

7575
cat_offset = num_numerical_features + 1
7676
for cat_idx, cat_feature_type in enumerate(cat_feature_types):

0 commit comments

Comments
 (0)