Skip to content

Commit 97e19f5

Browse files
committed
Add fp32 support for initialize
1 parent 9c7e9a1 commit 97e19f5

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

dpbench/benchmarks/black_scholes/black_scholes_initialize.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ def initialize(nopt, seed, types_dict):
77
import numpy as np
88
import numpy.random as default_rng
99

10-
dtype = types_dict["float"]
11-
S0L = 10.0
12-
S0H = 50.0
13-
XL = 10.0
14-
XH = 50.0
15-
TL = 1.0
16-
TH = 2.0
17-
RISK_FREE = 0.1
18-
VOLATILITY = 0.2
10+
dtype: np.dtype = types_dict["float"]
11+
S0L = dtype.type(10.0)
12+
S0H = dtype.type(50.0)
13+
XL = dtype.type(10.0)
14+
XH = dtype.type(50.0)
15+
TL = dtype.type(1.0)
16+
TH = dtype.type(2.0)
17+
RISK_FREE = dtype.type(0.1)
18+
VOLATILITY = dtype.type(0.2)
1919

2020
default_rng.seed(seed)
2121
price = default_rng.uniform(S0L, S0H, nopt).astype(dtype)

dpbench/benchmarks/dbscan/dbscan_initialize.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ class Params(NamedTuple):
6464
data_size, Params(eps=DEFAULT_EPS, minpts=DEFAULT_MINPTS)
6565
)
6666

67+
dtype: np.dtype = types_dict["float"]
68+
6769
return (
68-
X.flatten().astype(types_dict["float"]),
69-
params.eps,
70+
X.flatten().astype(dtype),
71+
dtype.type(params.eps),
7072
params.minpts,
7173
)

dpbench/benchmarks/kmeans/kmeans_initialize.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ def initialize(npoints, niters, seed, ndims, ncentroids, types_dict):
77
import numpy as np
88
import numpy.random as default_rng
99

10-
f_dtype = types_dict["float"]
11-
i_dtype = types_dict["int"]
12-
XL = 1.0
13-
XH = 5.0
10+
f_dtype: np.dtype = types_dict["float"]
11+
i_dtype: np.dtype = types_dict["int"]
12+
XL = f_dtype.type(1.0)
13+
XH = f_dtype.type(5.0)
1414

1515
default_rng.seed(seed)
1616

dpbench/benchmarks/knn/knn_initialize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ def _gen_test_data(test_size, data_dim, seed_test, dtype):
4141
)
4242
x_test = _gen_test_data(test_size, data_dim, seed_test, dtype)
4343
predictions = np.empty(test_size, types_dict["int"])
44-
votes_to_classes = np.zeros((test_size, classes_num))
44+
votes_to_classes = np.zeros((test_size, classes_num), dtype)
4545

4646
return (x_train, y_train, x_test, predictions, votes_to_classes)

dpbench/benchmarks/rambo/rambo_initialize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ def initialize(nevts, nout, types_dict):
1919
F1[i, j] = np.random.rand()
2020
Q1[i, j] = np.random.rand() * np.random.rand()
2121

22-
return (C1, F1, Q1, np.empty((nevts, nout, 4)))
22+
return (C1, F1, Q1, np.empty((nevts, nout, 4), dtype))

0 commit comments

Comments
 (0)