|
24 | 24 |
|
25 | 25 | cp = cupywrapper.cp |
26 | 26 |
|
27 | | -nvtx = cupywrapper.nvtx |
28 | 27 | from typing import Literal, Optional, Tuple, Union |
29 | 28 |
|
30 | 29 | __all__ = [ |
@@ -70,53 +69,6 @@ def rescale_to_int( |
70 | 69 | The original data, clipped to the range specified with the perc_range_min and |
71 | 70 | perc_range_max, and scaled to the full range of the output integer type |
72 | 71 | """ |
73 | | - if cupywrapper.cupy_run: |
74 | | - return __rescale_to_int(data, perc_range_min, perc_range_max, bits, glob_stats) |
75 | | - else: |
76 | | - print("rescale_to_int won't be executed because CuPy is not installed") |
77 | | - return data |
78 | | - |
79 | | - |
80 | | -@nvtx.annotate() |
81 | | -def __rescale_to_int( |
82 | | - data: cp.ndarray, |
83 | | - perc_range_min: float = 0.0, |
84 | | - perc_range_max: float = 100.0, |
85 | | - bits: Literal[8, 16, 32] = 8, |
86 | | - glob_stats: Optional[Tuple[float, float, float, int]] = None, |
87 | | -): |
88 | | - """ |
89 | | - Rescales the data and converts it fit into the range of an unsigned integer type |
90 | | - with the given number of bits. |
91 | | -
|
92 | | - Parameters |
93 | | - ---------- |
94 | | - data : cp.ndarray |
95 | | - Required input data array, on GPU |
96 | | - perc_range_min: float, optional |
97 | | - The lower cutoff point in the input data, in percent of the data range (defaults to 0). |
98 | | - The lower bound is computed as min + perc_range_min/100*(max-min) |
99 | | - perc_range_max: float, optional |
100 | | - The upper cutoff point in the input data, in percent of the data range (defaults to 100). |
101 | | - The upper bound is computed as min + perc_range_max/100*(max-min) |
102 | | - bits: Literal[8, 16, 32], optional |
103 | | - The number of bits in the output integer range (defaults to 8). |
104 | | - Allowed values are: |
105 | | - - 8 -> uint8 |
106 | | - - 16 -> uint16 |
107 | | - - 32 -> uint32 |
108 | | - glob_stats: tuple, optional |
109 | | - Global statistics of the full dataset (beyond the data passed into this call). |
110 | | - It's a tuple with (min, max, sum, num_items). If not given, the min/max is |
111 | | - computed from the given data. |
112 | | -
|
113 | | - Returns |
114 | | - ------- |
115 | | - cp.ndarray |
116 | | - The original data, clipped to the range specified with the perc_range_min and |
117 | | - perc_range_max, and scaled to the full range of the output integer type |
118 | | - """ |
119 | | - |
120 | 72 | if bits == 8: |
121 | 73 | output_dtype: Union[type[np.uint8], type[np.uint16], type[np.uint32]] = np.uint8 |
122 | 74 | elif bits == 16: |
|
0 commit comments