Explorar o código

[DLRM/PyT] Fix np.bool API deprecation

Tomasz Grel %!s(int64=2) %!d(string=hai) anos
pai
achega
e52bcb007d

+ 2 - 2
PyTorch/Recommendation/DLRM/dlrm/data/datasets.py

@@ -93,7 +93,7 @@ class ParametricDataset(Dataset):
         self._label_file = None
         self._numerical_bytes_per_batch = bytes_per_feature[numerical_features[0]] * \
                                           len(numerical_features) * batch_size
-        self._label_bytes_per_batch = np.dtype(np.bool).itemsize * batch_size
+        self._label_bytes_per_batch = np.dtype(bool).itemsize * batch_size
         self._number_of_numerical_features = len(numerical_features)
 
         chosen_mapping = feature_spec.source_spec[mapping]
@@ -187,7 +187,7 @@ class ParametricDataset(Dataset):
     def _get_label(self, idx: int) -> torch.Tensor:
         raw_label_data = os.pread(self._label_file, self._label_bytes_per_batch,
                                   idx * self._label_bytes_per_batch)
-        array = np.frombuffer(raw_label_data, dtype=np.bool)
+        array = np.frombuffer(raw_label_data, dtype=bool)
         return torch.from_numpy(array).to(torch.float32)
 
     def _get_numerical_features(self, idx: int) -> Optional[torch.Tensor]:

+ 2 - 2
PyTorch/Recommendation/DLRM/dlrm/data/feature_spec.py

@@ -172,7 +172,7 @@ class FeatureSpec:
                     assert len(contained_features) == 1
 
                     # check label dtype
-                    assert np.dtype(self.feature_spec[first_feature][DTYPE_SELECTOR]) == np.bool
+                    assert np.dtype(self.feature_spec[first_feature][DTYPE_SELECTOR]) == bool
 
                 else:
                     assert False, "Feature of unknown type"
@@ -202,7 +202,7 @@ class FeatureSpec:
                         zip(categorical_feature_names, cat_feature_types, categorical_feature_cardinalities)}
         for f_name in numerical_feature_names:
             feature_dict[f_name] = {DTYPE_SELECTOR: str(np.dtype(np.float16))}
-        feature_dict[label_feature_name] = {DTYPE_SELECTOR: str(np.dtype(np.bool))}
+        feature_dict[label_feature_name] = {DTYPE_SELECTOR: str(np.dtype(bool))}
 
         channel_spec = {CATEGORICAL_CHANNEL: categorical_feature_names,
                         NUMERICAL_CHANNEL: numerical_feature_names,

+ 1 - 1
PyTorch/Recommendation/DLRM/preproc/split_dataset.py

@@ -70,7 +70,7 @@ def split_binary_file(
             numerical_f.write(numerical_features.astype(np.float16).tobytes())
 
             label = batch_data[:, 0]
-            label_f.write(label.astype(np.bool).tobytes())
+            label_f.write(label.astype(bool).tobytes())
 
             cat_offset = num_numerical_features + 1
             for cat_idx, cat_feature_type in enumerate(cat_feature_types):