|
25 | 25 |
|
26 | 26 | @export.public_api(document_under="compiling_code/input_info", document_init_sig=False) |
27 | 27 | @dataclass |
28 | | -class ShapeBounds: |
| 28 | +class Bounds: |
29 | 29 | min: Tuple[IntLike] |
30 | 30 | """ |
31 | | - The minimum shape. |
| 31 | + The minimum value. |
32 | 32 | """ |
33 | 33 | opt: Tuple[IntLike] |
34 | 34 | """ |
35 | | - The shape to optimize for. |
| 35 | + The value to optimize for. |
36 | 36 | """ |
37 | 37 | max: Tuple[IntLike] |
38 | 38 | """ |
39 | | - The maximum shape. |
| 39 | + The maximum value. |
40 | 40 | """ |
41 | 41 |
|
42 | 42 | def is_static(self): |
43 | 43 | return self.min == self.opt == self.max |
44 | 44 |
|
45 | 45 |
|
46 | | -@json_utils.Encoder.register(ShapeBounds) |
47 | | -def encode_shape_bounds(shape_bounds): |
| 46 | +@json_utils.Encoder.register(Bounds) |
| 47 | +def encode_bounds(bounds): |
48 | 48 | return { |
49 | | - "min": shape_bounds.min, |
50 | | - "opt": shape_bounds.opt, |
51 | | - "max": shape_bounds.max, |
| 49 | + "min": bounds.min, |
| 50 | + "opt": bounds.opt, |
| 51 | + "max": bounds.max, |
52 | 52 | } |
53 | 53 |
|
54 | 54 |
|
55 | | -@json_utils.Decoder.register(ShapeBounds) |
56 | | -def decode_shape_bounds(shape_bounds_dict): |
57 | | - return ShapeBounds( |
58 | | - min=tuple(shape_bounds_dict["min"]), |
59 | | - opt=tuple(shape_bounds_dict["opt"]), |
60 | | - max=tuple(shape_bounds_dict["max"]), |
61 | | - ) |
62 | | - |
63 | | - |
64 | | -@dataclass |
65 | | -class ValueBounds: |
66 | | - min: Tuple[IntLike] |
67 | | - opt: Tuple[IntLike] |
68 | | - max: Tuple[IntLike] |
69 | | - |
70 | | - |
71 | | -@json_utils.Encoder.register(ValueBounds) |
72 | | -def encode_value_bounds(value_bounds): |
73 | | - return { |
74 | | - "min": tuple(value_bounds.min), |
75 | | - "opt": tuple(value_bounds.opt), |
76 | | - "max": tuple(value_bounds.max), |
77 | | - } |
78 | | - |
79 | | - |
80 | | -@json_utils.Decoder.register(ValueBounds) |
81 | | -def decode_value_bounds(value_bounds_dict): |
82 | | - return ValueBounds( |
83 | | - min=tuple(value_bounds_dict["min"]), |
84 | | - opt=tuple(value_bounds_dict["opt"]), |
85 | | - max=tuple(value_bounds_dict["max"]), |
| 55 | +@json_utils.Decoder.register(Bounds) |
| 56 | +def decode_bounds(bounds_dict): |
| 57 | + return Bounds( |
| 58 | + min=tuple(bounds_dict["min"]), |
| 59 | + opt=tuple(bounds_dict["opt"]), |
| 60 | + max=tuple(bounds_dict["max"]), |
86 | 61 | ) |
0 commit comments