From ab8708f9376b3153e0d9b44916f2f9faf9ac624b Mon Sep 17 00:00:00 2001 From: manideepika21 Date: Fri, 10 Apr 2026 15:44:21 -0400 Subject: [PATCH] Added inputs and rules for xla apis --- llm/gemini/valid_inputs_tf-xla-apis.py | 960 ++++ rules-tf/xla.reduce_precision/log-rulegen | 5234 +++++++++++++++++++ rules-tf/xla.reduce_precision/rule_1.py | 36 + rules-tf/xla.reduce_precision/rule_11.py | 41 + rules-tf/xla.reduce_precision/rule_12.py | 46 + rules-tf/xla.reduce_precision/rule_13.py | 36 + rules-tf/xla.reduce_precision/rule_14.py | 36 + rules-tf/xla.reduce_precision/rule_15.py | 46 + rules-tf/xla.reduce_precision/rule_16.py | 46 + rules-tf/xla.reduce_precision/rule_17.py | 46 + rules-tf/xla.reduce_precision/rule_18.py | 46 + rules-tf/xla.reduce_precision/rule_2.py | 36 + rules-tf/xla.reduce_precision/rule_20.py | 46 + rules-tf/xla.reduce_precision/rule_22.py | 41 + rules-tf/xla.reduce_precision/rule_23.py | 41 + rules-tf/xla.reduce_precision/rule_24.py | 46 + rules-tf/xla.reduce_precision/rule_25.py | 46 + rules-tf/xla.reduce_precision/rule_26.py | 46 + rules-tf/xla.reduce_precision/rule_27.py | 46 + rules-tf/xla.reduce_precision/rule_28.py | 41 + rules-tf/xla.reduce_precision/rule_29.py | 41 + rules-tf/xla.reduce_precision/rule_3.py | 41 + rules-tf/xla.reduce_precision/rule_31.py | 36 + rules-tf/xla.reduce_precision/rule_32.py | 46 + rules-tf/xla.reduce_precision/rule_33.py | 41 + rules-tf/xla.reduce_precision/rule_34.py | 46 + rules-tf/xla.reduce_precision/rule_35.py | 46 + rules-tf/xla.reduce_precision/rule_36.py | 46 + rules-tf/xla.reduce_precision/rule_38.py | 46 + rules-tf/xla.reduce_precision/rule_39.py | 46 + rules-tf/xla.reduce_precision/rule_4.py | 36 + rules-tf/xla.reduce_precision/rule_40.py | 46 + rules-tf/xla.reduce_precision/rule_41.py | 46 + rules-tf/xla.reduce_precision/rule_42.py | 46 + rules-tf/xla.reduce_precision/rule_43.py | 46 + rules-tf/xla.reduce_precision/rule_44.py | 41 + rules-tf/xla.reduce_precision/rule_45.py | 41 + rules-tf/xla.reduce_precision/rule_46.py | 46 + rules-tf/xla.reduce_precision/rule_47.py | 46 + rules-tf/xla.reduce_precision/rule_48.py | 46 + rules-tf/xla.reduce_precision/rule_49.py | 46 + rules-tf/xla.reduce_precision/rule_5.py | 46 + rules-tf/xla.reduce_precision/rule_50.py | 46 + rules-tf/xla.reduce_precision/rule_52.py | 36 + rules-tf/xla.reduce_precision/rule_53.py | 36 + rules-tf/xla.reduce_precision/rule_54.py | 46 + rules-tf/xla.reduce_precision/rule_55.py | 46 + rules-tf/xla.reduce_precision/rule_56.py | 46 + rules-tf/xla.reduce_precision/rule_57.py | 41 + rules-tf/xla.reduce_precision/rule_6.py | 41 + rules-tf/xla.reduce_precision/rule_7.py | 41 + rules-tf/xla.reduce_precision/rule_8.py | 41 + rules-tf/xla.reduce_precision/rules-ebnf | 150 + rules-tf/xla.rng_bit_generator/log-rulegen | 5314 ++++++++++++++++++++ rules-tf/xla.rng_bit_generator/rule_11.py | 36 + rules-tf/xla.rng_bit_generator/rule_14.py | 39 + rules-tf/xla.rng_bit_generator/rule_15.py | 41 + rules-tf/xla.rng_bit_generator/rule_17.py | 39 + rules-tf/xla.rng_bit_generator/rule_2.py | 39 + rules-tf/xla.rng_bit_generator/rule_21.py | 36 + rules-tf/xla.rng_bit_generator/rule_22.py | 39 + rules-tf/xla.rng_bit_generator/rule_23.py | 36 + rules-tf/xla.rng_bit_generator/rule_25.py | 39 + rules-tf/xla.rng_bit_generator/rule_28.py | 36 + rules-tf/xla.rng_bit_generator/rule_29.py | 41 + rules-tf/xla.rng_bit_generator/rule_3.py | 36 + rules-tf/xla.rng_bit_generator/rule_36.py | 41 + rules-tf/xla.rng_bit_generator/rule_42.py | 44 + rules-tf/xla.rng_bit_generator/rule_43.py | 44 + rules-tf/xla.rng_bit_generator/rule_44.py | 41 + rules-tf/xla.rng_bit_generator/rule_45.py | 41 + rules-tf/xla.rng_bit_generator/rule_49.py | 36 + rules-tf/xla.rng_bit_generator/rule_5.py | 39 + rules-tf/xla.rng_bit_generator/rule_6.py | 36 + rules-tf/xla.rng_bit_generator/rule_7.py | 41 + rules-tf/xla.rng_bit_generator/rule_8.py | 42 + rules-tf/xla.rng_bit_generator/rule_9.py | 36 + rules-tf/xla.rng_bit_generator/rules-ebnf | 150 + rules-tf/xla.sort/log-rulegen | 4024 +++++++++++++++ rules-tf/xla.sort/rule_1.py | 36 + rules-tf/xla.sort/rule_10.py | 41 + rules-tf/xla.sort/rule_11.py | 36 + rules-tf/xla.sort/rule_12.py | 41 + rules-tf/xla.sort/rule_13.py | 41 + rules-tf/xla.sort/rule_14.py | 41 + rules-tf/xla.sort/rule_15.py | 41 + rules-tf/xla.sort/rule_16.py | 41 + rules-tf/xla.sort/rule_18.py | 36 + rules-tf/xla.sort/rule_2.py | 36 + rules-tf/xla.sort/rule_20.py | 36 + rules-tf/xla.sort/rule_21.py | 41 + rules-tf/xla.sort/rule_22.py | 41 + rules-tf/xla.sort/rule_23.py | 41 + rules-tf/xla.sort/rule_24.py | 41 + rules-tf/xla.sort/rule_25.py | 41 + rules-tf/xla.sort/rule_27.py | 36 + rules-tf/xla.sort/rule_29.py | 41 + rules-tf/xla.sort/rule_3.py | 36 + rules-tf/xla.sort/rule_30.py | 44 + rules-tf/xla.sort/rule_31.py | 41 + rules-tf/xla.sort/rule_32.py | 43 + rules-tf/xla.sort/rule_33.py | 43 + rules-tf/xla.sort/rule_34.py | 43 + rules-tf/xla.sort/rule_35.py | 43 + rules-tf/xla.sort/rule_36.py | 43 + rules-tf/xla.sort/rule_37.py | 43 + rules-tf/xla.sort/rule_38.py | 43 + rules-tf/xla.sort/rule_39.py | 43 + rules-tf/xla.sort/rule_40.py | 42 + rules-tf/xla.sort/rule_42.py | 44 + rules-tf/xla.sort/rule_5.py | 36 + rules-tf/xla.sort/rule_6.py | 39 + rules-tf/xla.sort/rule_7.py | 36 + rules-tf/xla.sort/rule_8.py | 41 + rules-tf/xla.sort/rule_9.py | 41 + rules-tf/xla.sort/rules-ebnf | 114 + 116 files changed, 20451 insertions(+) create mode 100644 llm/gemini/valid_inputs_tf-xla-apis.py create mode 100644 rules-tf/xla.reduce_precision/log-rulegen create mode 100644 rules-tf/xla.reduce_precision/rule_1.py create mode 100644 rules-tf/xla.reduce_precision/rule_11.py create mode 100644 rules-tf/xla.reduce_precision/rule_12.py create mode 100644 rules-tf/xla.reduce_precision/rule_13.py create mode 100644 rules-tf/xla.reduce_precision/rule_14.py create mode 100644 rules-tf/xla.reduce_precision/rule_15.py create mode 100644 rules-tf/xla.reduce_precision/rule_16.py create mode 100644 rules-tf/xla.reduce_precision/rule_17.py create mode 100644 rules-tf/xla.reduce_precision/rule_18.py create mode 100644 rules-tf/xla.reduce_precision/rule_2.py create mode 100644 rules-tf/xla.reduce_precision/rule_20.py create mode 100644 rules-tf/xla.reduce_precision/rule_22.py create mode 100644 rules-tf/xla.reduce_precision/rule_23.py create mode 100644 rules-tf/xla.reduce_precision/rule_24.py create mode 100644 rules-tf/xla.reduce_precision/rule_25.py create mode 100644 rules-tf/xla.reduce_precision/rule_26.py create mode 100644 rules-tf/xla.reduce_precision/rule_27.py create mode 100644 rules-tf/xla.reduce_precision/rule_28.py create mode 100644 rules-tf/xla.reduce_precision/rule_29.py create mode 100644 rules-tf/xla.reduce_precision/rule_3.py create mode 100644 rules-tf/xla.reduce_precision/rule_31.py create mode 100644 rules-tf/xla.reduce_precision/rule_32.py create mode 100644 rules-tf/xla.reduce_precision/rule_33.py create mode 100644 rules-tf/xla.reduce_precision/rule_34.py create mode 100644 rules-tf/xla.reduce_precision/rule_35.py create mode 100644 rules-tf/xla.reduce_precision/rule_36.py create mode 100644 rules-tf/xla.reduce_precision/rule_38.py create mode 100644 rules-tf/xla.reduce_precision/rule_39.py create mode 100644 rules-tf/xla.reduce_precision/rule_4.py create mode 100644 rules-tf/xla.reduce_precision/rule_40.py create mode 100644 rules-tf/xla.reduce_precision/rule_41.py create mode 100644 rules-tf/xla.reduce_precision/rule_42.py create mode 100644 rules-tf/xla.reduce_precision/rule_43.py create mode 100644 rules-tf/xla.reduce_precision/rule_44.py create mode 100644 rules-tf/xla.reduce_precision/rule_45.py create mode 100644 rules-tf/xla.reduce_precision/rule_46.py create mode 100644 rules-tf/xla.reduce_precision/rule_47.py create mode 100644 rules-tf/xla.reduce_precision/rule_48.py create mode 100644 rules-tf/xla.reduce_precision/rule_49.py create mode 100644 rules-tf/xla.reduce_precision/rule_5.py create mode 100644 rules-tf/xla.reduce_precision/rule_50.py create mode 100644 rules-tf/xla.reduce_precision/rule_52.py create mode 100644 rules-tf/xla.reduce_precision/rule_53.py create mode 100644 rules-tf/xla.reduce_precision/rule_54.py create mode 100644 rules-tf/xla.reduce_precision/rule_55.py create mode 100644 rules-tf/xla.reduce_precision/rule_56.py create mode 100644 rules-tf/xla.reduce_precision/rule_57.py create mode 100644 rules-tf/xla.reduce_precision/rule_6.py create mode 100644 rules-tf/xla.reduce_precision/rule_7.py create mode 100644 rules-tf/xla.reduce_precision/rule_8.py create mode 100644 rules-tf/xla.reduce_precision/rules-ebnf create mode 100644 rules-tf/xla.rng_bit_generator/log-rulegen create mode 100644 rules-tf/xla.rng_bit_generator/rule_11.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_14.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_15.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_17.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_2.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_21.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_22.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_23.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_25.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_28.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_29.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_3.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_36.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_42.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_43.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_44.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_45.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_49.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_5.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_6.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_7.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_8.py create mode 100644 rules-tf/xla.rng_bit_generator/rule_9.py create mode 100644 rules-tf/xla.rng_bit_generator/rules-ebnf create mode 100644 rules-tf/xla.sort/log-rulegen create mode 100644 rules-tf/xla.sort/rule_1.py create mode 100644 rules-tf/xla.sort/rule_10.py create mode 100644 rules-tf/xla.sort/rule_11.py create mode 100644 rules-tf/xla.sort/rule_12.py create mode 100644 rules-tf/xla.sort/rule_13.py create mode 100644 rules-tf/xla.sort/rule_14.py create mode 100644 rules-tf/xla.sort/rule_15.py create mode 100644 rules-tf/xla.sort/rule_16.py create mode 100644 rules-tf/xla.sort/rule_18.py create mode 100644 rules-tf/xla.sort/rule_2.py create mode 100644 rules-tf/xla.sort/rule_20.py create mode 100644 rules-tf/xla.sort/rule_21.py create mode 100644 rules-tf/xla.sort/rule_22.py create mode 100644 rules-tf/xla.sort/rule_23.py create mode 100644 rules-tf/xla.sort/rule_24.py create mode 100644 rules-tf/xla.sort/rule_25.py create mode 100644 rules-tf/xla.sort/rule_27.py create mode 100644 rules-tf/xla.sort/rule_29.py create mode 100644 rules-tf/xla.sort/rule_3.py create mode 100644 rules-tf/xla.sort/rule_30.py create mode 100644 rules-tf/xla.sort/rule_31.py create mode 100644 rules-tf/xla.sort/rule_32.py create mode 100644 rules-tf/xla.sort/rule_33.py create mode 100644 rules-tf/xla.sort/rule_34.py create mode 100644 rules-tf/xla.sort/rule_35.py create mode 100644 rules-tf/xla.sort/rule_36.py create mode 100644 rules-tf/xla.sort/rule_37.py create mode 100644 rules-tf/xla.sort/rule_38.py create mode 100644 rules-tf/xla.sort/rule_39.py create mode 100644 rules-tf/xla.sort/rule_40.py create mode 100644 rules-tf/xla.sort/rule_42.py create mode 100644 rules-tf/xla.sort/rule_5.py create mode 100644 rules-tf/xla.sort/rule_6.py create mode 100644 rules-tf/xla.sort/rule_7.py create mode 100644 rules-tf/xla.sort/rule_8.py create mode 100644 rules-tf/xla.sort/rule_9.py create mode 100644 rules-tf/xla.sort/rules-ebnf diff --git a/llm/gemini/valid_inputs_tf-xla-apis.py b/llm/gemini/valid_inputs_tf-xla-apis.py new file mode 100644 index 0000000000..46aafa6aff --- /dev/null +++ b/llm/gemini/valid_inputs_tf-xla-apis.py @@ -0,0 +1,960 @@ +generated_inputs = {} + +import numpy as np +import copy + +def xla_add_inputs(): + list_of_inputs = [] + + x = np.array([1, 2, 3], dtype=np.int32) + y = np.array([4, 5, 6], dtype=np.int32) + list_of_inputs.append(copy.deepcopy({"x": x, "y": y})) + + x = np.array([-1, -2, -3], dtype=np.int32) + y = np.array([3, 2, 1], dtype=np.int32) + list_of_inputs.append(copy.deepcopy({"x": x, "y": y})) + + x = np.array([[1.5, 2.5], [3.5, 4.5]], dtype=np.float32) + y = np.array([[0.5, 1.5], [2.5, 3.5]], dtype=np.float32) + list_of_inputs.append(copy.deepcopy({"x": x, "y": y})) + + x = np.array([[1, 2], [3, 4]], dtype=np.int64) + y = np.array([[5, 6], [7, 8]], dtype=np.int64) + list_of_inputs.append(copy.deepcopy({"x": x, "y": y})) + + x = np.array([[[1]], [[2]]], dtype=np.int32) + y = np.array([[[3]], [[4]]], dtype=np.int32) + list_of_inputs.append(copy.deepcopy({"x": x, "y": y})) + + x = np.array([1.0, -1.0, 0.0], dtype=np.float64) + y = np.array([0.5, 0.5, 0.5], dtype=np.float64) + list_of_inputs.append(copy.deepcopy({"x": x, "y": y})) + + x = np.array([[[-1, -2], [-3, -4]]], dtype=np.int32) + y = np.array([[[4, 3], [2, 1]]], dtype=np.int32) + list_of_inputs.append(copy.deepcopy({"x": x, "y": y})) + + x = np.array([10], dtype=np.int32) + y = np.array([20], dtype=np.int32) + list_of_inputs.append(copy.deepcopy({"x": x, "y": y})) + + x = np.array([[1.1, 2.2, 3.3]], dtype=np.float32) + y = np.array([[3.3, 2.2, 1.1]], dtype=np.float32) + list_of_inputs.append(copy.deepcopy({"x": x, "y": y})) + + x = np.array([[[1, 2, 3], [4, 5, 6]]], dtype=np.int64) + y = np.array([[[6, 5, 4], [3, 2, 1]]], dtype=np.int64) + list_of_inputs.append(copy.deepcopy({"x": x, "y": y})) + + x = np.zeros((2, 2), dtype=np.float32) + y = np.ones((2, 2), dtype=np.float32) + list_of_inputs.append(copy.deepcopy({"x": x, "y": y})) + + x = np.array([[100, -100], [-50, 50]], dtype=np.int32) + y = np.array([[1, 1], [1, 1]], dtype=np.int32) + list_of_inputs.append(copy.deepcopy({"x": x, "y": y})) + + return list_of_inputs + +generated_inputs["xla.add"] = xla_add_inputs() + +import numpy as np +import copy + +def xla_broadcast_inputs(): + list_of_inputs = [] + + # Input 1 + x = np.array([1, 2, 3], dtype=np.int32) + shape = (3, 3) + list_of_inputs.append(copy.deepcopy({"x": x, "shape": shape})) + + # Input 2 + x = np.array([[1], [2], [3]], dtype=np.float32) + shape = (3, 4) + list_of_inputs.append(copy.deepcopy({"x": x, "shape": shape})) + + # Input 3 + x = np.array(5, dtype=np.int64) + shape = (2, 2, 2) + list_of_inputs.append(copy.deepcopy({"x": x, "shape": shape})) + + # Input 4 + x = np.array([[1, 2]], dtype=np.float64) + shape = (4, 2) + list_of_inputs.append(copy.deepcopy({"x": x, "shape": shape})) + + # Input 5 + x = np.array([[-1, -2, -3]], dtype=np.int32) + shape = (5, 3) + list_of_inputs.append(copy.deepcopy({"x": x, "shape": shape})) + + # Input 6 + x = np.array([[1], [2]], dtype=np.float32) + shape = (2, 3) + list_of_inputs.append(copy.deepcopy({"x": x, "shape": shape})) + + # Input 7 + x = np.array([1], dtype=np.int32) + shape = (4,) + list_of_inputs.append(copy.deepcopy({"x": x, "shape": shape})) + + # Input 8 + x = np.array([[1, 2, 3]], dtype=np.int64) + shape = (2, 3) + list_of_inputs.append(copy.deepcopy({"x": x, "shape": shape})) + + # Input 9 + x = np.array([[[1]], [[2]]], dtype=np.float32) + shape = (2, 3, 4) + list_of_inputs.append(copy.deepcopy({"x": x, "shape": shape})) + + # Input 10 + x = np.array([[1, 2], [3, 4]], dtype=np.float64) + shape = (2, 2) + list_of_inputs.append(copy.deepcopy({"x": x, "shape": shape})) + + # Input 11 + x = np.array([0], dtype=np.int32) + shape = (3, 3, 3) + list_of_inputs.append(copy.deepcopy({"x": x, "shape": shape})) + + # Input 12 + x = np.array([[True], [False]], dtype=np.bool_) + shape = (2, 2) + list_of_inputs.append(copy.deepcopy({"x": x, "shape": shape})) + + return list_of_inputs + +generated_inputs["xla.broadcast"] = xla_broadcast_inputs() + +import numpy as np +import copy + +def xla_dequantize_inputs(): + list_of_inputs = [] + + input_dict = { + "input": np.array([0, 127, 255], dtype=np.uint8), + "min_range": 0.0, + "max_range": 255.0, + "mode": "MIN_COMBINED", + "transpose_output": False, + "name": "basic_uint8" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([-128, 0, 127], dtype=np.int8), + "min_range": -1.0, + "max_range": 1.0, + "mode": "MIN_FIRST", + "transpose_output": True, + "name": "int8_range" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[0, 10], [20, 30]], dtype=np.uint8), + "min_range": 0.0, + "max_range": 30.0, + "mode": "SCALED", + "transpose_output": False, + "name": "2d_tensor" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[255, 128], [64, 32]], dtype=np.uint8), + "min_range": 0.0, + "max_range": 255.0, + "mode": "MIN_COMBINED", + "transpose_output": True, + "name": "transpose_case" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[[0, 1], [2, 3]]], dtype=np.uint8), + "min_range": 0.0, + "max_range": 3.0, + "mode": "MIN_FIRST", + "transpose_output": False, + "name": "3d_small" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([-10, 0, 10], dtype=np.int8), + "min_range": -10.0, + "max_range": 10.0, + "mode": "SCALED", + "transpose_output": False, + "name": "negative_positive" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[1, 1, 1], [1, 1, 1]], dtype=np.uint8), + "min_range": 0.0, + "max_range": 1.0, + "mode": "MIN_COMBINED", + "transpose_output": False, + "name": "constant_values" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[[255], [128]], [[64], [32]]], dtype=np.uint8), + "min_range": 0.0, + "max_range": 255.0, + "mode": "MIN_FIRST", + "transpose_output": True, + "name": "3d_transpose" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([5, 10, 15, 20], dtype=np.uint8), + "min_range": 5.0, + "max_range": 20.0, + "mode": "SCALED", + "transpose_output": False, + "name": "offset_range" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[0, 255], [255, 0]], dtype=np.uint8), + "min_range": 0.0, + "max_range": 255.0, + "mode": "MIN_COMBINED", + "transpose_output": True, + "name": "checkerboard" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + return list_of_inputs + +generated_inputs["xla.dequantize"] = xla_dequantize_inputs() + +import numpy as np +import copy + +def xla_dynamic_slice_inputs(): + list_of_inputs = [] + + # Input 1 + input_tensor = np.arange(10, dtype=np.int32) + start_indices = np.array([2], dtype=np.int32) + size_indices = np.array([5], dtype=np.int32) + name = "slice_1d_basic" + list_of_inputs.append(copy.deepcopy({ + "input": input_tensor, + "start_indices": start_indices, + "size_indices": size_indices, + "name": name + })) + + # Input 2 + input_tensor = np.arange(16, dtype=np.float32).reshape(4, 4) + start_indices = np.array([1, 1], dtype=np.int32) + size_indices = np.array([2, 2], dtype=np.int32) + name = "slice_2d_center" + list_of_inputs.append(copy.deepcopy({ + "input": input_tensor, + "start_indices": start_indices, + "size_indices": size_indices, + "name": name + })) + + # Input 3 + input_tensor = np.arange(27, dtype=np.int64).reshape(3, 3, 3) + start_indices = np.array([0, 1, 1], dtype=np.int32) + size_indices = np.array([2, 2, 2], dtype=np.int32) + name = "slice_3d" + list_of_inputs.append(copy.deepcopy({ + "input": input_tensor, + "start_indices": start_indices, + "size_indices": size_indices, + "name": name + })) + + # Input 4 + input_tensor = np.array([[-1, -2, -3], [-4, -5, -6]], dtype=np.int32) + start_indices = np.array([0, 0], dtype=np.int32) + size_indices = np.array([1, 3], dtype=np.int32) + name = "slice_negative_values" + list_of_inputs.append(copy.deepcopy({ + "input": input_tensor, + "start_indices": start_indices, + "size_indices": size_indices, + "name": name + })) + + # Input 5 + input_tensor = np.random.randn(5, 5).astype(np.float64) + start_indices = np.array([2, 2], dtype=np.int32) + size_indices = np.array([3, 3], dtype=np.int32) + name = "slice_random_float" + list_of_inputs.append(copy.deepcopy({ + "input": input_tensor, + "start_indices": start_indices, + "size_indices": size_indices, + "name": name + })) + + # Input 6 + input_tensor = np.arange(8, dtype=np.int32).reshape(2, 2, 2) + start_indices = np.array([1, 0, 0], dtype=np.int32) + size_indices = np.array([1, 2, 2], dtype=np.int32) + name = "slice_edge_3d" + list_of_inputs.append(copy.deepcopy({ + "input": input_tensor, + "start_indices": start_indices, + "size_indices": size_indices, + "name": name + })) + + # Input 7 + input_tensor = np.array([[1]], dtype=np.int32) + start_indices = np.array([0, 0], dtype=np.int32) + size_indices = np.array([1, 1], dtype=np.int32) + name = "slice_single_element" + list_of_inputs.append(copy.deepcopy({ + "input": input_tensor, + "start_indices": start_indices, + "size_indices": size_indices, + "name": name + })) + + # Input 8 + input_tensor = np.arange(20, dtype=np.int32) + start_indices = np.array([0], dtype=np.int32) + size_indices = np.array([10], dtype=np.int32) + name = "slice_start_zero" + list_of_inputs.append(copy.deepcopy({ + "input": input_tensor, + "start_indices": start_indices, + "size_indices": size_indices, + "name": name + })) + + # Input 9 + input_tensor = np.arange(60, dtype=np.int32).reshape(3, 4, 5) + start_indices = np.array([1, 2, 3], dtype=np.int32) + size_indices = np.array([2, 2, 2], dtype=np.int32) + name = "slice_high_dim" + list_of_inputs.append(copy.deepcopy({ + "input": input_tensor, + "start_indices": start_indices, + "size_indices": size_indices, + "name": name + })) + + # Input 10 + input_tensor = np.linspace(0, 1, 12, dtype=np.float32).reshape(3, 4) + start_indices = np.array([0, 2], dtype=np.int32) + size_indices = np.array([3, 2], dtype=np.int32) + name = "slice_float_linspace" + list_of_inputs.append(copy.deepcopy({ + "input": input_tensor, + "start_indices": start_indices, + "size_indices": size_indices, + "name": name + })) + + return list_of_inputs + +generated_inputs["xla.dynamic_slice"] = xla_dynamic_slice_inputs() + +import numpy as np +import copy + +def xla_dynamic_update_slice_inputs(): + list_of_inputs = [] + + # Input 1 + input_arr = np.zeros((5,), dtype=np.float32) + update = np.array([1.0, 2.0], dtype=np.float32) + indices = np.array([1], dtype=np.int32) + name = "1d_basic" + list_of_inputs.append(copy.deepcopy({ + "input": input_arr, + "update": update, + "indices": indices, + "name": name + })) + + # Input 2 + input_arr = np.arange(9, dtype=np.int32).reshape(3, 3) + update = np.array([[99]], dtype=np.int32) + indices = np.array([1, 1], dtype=np.int32) + name = "2d_center" + list_of_inputs.append(copy.deepcopy({ + "input": input_arr, + "update": update, + "indices": indices, + "name": name + })) + + # Input 3 + input_arr = np.ones((4, 4), dtype=np.float64) + update = np.array([[5.5, 6.6]], dtype=np.float64) + indices = np.array([2, 1], dtype=np.int32) + name = "2d_row_update" + list_of_inputs.append(copy.deepcopy({ + "input": input_arr, + "update": update, + "indices": indices, + "name": name + })) + + # Input 4 + input_arr = np.zeros((2, 3, 4), dtype=np.int32) + update = np.ones((1, 2, 2), dtype=np.int32) * -3 + indices = np.array([1, 1, 1], dtype=np.int32) + name = "3d_negative_update" + list_of_inputs.append(copy.deepcopy({ + "input": input_arr, + "update": update, + "indices": indices, + "name": name + })) + + # Input 5 + input_arr = np.arange(24, dtype=np.float32).reshape(2, 3, 4) + update = np.array([[[100.0]]], dtype=np.float32) + indices = np.array([0, 2, 3], dtype=np.int32) + name = "3d_single_point" + list_of_inputs.append(copy.deepcopy({ + "input": input_arr, + "update": update, + "indices": indices, + "name": name + })) + + # Input 6 + input_arr = np.zeros((6,), dtype=np.int64) + update = np.array([7, 8, 9], dtype=np.int64) + indices = np.array([2], dtype=np.int32) + name = "1d_longer_update" + list_of_inputs.append(copy.deepcopy({ + "input": input_arr, + "update": update, + "indices": indices, + "name": name + })) + + # Input 7 + input_arr = np.ones((3, 3, 3), dtype=np.float32) + update = np.zeros((2, 2, 2), dtype=np.float32) + indices = np.array([1, 0, 1], dtype=np.int32) + name = "3d_block_update" + list_of_inputs.append(copy.deepcopy({ + "input": input_arr, + "update": update, + "indices": indices, + "name": name + })) + + # Input 8 + input_arr = np.full((4, 4), -1, dtype=np.int32) + update = np.array([[2, 2], [2, 2]], dtype=np.int32) + indices = np.array([0, 0], dtype=np.int32) + name = "2d_top_left" + list_of_inputs.append(copy.deepcopy({ + "input": input_arr, + "update": update, + "indices": indices, + "name": name + })) + + # Input 9 + input_arr = np.arange(16, dtype=np.float64).reshape(4, 4) + update = np.array([[50.5]], dtype=np.float64) + indices = np.array([3, 3], dtype=np.int32) + name = "2d_bottom_right" + list_of_inputs.append(copy.deepcopy({ + "input": input_arr, + "update": update, + "indices": indices, + "name": name + })) + + # Input 10 + input_arr = np.zeros((2, 2, 2, 2), dtype=np.int32) + update = np.ones((1, 1, 1, 1), dtype=np.int32) * 42 + indices = np.array([1, 1, 1, 1], dtype=np.int32) + name = "4d_single_update" + list_of_inputs.append(copy.deepcopy({ + "input": input_arr, + "update": update, + "indices": indices, + "name": name + })) + + return list_of_inputs + +generated_inputs["xla.dynamic_update_slice"] = xla_dynamic_update_slice_inputs() + +import numpy as np +import copy + +def xla_key_value_sort_inputs(): + list_of_inputs = [] + + keys = np.array([3, 1, 2], dtype=np.int32) + values = np.array([30, 10, 20], dtype=np.int32) + name = "simple_1d_int" + list_of_inputs.append(copy.deepcopy({"keys": keys, "values": values, "name": name})) + + keys = np.array([0.2, -1.5, 3.3, 2.2], dtype=np.float32) + values = np.array([2, 4, 1, 3], dtype=np.int32) + name = "float_keys" + list_of_inputs.append(copy.deepcopy({"keys": keys, "values": values, "name": name})) + + keys = np.array([[3, 1], [2, 4]], dtype=np.int32) + values = np.array([[30, 10], [20, 40]], dtype=np.int32) + name = "2d_int" + list_of_inputs.append(copy.deepcopy({"keys": keys, "values": values, "name": name})) + + keys = np.array([[-1, -3, -2]], dtype=np.int32) + values = np.array([[10, 30, 20]], dtype=np.int32) + name = "negative_keys" + list_of_inputs.append(copy.deepcopy({"keys": keys, "values": values, "name": name})) + + keys = np.array([5], dtype=np.int64) + values = np.array([50], dtype=np.int64) + name = "single_element" + list_of_inputs.append(copy.deepcopy({"keys": keys, "values": values, "name": name})) + + keys = np.array([[1.1, 2.2], [3.3, 0.0]], dtype=np.float64) + values = np.array([[11, 22], [33, 0]], dtype=np.int32) + name = "float64_keys" + list_of_inputs.append(copy.deepcopy({"keys": keys, "values": values, "name": name})) + + keys = np.array([3, 3, 1, 2], dtype=np.int32) + values = np.array([300, 301, 100, 200], dtype=np.int32) + name = "duplicate_keys" + list_of_inputs.append(copy.deepcopy({"keys": keys, "values": values, "name": name})) + + keys = np.array([[9, 7, 8], [6, 5, 4]], dtype=np.int32) + values = np.array([[90, 70, 80], [60, 50, 40]], dtype=np.int32) + name = "2d_rectangular" + list_of_inputs.append(copy.deepcopy({"keys": keys, "values": values, "name": name})) + + keys = np.array([0, -1, 1, 0], dtype=np.int32) + values = np.array([0, -10, 10, 5], dtype=np.int32) + name = "zeros_and_negatives" + list_of_inputs.append(copy.deepcopy({"keys": keys, "values": values, "name": name})) + + keys = np.array([1.5, 1.5, 1.5], dtype=np.float32) + values = np.array([15, 16, 17], dtype=np.int32) + name = "all_equal_keys" + list_of_inputs.append(copy.deepcopy({"keys": keys, "values": values, "name": name})) + + keys = np.array([[[3, 1], [2, 4]]], dtype=np.int32) + values = np.array([[[30, 10], [20, 40]]], dtype=np.int32) + name = "3d_tensor" + list_of_inputs.append(copy.deepcopy({"keys": keys, "values": values, "name": name})) + + return list_of_inputs + +generated_inputs["xla.key_value_sort"] = xla_key_value_sort_inputs() + +import numpy as np +import copy + +def xla_pad_inputs(): + list_of_inputs = [] + + input_dict = { + "input": np.array([1, 2, 3], dtype=np.int32), + "padding_value": np.array(0, dtype=np.int32), + "padding_low": np.array([1], dtype=np.int32), + "padding_high": np.array([2], dtype=np.int32), + "padding_interior": np.array([0], dtype=np.int32), + "name": "pad_1d_basic" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[1, 2], [3, 4]], dtype=np.float32), + "padding_value": np.array(1.5, dtype=np.float32), + "padding_low": np.array([1, 1], dtype=np.int32), + "padding_high": np.array([1, 2], dtype=np.int32), + "padding_interior": np.array([0, 0], dtype=np.int32), + "name": "pad_2d_float" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[[-1, -2], [-3, -4]]], dtype=np.int64), + "padding_value": np.array(-9, dtype=np.int64), + "padding_low": np.array([0, 1, 1], dtype=np.int32), + "padding_high": np.array([1, 0, 2], dtype=np.int32), + "padding_interior": np.array([0, 0, 0], dtype=np.int32), + "name": "pad_3d_negative" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([10.5, -2.3, 7.7], dtype=np.float64), + "padding_value": np.array(3.14, dtype=np.float64), + "padding_low": np.array([2], dtype=np.int32), + "padding_high": np.array([2], dtype=np.int32), + "padding_interior": np.array([1], dtype=np.int32), + "name": "pad_1d_interior" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[1]], dtype=np.int32), + "padding_value": np.array(5, dtype=np.int32), + "padding_low": np.array([2, 2], dtype=np.int32), + "padding_high": np.array([2, 2], dtype=np.int32), + "padding_interior": np.array([1, 1], dtype=np.int32), + "name": "pad_single_element" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[1, 2, 3], [4, 5, 6]], dtype=np.int32), + "padding_value": np.array(-1, dtype=np.int32), + "padding_low": np.array([0, 1], dtype=np.int32), + "padding_high": np.array([1, 0], dtype=np.int32), + "padding_interior": np.array([0, 2], dtype=np.int32), + "name": "pad_2d_mixed" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[[1.1], [2.2]], [[3.3], [4.4]]], dtype=np.float32), + "padding_value": np.array(0.0, dtype=np.float32), + "padding_low": np.array([1, 0, 1], dtype=np.int32), + "padding_high": np.array([0, 1, 1], dtype=np.int32), + "padding_interior": np.array([1, 0, 0], dtype=np.int32), + "name": "pad_3d_float" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([5, 6, 7, 8], dtype=np.int64), + "padding_value": np.array(99, dtype=np.int64), + "padding_low": np.array([0], dtype=np.int32), + "padding_high": np.array([3], dtype=np.int32), + "padding_interior": np.array([2], dtype=np.int32), + "name": "pad_1d_large_high" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[[-5]]], dtype=np.int32), + "padding_value": np.array(7, dtype=np.int32), + "padding_low": np.array([1, 1, 1], dtype=np.int32), + "padding_high": np.array([1, 1, 1], dtype=np.int32), + "padding_interior": np.array([0, 0, 0], dtype=np.int32), + "name": "pad_cube" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[1.5, 2.5]], dtype=np.float64), + "padding_value": np.array(-3.5, dtype=np.float64), + "padding_low": np.array([1, 0], dtype=np.int32), + "padding_high": np.array([0, 1], dtype=np.int32), + "padding_interior": np.array([1, 1], dtype=np.int32), + "name": "pad_float64_edge" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + return list_of_inputs + +generated_inputs["xla.pad"] = xla_pad_inputs() + +import numpy as np +import copy + +def xla_reduce_precision_inputs(): + list_of_inputs = [] + + # Input 1 + operand = np.array([1.5, -2.3, 3.7], dtype=np.float32) + exponent_bits = 5 + mantissa_bits = 10 + list_of_inputs.append(copy.deepcopy({ + "operand": operand, + "exponent_bits": exponent_bits, + "mantissa_bits": mantissa_bits + })) + + # Input 2 + operand = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float64) + exponent_bits = 8 + mantissa_bits = 23 + list_of_inputs.append(copy.deepcopy({ + "operand": operand, + "exponent_bits": exponent_bits, + "mantissa_bits": mantissa_bits + })) + + # Input 3 + operand = np.array([-1.25, -0.5, 0.0, 0.5, 1.25], dtype=np.float32) + exponent_bits = 4 + mantissa_bits = 7 + list_of_inputs.append(copy.deepcopy({ + "operand": operand, + "exponent_bits": exponent_bits, + "mantissa_bits": mantissa_bits + })) + + # Input 4 + operand = np.random.randn(3, 3).astype(np.float32) + exponent_bits = 6 + mantissa_bits = 9 + list_of_inputs.append(copy.deepcopy({ + "operand": operand, + "exponent_bits": exponent_bits, + "mantissa_bits": mantissa_bits + })) + + # Input 5 + operand = np.random.uniform(-10, 10, (2, 4, 3)).astype(np.float64) + exponent_bits = 10 + mantissa_bits = 20 + list_of_inputs.append(copy.deepcopy({ + "operand": operand, + "exponent_bits": exponent_bits, + "mantissa_bits": mantissa_bits + })) + + # Input 6 + operand = np.array([[[-1.1], [2.2]], [[-3.3], [4.4]]], dtype=np.float32) + exponent_bits = 3 + mantissa_bits = 5 + list_of_inputs.append(copy.deepcopy({ + "operand": operand, + "exponent_bits": exponent_bits, + "mantissa_bits": mantissa_bits + })) + + # Input 7 + operand = np.linspace(-5, 5, 10, dtype=np.float32) + exponent_bits = 7 + mantissa_bits = 12 + list_of_inputs.append(copy.deepcopy({ + "operand": operand, + "exponent_bits": exponent_bits, + "mantissa_bits": mantissa_bits + })) + + # Input 8 + operand = np.random.randn(1).astype(np.float64) + exponent_bits = 11 + mantissa_bits = 52 + list_of_inputs.append(copy.deepcopy({ + "operand": operand, + "exponent_bits": exponent_bits, + "mantissa_bits": mantissa_bits + })) + + # Input 9 + operand = np.zeros((5, 5), dtype=np.float32) + exponent_bits = 2 + mantissa_bits = 3 + list_of_inputs.append(copy.deepcopy({ + "operand": operand, + "exponent_bits": exponent_bits, + "mantissa_bits": mantissa_bits + })) + + # Input 10 + operand = np.full((2, 2, 2), 7.77, dtype=np.float64) + exponent_bits = 9 + mantissa_bits = 15 + list_of_inputs.append(copy.deepcopy({ + "operand": operand, + "exponent_bits": exponent_bits, + "mantissa_bits": mantissa_bits + })) + + # Input 11 + operand = np.array([1e-10, 1e10, -1e5], dtype=np.float32) + exponent_bits = 5 + mantissa_bits = 8 + list_of_inputs.append(copy.deepcopy({ + "operand": operand, + "exponent_bits": exponent_bits, + "mantissa_bits": mantissa_bits + })) + + return list_of_inputs + +generated_inputs["xla.reduce_precision"] = xla_reduce_precision_inputs() + +import numpy as np +import copy + +def xla_rng_bit_generator_inputs(): + list_of_inputs = [] + + input_dict = { + "algorithm": "philox", + "initial_state": "seed_123", + "shape": [2, 3], + "dtype": np.uint32 + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "algorithm": "threefry", + "initial_state": "state_abc", + "shape": [4], + "dtype": np.int32 + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "algorithm": "default", + "initial_state": "init_state_001", + "shape": [1, 2, 3], + "dtype": np.uint64 + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "algorithm": "philox", + "initial_state": "negative_seed_-1", + "shape": [5, 5], + "dtype": np.int64 + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "algorithm": "threefry", + "initial_state": "long_seed_value_999999", + "shape": [2, 2, 2, 2], + "dtype": np.uint32 + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "algorithm": "default", + "initial_state": "zero_state", + "shape": [10], + "dtype": np.int32 + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "algorithm": "philox", + "initial_state": "state_xyz", + "shape": [3, 1], + "dtype": np.uint64 + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "algorithm": "threefry", + "initial_state": "state_with_special_chars_!@#", + "shape": [6, 0], + "dtype": np.int64 + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "algorithm": "default", + "initial_state": "empty_like_state", + "shape": [], + "dtype": np.uint32 + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "algorithm": "philox", + "initial_state": "very_large_shape", + "shape": [2, 3, 4, 5], + "dtype": np.int32 + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + return list_of_inputs + +generated_inputs["xla.rng_bit_generator"] = xla_rng_bit_generator_inputs() + +import numpy as np +import copy + +def xla_sort_inputs(): + list_of_inputs = [] + + input_dict = { + "input": np.array([3, 1, 2, 5, 4], dtype=np.int32), + "name": "simple_int_sort" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([-1, -3, -2, -5, -4], dtype=np.int32), + "name": "negative_int_sort" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([1.5, 3.2, 0.7, 2.8], dtype=np.float32), + "name": "float_sort" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[3, 2, 1], [6, 5, 4]], dtype=np.int64), + "name": "2d_int_sort" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[1.1, 3.3], [2.2, 0.0]], dtype=np.float64), + "name": "2d_float_sort" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[[3, 1], [2, 4]], [[6, 5], [8, 7]]], dtype=np.int32), + "name": "3d_tensor_sort" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([10], dtype=np.int32), + "name": "single_element" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([], dtype=np.float32), + "name": "empty_tensor" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([5, 5, 5, 5], dtype=np.int32), + "name": "duplicate_values" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([100, -100, 50, -50, 0], dtype=np.int64), + "name": "mixed_values" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + input_dict = { + "input": np.array([[[-1.1, 2.2], [3.3, -4.4]]], dtype=np.float32), + "name": "3d_float_mixed" + } + list_of_inputs.append(copy.deepcopy(input_dict)) + + return list_of_inputs + +generated_inputs["xla.sort"] = xla_sort_inputs() \ No newline at end of file diff --git a/rules-tf/xla.reduce_precision/log-rulegen b/rules-tf/xla.reduce_precision/log-rulegen new file mode 100644 index 0000000000..7c83cfba45 --- /dev/null +++ b/rules-tf/xla.reduce_precision/log-rulegen @@ -0,0 +1,5234 @@ +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 1 (exponent_bits must be non-negative) +{v_2 : int} |= v_2 ≥ 0 +Token usage: input=1402, output=341, total=1743 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 2 (mantissa_bits must be non-negative) +{v_3 : int} |= v_3 ≥ 0 +Token usage: input=1402, output=341, total=1743 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 3 (The sum of exponent_bits and mantissa_bits must be less than 64) +{v_2 : int, v_3 : int} |= v_2 + v_3 ≤ 64 +Token usage: input=1402, output=341, total=1743 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 4 (operand must have a floating-point dtype: 6–8) +{v_1: tensor} |= 6 ≤ dtype_(v_1) ∧ dtype_(v_1) ≤ 8 +Token usage: input=1402, output=341, total=1743 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 5 (if exponent_bits and mantissa_bits are zero, it acts as identity, but only for floating tensors) +{v_1: tensor, v_2 : int, v_3 : int} |= if v_2 = 0 ∧ v_3 = 0 then 6 ≤ dtype_(v_1) ∧ dtype_(v_1) ≤ 8 +Token usage: input=1402, output=341, total=1743 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 6 (mantissa_bits must be less than the bit-width of the tensor's dtype) +{v_1: tensor, v_3 : int} |= if dtype_(v_1) = 6 then v_3 ≤ 10 else if dtype_(v_1) = 7 then v_3 ≤ 23 else if dtype_(v_1) = 8 then v_3 ≤ 52 +Token usage: input=1402, output=341, total=1743 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 7 (If mantissa_bits is greater than 0, exponent_bits should also be greater than 0.) +{v_2 : int, v_3 : int} |= if v_3 > 0 then v_2 > 0 +Token usage: input=3177, output=218, total=3395 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 8 (If exponent_bits is greater than 0, mantissa_bits should also be greater than 0.) +{v_2 : int, v_3 : int} |= if v_2 > 0 then v_3 > 0 +Token usage: input=3177, output=218, total=3395 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 9 (exponent_bits cannot be negative) +{v_2 : int} |= v_2 ≥ 0 +Token usage: input=3177, output=218, total=3395 +** DUPLICATED RULE ** (num_failures: 1) + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 10 (mantissa_bits cannot be negative) +{v_3 : int} |= v_3 ≥ 0 +Token usage: input=3177, output=218, total=3395 +** DUPLICATED RULE ** (num_failures: 2) + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 11 (exponent_bits or mantissa bits can be zero) +{v_2 : int, v_3 : int} |= v_2 = 0 ∨ v_3 = 0 +Token usage: input=3177, output=218, total=3395 +** SUCCESS ** + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_2 : int} |= v_2 ≥ 0 +Duplicated rule: {v_3 : int} |= v_3 ≥ 0 + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 12 (exponent_bits and mantissa_bits cannot be both zero if the input is a float16) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 6 then v_2 > 0 ∨ v_3 > 0 +Token usage: input=4887, output=215, total=5102 +** SUCCESS ** + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_2 : int} |= v_2 ≥ 0 +Duplicated rule: {v_3 : int} |= v_3 ≥ 0 + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 13 (exponent_bits cannot be greater than maximum allowed bits) +{v_2 : int} |= v_2 ≤ 63 +Token usage: input=4887, output=215, total=5102 +** SUCCESS ** + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_2 : int} |= v_2 ≥ 0 +Duplicated rule: {v_3 : int} |= v_3 ≥ 0 + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 14 (mantissa_bits cannot be greater than maximum allowed bits) +{v_3 : int} |= v_3 ≤ 63 +Token usage: input=4887, output=215, total=5102 +** SUCCESS ** + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_2 : int} |= v_2 ≥ 0 +Duplicated rule: {v_3 : int} |= v_3 ≥ 0 + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 15 (If operand is bool, then exponent_bits and mantissa_bits should be 0) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 0 then v_2 = 0 ∧ v_3 = 0 +Token usage: input=4887, output=215, total=5102 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 16 (If operand is complex, exponent_bits and mantissa_bits must be zero) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 9 ∨ dtype_(v_1) = 10 then v_2 = 0 ∧ v_3 = 0 +Token usage: input=6471, output=205, total=6676 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 17 (exponent_bits and mantissa_bits sum must be less than or equal to the total bits available in the float type) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 6 then v_2 + v_3 ≤ 11 else if dtype_(v_1) = 7 then v_2 + v_3 ≤ 24 else if dtype_(v_1) = 8 then v_2 + v_3 ≤ 53 +Token usage: input=6471, output=205, total=6676 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 18 (If operand is integer, then exponent_bits and mantissa_bits must be 0) +{v_1 : tensor, v_2 : int, v_3 : int} |= if 1 ≤ dtype_(v_1) ∧ dtype_(v_1) ≤ 5 then v_2 = 0 ∧ v_3 = 0 +Token usage: input=8119, output=156, total=8275 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 19 (If operand is boolean, exponent_bits and mantissa_bits must be 0) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 0 then v_2 = 0 ∧ v_3 = 0 +Token usage: input=8119, output=156, total=8275 +** DUPLICATED RULE ** (num_failures: 3) + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 0 then v_2 = 0 ∧ v_3 = 0 + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 20 (If the input tensor is of type float16, the exponent_bits + mantissa_bits should be less than or equal to 11) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 6 then v_2 + v_3 ≤ 11 +Token usage: input=9769, output=116, total=9885 +** SUCCESS ** + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 0 then v_2 = 0 ∧ v_3 = 0 + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 21 (exponent_bits and mantissa_bits must be int) +{v_2: int, v_3: int} |= true +Token usage: input=9769, output=116, total=9885 +** REDUNDANT VARIABLES ** (num_failures: 4) + +>>> PROMPT +[Feedback Message from Prior Run] +Redundant variables: {v_2: int, v_3: int} |= true (Unused: v_2, v_3) + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 22 (If exponent_bits is zero, then mantissa_bits can be any non-negative number) +{v_2 : int, v_3 : int} |= if v_2 = 0 then v_3 ≥ 0 +Token usage: input=11345, output=114, total=11459 +** SUCCESS ** + +>>> PROMPT +[Feedback Message from Prior Run] +Redundant variables: {v_2: int, v_3: int} |= true (Unused: v_2, v_3) + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 23 (If mantissa_bits is zero, then exponent_bits can be any non-negative number) +{v_2 : int, v_3 : int} |= if v_3 = 0 then v_2 ≥ 0 +Token usage: input=11345, output=114, total=11459 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 24 (If the input tensor is of type float32, the exponent_bits + mantissa_bits should be less than or equal to 24) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 7 then v_2 + v_3 ≤ 24 +Token usage: input=12928, output=82, total=13010 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 25 (If the input tensor is of type float64, the exponent_bits + mantissa_bits should be less than or equal to 53) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 8 then v_2 + v_3 ≤ 53 +Token usage: input=14410, output=82, total=14492 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 26 (If the input tensor is of type other than float, exponent_bits and mantissa_bits must be zero) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) ≠ 6 ∧ dtype_(v_1) ≠ 7 ∧ dtype_(v_1) ≠ 8 then v_2 = 0 ∧ v_3 = 0 +Token usage: input=15812, output=99, total=15911 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 27 (exponent_bits and mantissa_bits should be less than or equal to the number of bits in the dtype) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 then v_2 + v_3 <= 16 else if dtype_(v_1) = 7 then v_2 + v_3 <= 32 else if dtype_(v_1) = 8 then v_2 + v_3 <= 64 +Token usage: input=17356, output=120, total=17476 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 28 (exponent_bits must be less than the bit width of the tensor's dtype) +{v_1: tensor, v_2 : int} |= if dtype_(v_1) = 6 then v_2 < 16 else if dtype_(v_1) = 7 then v_2 < 32 else if dtype_(v_1) = 8 then v_2 < 64 +Token usage: input=18960, output=193, total=19153 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 29 (mantissa_bits must be less than the bit width of the tensor's dtype) +{v_1: tensor, v_3 : int} |= if dtype_(v_1) = 6 then v_3 < 16 else if dtype_(v_1) = 7 then v_3 < 32 else if dtype_(v_1) = 8 then v_3 < 64 +Token usage: input=18960, output=193, total=19153 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 30 (If the input tensor is a quantized type, exponent_bits and mantissa_bits are ignored) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 1 ∨ dtype_(v_1) = 2 ∨ dtype_(v_1) = 3 ∨ dtype_(v_1) = 4 ∨ dtype_(v_1) = 5 ∨ dtype_(v_1) = 6 then true +Token usage: input=20778, output=116, total=20894 +** REDUNDANT VARIABLES ** (num_failures: 5) + +>>> PROMPT +[Feedback Message from Prior Run] +Redundant variables: {v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 1 ∨ dtype_(v_1) = 2 ∨ dtype_(v_1) = 3 ∨ dtype_(v_1) = 4 ∨ dtype_(v_1) = 5 ∨ dtype_(v_1) = 6 then true (Unused: v_2, v_3) + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 31 (If the input tensor is a quantized type, exponent_bits and mantissa_bits have no effect) +{v_1 : tensor} |= if dtype_(v_1) = 1 ∨ dtype_(v_1) = 2 ∨ dtype_(v_1) = 3 ∨ dtype_(v_1) = 4 ∨ dtype_(v_1) = 5 then true +Token usage: input=22412, output=94, total=22506 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 32 (If exponent_bits + mantissa_bits is greater than zero, the input tensor must be a float type) +{v_1 : tensor, v_2 : int, v_3 : int} |= if v_2 + v_3 > 0 then dtype_(v_1) = 6 ∨ dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 +Token usage: input=23927, output=95, total=24022 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 33 (exponent_bits and mantissa_bits cannot be negative) +{v_2 : int, v_3 : int} |= v_2 ≥ 0 ∧ v_3 ≥ 0 +Token usage: input=25509, output=47, total=25556 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 34 (If exponent_bits is 0, then mantissa bits can be at most the maximum mantissa bits for the dtype) +{v_1: tensor, v_2 : int, v_3 : int} |= if v_2 = 0 then (if dtype_(v_1) = 6 then v_3 <= 11 else if dtype_(v_1) = 7 then v_3 <= 23 else if dtype_(v_1) = 8 then v_3 <= 52) +Token usage: input=26974, output=122, total=27096 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 35 (If mantissa_bits is 0, then exponent bits can be at most the maximum exponent bits for the dtype) +{v_1: tensor, v_2 : int, v_3 : int} |= if v_3 = 0 then (if dtype_(v_1) = 6 then v_2 <= 5 else if dtype_(v_1) = 7 then v_2 <= 8 else if dtype_(v_1) = 8 then v_2 <= 11) +Token usage: input=28459, output=119, total=28578 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 36 (exponent_bits and mantissa_bits should be less than the total number of bits representing the float value) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 then v_2 + v_3 <= 15 else if dtype_(v_1) = 7 then v_2 + v_3 <= 31 else if dtype_(v_1) = 8 then v_2 + v_3 <= 63 +Token usage: input=29980, output=119, total=30099 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 37 (If exponent_bits is specified, mantissa_bits must also be specified, and vice-versa for float tensors) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 ∨ dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 = 0 ↔ v_3 = 0) +Token usage: input=31712, output=102, total=31814 +** PARSING ERROR ** (num_failures: 6) + +>>> PROMPT +[Feedback Message from Prior Run] +Parse error: {v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 ∨ dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 = 0 ↔ v_3 = 0) (Error: No terminal matches '↔' in the current parser context, at line 1 col 107 + +_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 = 0 ↔ v_3 = 0) + ^ +Expected one of: + * MULOP + * __ANON_3 + * RPAR + * __ANON_2 + * ADDOP +) + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 38 (If exponent_bits is specified, mantissa_bits must also be specified, and vice-versa for float tensors) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 ∨ dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 = 0 ∧ v_3 = 0) ∨ (v_2 ≠ 0 ∧ v_3 ≠ 0) +Token usage: input=33679, output=120, total=33799 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 39 (If reducing precision, exponent bits should be smaller than original type's exponent bits and same for mantissa) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 then (v_2 < 5 ∧ v_3 < 11) else if dtype_(v_1) = 7 then (v_2 < 8 ∧ v_3 < 23) else if dtype_(v_1) = 8 then (v_2 < 11 ∧ v_3 < 52) +Token usage: input=35198, output=138, total=35336 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 40 (It is valid to set only exponent bits and rely on implicit truncation for float types) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 ∨ dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 > 0 ∧ v_3 = 0) ∨ (v_2=0 ∧ v_3 > 0) ∨ (v_2>0 ∧ v_3 >0) +Token usage: input=36803, output=128, total=36931 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 41 (exponent_bits and mantissa_bits should both be zero for non-float tensors) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) ≠ 6 ∧ dtype_(v_1) ≠ 7 ∧ dtype_(v_1) ≠ 8 then v_2 = 0 ∧ v_3 = 0 +Token usage: input=38592, output=94, total=38686 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 42 (Reducing to bfloat16 - exponent bits and mantissa bits should be correctly set) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 = 8 ∧ v_3 = 7) +Token usage: input=40131, output=85, total=40216 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 43 (Reducing to fp16 - exponent bits and mantissa bits should be correctly set) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 = 5 ∧ v_3 = 10) +Token usage: input=41688, output=85, total=41773 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 44 (If reducing precision, the number of mantissa bits cannot be increased) +{v_1: tensor, v_3: int} |= if dtype_(v_1) = 6 then v_3 <= 10 else if dtype_(v_1) = 7 then v_3 <= 23 else if dtype_(v_1) = 8 then v_3 <= 52 +Token usage: input=43353, output=93, total=43446 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 45 (If reducing precision, the number of exponent bits cannot be increased) +{v_1: tensor, v_2: int} |= if dtype_(v_1) = 6 then v_2 <= 5 else if dtype_(v_1) = 7 then v_2 <= 8 else if dtype_(v_1) = 8 then v_2 <= 11 +Token usage: input=44847, output=90, total=44937 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 46 (If reducing precision to a lower bit-width, it should be possible to represent the original value in the reduced precision) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 7 then (v_2 <= 8 ∧ v_3 <= 7) ∨ (v_2 <= 5 ∧ v_3 <= 10) else if dtype_(v_1) = 8 then (v_2 <= 8 ∧ v_3 <= 7) ∨ (v_2 <= 5 ∧ v_3 <= 10) +Token usage: input=46504, output=146, total=46650 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 47 (When reducing to bfloat16, the original tensor must be fp32 or fp64) +{v_1: tensor, v_2: int, v_3: int} |= if v_2 = 8 ∧ v_3 = 7 then dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 +Token usage: input=48093, output=86, total=48179 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 48 (When reducing precision to fp16, the original tensor must be fp32 or fp64) +{v_1: tensor, v_2: int, v_3: int} |= if v_2 = 5 ∧ v_3 = 10 then dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 +Token usage: input=49536, output=87, total=49623 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 49 (Mantissa bits + exponent bits <= dtype size -1, for float types) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 6 then v_2 + v_3 <= 15 else if dtype_(v_1) = 7 then v_2 + v_3 <= 31 else if dtype_(v_1) = 8 then v_2 + v_3 <= 63 +Token usage: input=51057, output=113, total=51170 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 50 (If reducing precision, the exponent_bits and mantissa_bits combined can't be zero for fp32 and fp64) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then v_2 + v_3 > 0 +Token usage: input=52605, output=89, total=52694 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 51 (If the input tensor is complex type then the exponent_bits and mantissa_bits must be zero) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 9 ∨ dtype_(v_1) = 10 then v_2 = 0 ∧ v_3 = 0 +Token usage: input=54188, output=87, total=54275 +** DUPLICATED RULE ** (num_failures: 7) + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 9 ∨ dtype_(v_1) = 10 then v_2 = 0 ∧ v_3 = 0 + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 52 (Reducing precision is not defined on string type) +{v_1: tensor} |= if dtype_(v_1) = 11 then false +Token usage: input=56021, output=39, total=56060 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 53 (Reducing precision is not defined on dtype type) +{v_1: tensor} |= if dtype_(v_1) = 12 then false +Token usage: input=57485, output=39, total=57524 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 54 (For float16 tensors, exponent and mantissa bits have to be specified) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 then v_2 > 0 ∧ v_3 > 0 +Token usage: input=59056, output=70, total=59126 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 55 (If the input tensor is a float16, it will be promoted to float32 before reducing, exponent and mantissa bit constraints of float32 apply to that operation) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 then v_2 + v_3 <= 31 +Token usage: input=60581, output=87, total=60668 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 56 (It is invalid to specify only mantissa_bits and not exponent_bits in floating-point types) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 ∨ dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 ≠ 0 ∨ v_3 = 0) +Token usage: input=62052, output=99, total=62151 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.reduce_precision API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] operand: tensor, exponent_bits: integer, mantissa_bits: integer + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 57 (If the input tensor is a float16, it will be promoted to float32 before reducing, if exponent bits are reduced, it should be smaller or equal to 8.) +{v_1: tensor, v_2: int} |= if dtype_(v_1) = 6 then v_2 <= 8 +Token usage: input=63585, output=77, total=63662 +** SUCCESS ** + diff --git a/rules-tf/xla.reduce_precision/rule_1.py b/rules-tf/xla.reduce_precision/rule_1.py new file mode 100644 index 0000000000..adce2f86b5 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_1.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# exponent_bits must be non-negative (Rule 1) + +rule_1 = lambda s, v, n=False: ( + s.add(Not(v["arg1_value"] >= 0) if n else + v["arg1_value"] >= 0) +) + +def rule_1_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, (int, np.integer)) and not isinstance(arg1, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + + # Value assignments + solver.add(arg1_value == int(arg1)) + + # Constraints for rule 1 + rule_1(solver, {'arg1_value': arg1_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_1(solver, {'arg1_value': arg1['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_11.py b/rules-tf/xla.reduce_precision/rule_11.py new file mode 100644 index 0000000000..1b674f24a4 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_11.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# exponent_bits or mantissa bits can be zero (Rule 11) + +rule_11 = lambda s, v, n=False: ( + s.add(Not(Or(v["arg1_value"] == 0, v["arg2_value"] == 0)) if n else + Or(v["arg1_value"] == 0, v["arg2_value"] == 0)) +) + +def rule_11_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, (int, np.integer)) and not isinstance(arg1, bool)): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_value == int(arg1)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 11 + rule_11(solver, {'arg1_value': arg1_value, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_11(solver, {'arg1_value': arg1['value'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_12.py b/rules-tf/xla.reduce_precision/rule_12.py new file mode 100644 index 0000000000..57c5d2c0a2 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_12.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# exponent_bits and mantissa_bits cannot be both zero if the input is a float16 (Rule 12) + +rule_12 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, Or(v["arg2_value"] > 0, v["arg3_value"] > 0), True)) if n else + If(v["arg1_dtype"] == 6, Or(v["arg2_value"] > 0, v["arg3_value"] > 0), True)) +) + +def rule_12_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 12 + rule_12(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_12(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_13.py b/rules-tf/xla.reduce_precision/rule_13.py new file mode 100644 index 0000000000..f6974e152f --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_13.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# exponent_bits cannot be greater than maximum allowed bits (Rule 13) + +rule_13 = lambda s, v, n=False: ( + s.add(Not(v["arg1_value"] <= 63) if n else + v["arg1_value"] <= 63) +) + +def rule_13_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, (int, np.integer)) and not isinstance(arg1, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + + # Value assignments + solver.add(arg1_value == int(arg1)) + + # Constraints for rule 13 + rule_13(solver, {'arg1_value': arg1_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_13(solver, {'arg1_value': arg1['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_14.py b/rules-tf/xla.reduce_precision/rule_14.py new file mode 100644 index 0000000000..98f5ea431e --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_14.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# mantissa_bits cannot be greater than maximum allowed bits (Rule 14) + +rule_14 = lambda s, v, n=False: ( + s.add(Not(v["arg1_value"] <= 63) if n else + v["arg1_value"] <= 63) +) + +def rule_14_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, (int, np.integer)) and not isinstance(arg1, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + + # Value assignments + solver.add(arg1_value == int(arg1)) + + # Constraints for rule 14 + rule_14(solver, {'arg1_value': arg1_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_14(solver, {'arg1_value': arg1['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_15.py b/rules-tf/xla.reduce_precision/rule_15.py new file mode 100644 index 0000000000..a5e82c2bf3 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_15.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If operand is bool, then exponent_bits and mantissa_bits should be 0 (Rule 15) + +rule_15 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 0, And(v["arg2_value"] == 0, v["arg3_value"] == 0), True)) if n else + If(v["arg1_dtype"] == 0, And(v["arg2_value"] == 0, v["arg3_value"] == 0), True)) +) + +def rule_15_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 15 + rule_15(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_15(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_16.py b/rules-tf/xla.reduce_precision/rule_16.py new file mode 100644 index 0000000000..fc757519a9 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_16.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If operand is complex, exponent_bits and mantissa_bits must be zero (Rule 16) + +rule_16 = lambda s, v, n=False: ( + s.add(Not(If(Or(v["arg1_dtype"] == 9, v["arg1_dtype"] == 10), And(v["arg2_value"] == 0, v["arg3_value"] == 0), True)) if n else + If(Or(v["arg1_dtype"] == 9, v["arg1_dtype"] == 10), And(v["arg2_value"] == 0, v["arg3_value"] == 0), True)) +) + +def rule_16_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 16 + rule_16(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_16(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_17.py b/rules-tf/xla.reduce_precision/rule_17.py new file mode 100644 index 0000000000..889b8433ee --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_17.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# exponent_bits and mantissa_bits sum must be less than or equal to the total bits available in the float type (Rule 17) + +rule_17 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, v["arg2_value"] + v["arg3_value"] <= 11, If(v["arg1_dtype"] == 7, v["arg2_value"] + v["arg3_value"] <= 24, If(v["arg1_dtype"] == 8, v["arg2_value"] + v["arg3_value"] <= 53, True)))) if n else + If(v["arg1_dtype"] == 6, v["arg2_value"] + v["arg3_value"] <= 11, If(v["arg1_dtype"] == 7, v["arg2_value"] + v["arg3_value"] <= 24, If(v["arg1_dtype"] == 8, v["arg2_value"] + v["arg3_value"] <= 53, True)))) +) + +def rule_17_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 17 + rule_17(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_17(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_18.py b/rules-tf/xla.reduce_precision/rule_18.py new file mode 100644 index 0000000000..c328e3e2ea --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_18.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If operand is integer, then exponent_bits and mantissa_bits must be 0 (Rule 18) + +rule_18 = lambda s, v, n=False: ( + s.add(Not(If(And(1 <= v["arg1_dtype"], v["arg1_dtype"] <= 5), And(v["arg2_value"] == 0, v["arg3_value"] == 0), True)) if n else + If(And(1 <= v["arg1_dtype"], v["arg1_dtype"] <= 5), And(v["arg2_value"] == 0, v["arg3_value"] == 0), True)) +) + +def rule_18_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 18 + rule_18(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_18(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_2.py b/rules-tf/xla.reduce_precision/rule_2.py new file mode 100644 index 0000000000..62268d37a2 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_2.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# mantissa_bits must be non-negative (Rule 2) + +rule_2 = lambda s, v, n=False: ( + s.add(Not(v["arg1_value"] >= 0) if n else + v["arg1_value"] >= 0) +) + +def rule_2_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, (int, np.integer)) and not isinstance(arg1, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + + # Value assignments + solver.add(arg1_value == int(arg1)) + + # Constraints for rule 2 + rule_2(solver, {'arg1_value': arg1_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_2(solver, {'arg1_value': arg1['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_20.py b/rules-tf/xla.reduce_precision/rule_20.py new file mode 100644 index 0000000000..57d42b339e --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_20.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the input tensor is of type float16, the exponent_bits + mantissa_bits should be less than or equal to 11 (Rule 20) + +rule_20 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, v["arg2_value"] + v["arg3_value"] <= 11, True)) if n else + If(v["arg1_dtype"] == 6, v["arg2_value"] + v["arg3_value"] <= 11, True)) +) + +def rule_20_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 20 + rule_20(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_20(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_22.py b/rules-tf/xla.reduce_precision/rule_22.py new file mode 100644 index 0000000000..39805021ba --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_22.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If exponent_bits is zero, then mantissa_bits can be any non-negative number (Rule 22) + +rule_22 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_value"] == 0, v["arg2_value"] >= 0, True)) if n else + If(v["arg1_value"] == 0, v["arg2_value"] >= 0, True)) +) + +def rule_22_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, (int, np.integer)) and not isinstance(arg1, bool)): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_value == int(arg1)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 22 + rule_22(solver, {'arg1_value': arg1_value, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_22(solver, {'arg1_value': arg1['value'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_23.py b/rules-tf/xla.reduce_precision/rule_23.py new file mode 100644 index 0000000000..e59ee03bc3 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_23.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If mantissa_bits is zero, then exponent_bits can be any non-negative number (Rule 23) + +rule_23 = lambda s, v, n=False: ( + s.add(Not(If(v["arg2_value"] == 0, v["arg1_value"] >= 0, True)) if n else + If(v["arg2_value"] == 0, v["arg1_value"] >= 0, True)) +) + +def rule_23_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, (int, np.integer)) and not isinstance(arg1, bool)): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_value == int(arg1)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 23 + rule_23(solver, {'arg1_value': arg1_value, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_23(solver, {'arg1_value': arg1['value'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_24.py b/rules-tf/xla.reduce_precision/rule_24.py new file mode 100644 index 0000000000..56cd620c2c --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_24.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the input tensor is of type float32, the exponent_bits + mantissa_bits should be less than or equal to 24 (Rule 24) + +rule_24 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 7, v["arg2_value"] + v["arg3_value"] <= 24, True)) if n else + If(v["arg1_dtype"] == 7, v["arg2_value"] + v["arg3_value"] <= 24, True)) +) + +def rule_24_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 24 + rule_24(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_24(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_25.py b/rules-tf/xla.reduce_precision/rule_25.py new file mode 100644 index 0000000000..7a8446fec0 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_25.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the input tensor is of type float64, the exponent_bits + mantissa_bits should be less than or equal to 53 (Rule 25) + +rule_25 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 8, v["arg2_value"] + v["arg3_value"] <= 53, True)) if n else + If(v["arg1_dtype"] == 8, v["arg2_value"] + v["arg3_value"] <= 53, True)) +) + +def rule_25_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 25 + rule_25(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_25(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_26.py b/rules-tf/xla.reduce_precision/rule_26.py new file mode 100644 index 0000000000..e986c9f09a --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_26.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the input tensor is of type other than float, exponent_bits and mantissa_bits must be zero (Rule 26) + +rule_26 = lambda s, v, n=False: ( + s.add(Not(If(And(And(v["arg1_dtype"] != 6, v["arg1_dtype"] != 7), v["arg1_dtype"] != 8), And(v["arg2_value"] == 0, v["arg3_value"] == 0), True)) if n else + If(And(And(v["arg1_dtype"] != 6, v["arg1_dtype"] != 7), v["arg1_dtype"] != 8), And(v["arg2_value"] == 0, v["arg3_value"] == 0), True)) +) + +def rule_26_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 26 + rule_26(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_26(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_27.py b/rules-tf/xla.reduce_precision/rule_27.py new file mode 100644 index 0000000000..cfb0fa78ea --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_27.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# exponent_bits and mantissa_bits should be less than or equal to the number of bits in the dtype (Rule 27) + +rule_27 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, v["arg2_value"] + v["arg3_value"] <= 16, If(v["arg1_dtype"] == 7, v["arg2_value"] + v["arg3_value"] <= 32, If(v["arg1_dtype"] == 8, v["arg2_value"] + v["arg3_value"] <= 64, True)))) if n else + If(v["arg1_dtype"] == 6, v["arg2_value"] + v["arg3_value"] <= 16, If(v["arg1_dtype"] == 7, v["arg2_value"] + v["arg3_value"] <= 32, If(v["arg1_dtype"] == 8, v["arg2_value"] + v["arg3_value"] <= 64, True)))) +) + +def rule_27_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 27 + rule_27(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_27(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_28.py b/rules-tf/xla.reduce_precision/rule_28.py new file mode 100644 index 0000000000..a1d26ea04c --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_28.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# exponent_bits must be less than the bit width of the tensor's dtype (Rule 28) + +rule_28 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, v["arg2_value"] < 16, If(v["arg1_dtype"] == 7, v["arg2_value"] < 32, If(v["arg1_dtype"] == 8, v["arg2_value"] < 64, True)))) if n else + If(v["arg1_dtype"] == 6, v["arg2_value"] < 16, If(v["arg1_dtype"] == 7, v["arg2_value"] < 32, If(v["arg1_dtype"] == 8, v["arg2_value"] < 64, True)))) +) + +def rule_28_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 28 + rule_28(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_28(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_29.py b/rules-tf/xla.reduce_precision/rule_29.py new file mode 100644 index 0000000000..3aa290067d --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_29.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# mantissa_bits must be less than the bit width of the tensor's dtype (Rule 29) + +rule_29 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, v["arg2_value"] < 16, If(v["arg1_dtype"] == 7, v["arg2_value"] < 32, If(v["arg1_dtype"] == 8, v["arg2_value"] < 64, True)))) if n else + If(v["arg1_dtype"] == 6, v["arg2_value"] < 16, If(v["arg1_dtype"] == 7, v["arg2_value"] < 32, If(v["arg1_dtype"] == 8, v["arg2_value"] < 64, True)))) +) + +def rule_29_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 29 + rule_29(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_29(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_3.py b/rules-tf/xla.reduce_precision/rule_3.py new file mode 100644 index 0000000000..51d25d12a2 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_3.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# The sum of exponent_bits and mantissa_bits must be less than 64 (Rule 3) + +rule_3 = lambda s, v, n=False: ( + s.add(Not(v["arg1_value"] + v["arg2_value"] <= 64) if n else + v["arg1_value"] + v["arg2_value"] <= 64) +) + +def rule_3_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, (int, np.integer)) and not isinstance(arg1, bool)): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_value == int(arg1)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 3 + rule_3(solver, {'arg1_value': arg1_value, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_3(solver, {'arg1_value': arg1['value'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_31.py b/rules-tf/xla.reduce_precision/rule_31.py new file mode 100644 index 0000000000..849ec17bd8 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_31.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the input tensor is a quantized type, exponent_bits and mantissa_bits have no effect (Rule 31) + +rule_31 = lambda s, v, n=False: ( + s.add(Not(If(Or(Or(Or(Or(v["arg1_dtype"] == 1, v["arg1_dtype"] == 2), v["arg1_dtype"] == 3), v["arg1_dtype"] == 4), v["arg1_dtype"] == 5), True, True)) if n else + If(Or(Or(Or(Or(v["arg1_dtype"] == 1, v["arg1_dtype"] == 2), v["arg1_dtype"] == 3), v["arg1_dtype"] == 4), v["arg1_dtype"] == 5), True, True)) +) + +def rule_31_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + + # Constraints for rule 31 + rule_31(solver, {'arg1_dtype': arg1_dtype}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_31(solver, {'arg1_dtype': arg1['dtype']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_32.py b/rules-tf/xla.reduce_precision/rule_32.py new file mode 100644 index 0000000000..54fcc10231 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_32.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If exponent_bits + mantissa_bits is greater than zero, the input tensor must be a float type (Rule 32) + +rule_32 = lambda s, v, n=False: ( + s.add(Not(If(v["arg2_value"] + v["arg3_value"] > 0, Or(Or(v["arg1_dtype"] == 6, v["arg1_dtype"] == 7), v["arg1_dtype"] == 8), True)) if n else + If(v["arg2_value"] + v["arg3_value"] > 0, Or(Or(v["arg1_dtype"] == 6, v["arg1_dtype"] == 7), v["arg1_dtype"] == 8), True)) +) + +def rule_32_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 32 + rule_32(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_32(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_33.py b/rules-tf/xla.reduce_precision/rule_33.py new file mode 100644 index 0000000000..c7d8a15fe8 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_33.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# exponent_bits and mantissa_bits cannot be negative (Rule 33) + +rule_33 = lambda s, v, n=False: ( + s.add(Not(And(v["arg1_value"] >= 0, v["arg2_value"] >= 0)) if n else + And(v["arg1_value"] >= 0, v["arg2_value"] >= 0)) +) + +def rule_33_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, (int, np.integer)) and not isinstance(arg1, bool)): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_value == int(arg1)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 33 + rule_33(solver, {'arg1_value': arg1_value, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_33(solver, {'arg1_value': arg1['value'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_34.py b/rules-tf/xla.reduce_precision/rule_34.py new file mode 100644 index 0000000000..832ad44528 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_34.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If exponent_bits is 0, then mantissa bits can be at most the maximum mantissa bits for the dtype (Rule 34) + +rule_34 = lambda s, v, n=False: ( + s.add(Not(If(v["arg2_value"] == 0, (If(v["arg1_dtype"] == 6, v["arg3_value"] <= 11, If(v["arg1_dtype"] == 7, v["arg3_value"] <= 23, If(v["arg1_dtype"] == 8, v["arg3_value"] <= 52, True)))), True)) if n else + If(v["arg2_value"] == 0, (If(v["arg1_dtype"] == 6, v["arg3_value"] <= 11, If(v["arg1_dtype"] == 7, v["arg3_value"] <= 23, If(v["arg1_dtype"] == 8, v["arg3_value"] <= 52, True)))), True)) +) + +def rule_34_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 34 + rule_34(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_34(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_35.py b/rules-tf/xla.reduce_precision/rule_35.py new file mode 100644 index 0000000000..dc01be0a9e --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_35.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If mantissa_bits is 0, then exponent bits can be at most the maximum exponent bits for the dtype (Rule 35) + +rule_35 = lambda s, v, n=False: ( + s.add(Not(If(v["arg3_value"] == 0, (If(v["arg1_dtype"] == 6, v["arg2_value"] <= 5, If(v["arg1_dtype"] == 7, v["arg2_value"] <= 8, If(v["arg1_dtype"] == 8, v["arg2_value"] <= 11, True)))), True)) if n else + If(v["arg3_value"] == 0, (If(v["arg1_dtype"] == 6, v["arg2_value"] <= 5, If(v["arg1_dtype"] == 7, v["arg2_value"] <= 8, If(v["arg1_dtype"] == 8, v["arg2_value"] <= 11, True)))), True)) +) + +def rule_35_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 35 + rule_35(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_35(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_36.py b/rules-tf/xla.reduce_precision/rule_36.py new file mode 100644 index 0000000000..24c8aa1408 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_36.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# exponent_bits and mantissa_bits should be less than the total number of bits representing the float value (Rule 36) + +rule_36 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, v["arg2_value"] + v["arg3_value"] <= 15, If(v["arg1_dtype"] == 7, v["arg2_value"] + v["arg3_value"] <= 31, If(v["arg1_dtype"] == 8, v["arg2_value"] + v["arg3_value"] <= 63, True)))) if n else + If(v["arg1_dtype"] == 6, v["arg2_value"] + v["arg3_value"] <= 15, If(v["arg1_dtype"] == 7, v["arg2_value"] + v["arg3_value"] <= 31, If(v["arg1_dtype"] == 8, v["arg2_value"] + v["arg3_value"] <= 63, True)))) +) + +def rule_36_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 36 + rule_36(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_36(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_38.py b/rules-tf/xla.reduce_precision/rule_38.py new file mode 100644 index 0000000000..50542c2245 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_38.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If exponent_bits is specified, mantissa_bits must also be specified, and vice-versa for float tensors (Rule 38) + +rule_38 = lambda s, v, n=False: ( + s.add(Not(If(Or(Or(v["arg1_dtype"] == 6, v["arg1_dtype"] == 7), v["arg1_dtype"] == 8), Or((And(v["arg2_value"] == 0, v["arg3_value"] == 0)), (And(v["arg2_value"] != 0, v["arg3_value"] != 0))), True)) if n else + If(Or(Or(v["arg1_dtype"] == 6, v["arg1_dtype"] == 7), v["arg1_dtype"] == 8), Or((And(v["arg2_value"] == 0, v["arg3_value"] == 0)), (And(v["arg2_value"] != 0, v["arg3_value"] != 0))), True)) +) + +def rule_38_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 38 + rule_38(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_38(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_39.py b/rules-tf/xla.reduce_precision/rule_39.py new file mode 100644 index 0000000000..75727c975c --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_39.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If reducing precision, exponent bits should be smaller than original type's exponent bits and same for mantissa (Rule 39) + +rule_39 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, (And(v["arg2_value"] < 5, v["arg3_value"] < 11)), If(v["arg1_dtype"] == 7, (And(v["arg2_value"] < 8, v["arg3_value"] < 23)), If(v["arg1_dtype"] == 8, (And(v["arg2_value"] < 11, v["arg3_value"] < 52)), True)))) if n else + If(v["arg1_dtype"] == 6, (And(v["arg2_value"] < 5, v["arg3_value"] < 11)), If(v["arg1_dtype"] == 7, (And(v["arg2_value"] < 8, v["arg3_value"] < 23)), If(v["arg1_dtype"] == 8, (And(v["arg2_value"] < 11, v["arg3_value"] < 52)), True)))) +) + +def rule_39_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 39 + rule_39(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_39(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_4.py b/rules-tf/xla.reduce_precision/rule_4.py new file mode 100644 index 0000000000..ebfac26d6c --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_4.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# operand must have a floating-point dtype: 6–8 (Rule 4) + +rule_4 = lambda s, v, n=False: ( + s.add(Not(And(6 <= v["arg1_dtype"], v["arg1_dtype"] <= 8)) if n else + And(6 <= v["arg1_dtype"], v["arg1_dtype"] <= 8)) +) + +def rule_4_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + + # Constraints for rule 4 + rule_4(solver, {'arg1_dtype': arg1_dtype}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_4(solver, {'arg1_dtype': arg1['dtype']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_40.py b/rules-tf/xla.reduce_precision/rule_40.py new file mode 100644 index 0000000000..9d618632d6 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_40.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# It is valid to set only exponent bits and rely on implicit truncation for float types (Rule 40) + +rule_40 = lambda s, v, n=False: ( + s.add(Not(If(Or(Or(v["arg1_dtype"] == 6, v["arg1_dtype"] == 7), v["arg1_dtype"] == 8), Or(Or((And(v["arg2_value"] > 0, v["arg3_value"] == 0)), (And(v["arg2_value"] == 0, v["arg3_value"] > 0))), (And(v["arg2_value"] > 0, v["arg3_value"] > 0))), True)) if n else + If(Or(Or(v["arg1_dtype"] == 6, v["arg1_dtype"] == 7), v["arg1_dtype"] == 8), Or(Or((And(v["arg2_value"] > 0, v["arg3_value"] == 0)), (And(v["arg2_value"] == 0, v["arg3_value"] > 0))), (And(v["arg2_value"] > 0, v["arg3_value"] > 0))), True)) +) + +def rule_40_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 40 + rule_40(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_40(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_41.py b/rules-tf/xla.reduce_precision/rule_41.py new file mode 100644 index 0000000000..1581238263 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_41.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# exponent_bits and mantissa_bits should both be zero for non-float tensors (Rule 41) + +rule_41 = lambda s, v, n=False: ( + s.add(Not(If(And(And(v["arg1_dtype"] != 6, v["arg1_dtype"] != 7), v["arg1_dtype"] != 8), And(v["arg2_value"] == 0, v["arg3_value"] == 0), True)) if n else + If(And(And(v["arg1_dtype"] != 6, v["arg1_dtype"] != 7), v["arg1_dtype"] != 8), And(v["arg2_value"] == 0, v["arg3_value"] == 0), True)) +) + +def rule_41_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 41 + rule_41(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_41(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_42.py b/rules-tf/xla.reduce_precision/rule_42.py new file mode 100644 index 0000000000..e5c326d918 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_42.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# Reducing to bfloat16 - exponent bits and mantissa bits should be correctly set (Rule 42) + +rule_42 = lambda s, v, n=False: ( + s.add(Not(If(Or(v["arg1_dtype"] == 7, v["arg1_dtype"] == 8), (And(v["arg2_value"] == 8, v["arg3_value"] == 7)), True)) if n else + If(Or(v["arg1_dtype"] == 7, v["arg1_dtype"] == 8), (And(v["arg2_value"] == 8, v["arg3_value"] == 7)), True)) +) + +def rule_42_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 42 + rule_42(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_42(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_43.py b/rules-tf/xla.reduce_precision/rule_43.py new file mode 100644 index 0000000000..0e3ba6766b --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_43.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# Reducing to fp16 - exponent bits and mantissa bits should be correctly set (Rule 43) + +rule_43 = lambda s, v, n=False: ( + s.add(Not(If(Or(v["arg1_dtype"] == 7, v["arg1_dtype"] == 8), (And(v["arg2_value"] == 5, v["arg3_value"] == 10)), True)) if n else + If(Or(v["arg1_dtype"] == 7, v["arg1_dtype"] == 8), (And(v["arg2_value"] == 5, v["arg3_value"] == 10)), True)) +) + +def rule_43_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 43 + rule_43(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_43(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_44.py b/rules-tf/xla.reduce_precision/rule_44.py new file mode 100644 index 0000000000..20620fb9d5 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_44.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If reducing precision, the number of mantissa bits cannot be increased (Rule 44) + +rule_44 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, v["arg2_value"] <= 10, If(v["arg1_dtype"] == 7, v["arg2_value"] <= 23, If(v["arg1_dtype"] == 8, v["arg2_value"] <= 52, True)))) if n else + If(v["arg1_dtype"] == 6, v["arg2_value"] <= 10, If(v["arg1_dtype"] == 7, v["arg2_value"] <= 23, If(v["arg1_dtype"] == 8, v["arg2_value"] <= 52, True)))) +) + +def rule_44_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 44 + rule_44(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_44(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_45.py b/rules-tf/xla.reduce_precision/rule_45.py new file mode 100644 index 0000000000..2d5efb8644 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_45.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If reducing precision, the number of exponent bits cannot be increased (Rule 45) + +rule_45 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, v["arg2_value"] <= 5, If(v["arg1_dtype"] == 7, v["arg2_value"] <= 8, If(v["arg1_dtype"] == 8, v["arg2_value"] <= 11, True)))) if n else + If(v["arg1_dtype"] == 6, v["arg2_value"] <= 5, If(v["arg1_dtype"] == 7, v["arg2_value"] <= 8, If(v["arg1_dtype"] == 8, v["arg2_value"] <= 11, True)))) +) + +def rule_45_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 45 + rule_45(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_45(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_46.py b/rules-tf/xla.reduce_precision/rule_46.py new file mode 100644 index 0000000000..283c984475 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_46.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If reducing precision to a lower bit-width, it should be possible to represent the original value in the reduced precision (Rule 46) + +rule_46 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 7, Or((And(v["arg2_value"] <= 8, v["arg3_value"] <= 7)), (And(v["arg2_value"] <= 5, v["arg3_value"] <= 10))), If(v["arg1_dtype"] == 8, Or((And(v["arg2_value"] <= 8, v["arg3_value"] <= 7)), (And(v["arg2_value"] <= 5, v["arg3_value"] <= 10))), True))) if n else + If(v["arg1_dtype"] == 7, Or((And(v["arg2_value"] <= 8, v["arg3_value"] <= 7)), (And(v["arg2_value"] <= 5, v["arg3_value"] <= 10))), If(v["arg1_dtype"] == 8, Or((And(v["arg2_value"] <= 8, v["arg3_value"] <= 7)), (And(v["arg2_value"] <= 5, v["arg3_value"] <= 10))), True))) +) + +def rule_46_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 46 + rule_46(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_46(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_47.py b/rules-tf/xla.reduce_precision/rule_47.py new file mode 100644 index 0000000000..86fa5bf3ad --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_47.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# When reducing to bfloat16, the original tensor must be fp32 or fp64 (Rule 47) + +rule_47 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg2_value"] == 8, v["arg3_value"] == 7), Or(v["arg1_dtype"] == 7, v["arg1_dtype"] == 8), True)) if n else + If(And(v["arg2_value"] == 8, v["arg3_value"] == 7), Or(v["arg1_dtype"] == 7, v["arg1_dtype"] == 8), True)) +) + +def rule_47_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 47 + rule_47(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_47(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_48.py b/rules-tf/xla.reduce_precision/rule_48.py new file mode 100644 index 0000000000..a461b73915 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_48.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# When reducing precision to fp16, the original tensor must be fp32 or fp64 (Rule 48) + +rule_48 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg2_value"] == 5, v["arg3_value"] == 10), Or(v["arg1_dtype"] == 7, v["arg1_dtype"] == 8), True)) if n else + If(And(v["arg2_value"] == 5, v["arg3_value"] == 10), Or(v["arg1_dtype"] == 7, v["arg1_dtype"] == 8), True)) +) + +def rule_48_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 48 + rule_48(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_48(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_49.py b/rules-tf/xla.reduce_precision/rule_49.py new file mode 100644 index 0000000000..1574a93d4c --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_49.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# Mantissa bits + exponent bits <= dtype size -1, for float types (Rule 49) + +rule_49 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, v["arg2_value"] + v["arg3_value"] <= 15, If(v["arg1_dtype"] == 7, v["arg2_value"] + v["arg3_value"] <= 31, If(v["arg1_dtype"] == 8, v["arg2_value"] + v["arg3_value"] <= 63, True)))) if n else + If(v["arg1_dtype"] == 6, v["arg2_value"] + v["arg3_value"] <= 15, If(v["arg1_dtype"] == 7, v["arg2_value"] + v["arg3_value"] <= 31, If(v["arg1_dtype"] == 8, v["arg2_value"] + v["arg3_value"] <= 63, True)))) +) + +def rule_49_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 49 + rule_49(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_49(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_5.py b/rules-tf/xla.reduce_precision/rule_5.py new file mode 100644 index 0000000000..7ff42ac52f --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_5.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# if exponent_bits and mantissa_bits are zero, it acts as identity, but only for floating tensors (Rule 5) + +rule_5 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg2_value"] == 0, v["arg3_value"] == 0), And(6 <= v["arg1_dtype"], v["arg1_dtype"] <= 8), True)) if n else + If(And(v["arg2_value"] == 0, v["arg3_value"] == 0), And(6 <= v["arg1_dtype"], v["arg1_dtype"] <= 8), True)) +) + +def rule_5_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 5 + rule_5(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_5(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_50.py b/rules-tf/xla.reduce_precision/rule_50.py new file mode 100644 index 0000000000..0732b81d18 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_50.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If reducing precision, the exponent_bits and mantissa_bits combined can't be zero for fp32 and fp64 (Rule 50) + +rule_50 = lambda s, v, n=False: ( + s.add(Not(If(Or(v["arg1_dtype"] == 7, v["arg1_dtype"] == 8), v["arg2_value"] + v["arg3_value"] > 0, True)) if n else + If(Or(v["arg1_dtype"] == 7, v["arg1_dtype"] == 8), v["arg2_value"] + v["arg3_value"] > 0, True)) +) + +def rule_50_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 50 + rule_50(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_50(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_52.py b/rules-tf/xla.reduce_precision/rule_52.py new file mode 100644 index 0000000000..17df94dddd --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_52.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# Reducing precision is not defined on string type (Rule 52) + +rule_52 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 11, False, True)) if n else + If(v["arg1_dtype"] == 11, False, True)) +) + +def rule_52_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + + # Constraints for rule 52 + rule_52(solver, {'arg1_dtype': arg1_dtype}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_52(solver, {'arg1_dtype': arg1['dtype']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_53.py b/rules-tf/xla.reduce_precision/rule_53.py new file mode 100644 index 0000000000..1f8234787c --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_53.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# Reducing precision is not defined on dtype type (Rule 53) + +rule_53 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 12, False, True)) if n else + If(v["arg1_dtype"] == 12, False, True)) +) + +def rule_53_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + + # Constraints for rule 53 + rule_53(solver, {'arg1_dtype': arg1_dtype}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_53(solver, {'arg1_dtype': arg1['dtype']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_54.py b/rules-tf/xla.reduce_precision/rule_54.py new file mode 100644 index 0000000000..00257c8b38 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_54.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# For float16 tensors, exponent and mantissa bits have to be specified (Rule 54) + +rule_54 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, And(v["arg2_value"] > 0, v["arg3_value"] > 0), True)) if n else + If(v["arg1_dtype"] == 6, And(v["arg2_value"] > 0, v["arg3_value"] > 0), True)) +) + +def rule_54_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 54 + rule_54(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_54(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_55.py b/rules-tf/xla.reduce_precision/rule_55.py new file mode 100644 index 0000000000..c30ced9100 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_55.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the input tensor is a float16, it will be promoted to float32 before reducing, exponent and mantissa bit constraints of float32 apply to that operation (Rule 55) + +rule_55 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, v["arg2_value"] + v["arg3_value"] <= 31, True)) if n else + If(v["arg1_dtype"] == 6, v["arg2_value"] + v["arg3_value"] <= 31, True)) +) + +def rule_55_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 55 + rule_55(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_55(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_56.py b/rules-tf/xla.reduce_precision/rule_56.py new file mode 100644 index 0000000000..b06d7aa4c0 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_56.py @@ -0,0 +1,46 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# It is invalid to specify only mantissa_bits and not exponent_bits in floating-point types (Rule 56) + +rule_56 = lambda s, v, n=False: ( + s.add(Not(If(Or(Or(v["arg1_dtype"] == 6, v["arg1_dtype"] == 7), v["arg1_dtype"] == 8), (Or(v["arg2_value"] != 0, v["arg3_value"] == 0)), True)) if n else + If(Or(Or(v["arg1_dtype"] == 6, v["arg1_dtype"] == 7), v["arg1_dtype"] == 8), (Or(v["arg2_value"] != 0, v["arg3_value"] == 0)), True)) +) + +def rule_56_func(arg1, arg2, arg3, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + arg3 = next(iter(arg3.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + if not (isinstance(arg3, (int, np.integer)) and not isinstance(arg3, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + arg3_value = Int('arg3_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + solver.add(arg3_value == int(arg3)) + + # Constraints for rule 56 + rule_56(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value, 'arg3_value': arg3_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_56(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value'], 'arg3_value': arg3['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_57.py b/rules-tf/xla.reduce_precision/rule_57.py new file mode 100644 index 0000000000..16a06387c3 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_57.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the input tensor is a float16, it will be promoted to float32 before reducing, if exponent bits are reduced, it should be smaller or equal to 8. (Rule 57) + +rule_57 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, v["arg2_value"] <= 8, True)) if n else + If(v["arg1_dtype"] == 6, v["arg2_value"] <= 8, True)) +) + +def rule_57_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 57 + rule_57(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_57(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_6.py b/rules-tf/xla.reduce_precision/rule_6.py new file mode 100644 index 0000000000..8b459d2f39 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_6.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# mantissa_bits must be less than the bit-width of the tensor's dtype (Rule 6) + +rule_6 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 6, v["arg2_value"] <= 10, If(v["arg1_dtype"] == 7, v["arg2_value"] <= 23, If(v["arg1_dtype"] == 8, v["arg2_value"] <= 52, True)))) if n else + If(v["arg1_dtype"] == 6, v["arg2_value"] <= 10, If(v["arg1_dtype"] == 7, v["arg2_value"] <= 23, If(v["arg1_dtype"] == 8, v["arg2_value"] <= 52, True)))) +) + +def rule_6_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 6 + rule_6(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_6(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_7.py b/rules-tf/xla.reduce_precision/rule_7.py new file mode 100644 index 0000000000..10fc6579b7 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_7.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If mantissa_bits is greater than 0, exponent_bits should also be greater than 0. (Rule 7) + +rule_7 = lambda s, v, n=False: ( + s.add(Not(If(v["arg2_value"] > 0, v["arg1_value"] > 0, True)) if n else + If(v["arg2_value"] > 0, v["arg1_value"] > 0, True)) +) + +def rule_7_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, (int, np.integer)) and not isinstance(arg1, bool)): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_value == int(arg1)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 7 + rule_7(solver, {'arg1_value': arg1_value, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_7(solver, {'arg1_value': arg1['value'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rule_8.py b/rules-tf/xla.reduce_precision/rule_8.py new file mode 100644 index 0000000000..d6d3f67fa7 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rule_8.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If exponent_bits is greater than 0, mantissa_bits should also be greater than 0. (Rule 8) + +rule_8 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_value"] > 0, v["arg2_value"] > 0, True)) if n else + If(v["arg1_value"] > 0, v["arg2_value"] > 0, True)) +) + +def rule_8_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, (int, np.integer)) and not isinstance(arg1, bool)): + return False + if not (isinstance(arg2, (int, np.integer)) and not isinstance(arg2, bool)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_value == int(arg1)) + solver.add(arg2_value == int(arg2)) + + # Constraints for rule 8 + rule_8(solver, {'arg1_value': arg1_value, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_8(solver, {'arg1_value': arg1['value'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.reduce_precision/rules-ebnf b/rules-tf/xla.reduce_precision/rules-ebnf new file mode 100644 index 0000000000..8ab642cfb3 --- /dev/null +++ b/rules-tf/xla.reduce_precision/rules-ebnf @@ -0,0 +1,150 @@ +>> +Rule 1 (exponent_bits must be non-negative) +{v_2 : int} |= v_2 ≥ 0 +>> +Rule 2 (mantissa_bits must be non-negative) +{v_3 : int} |= v_3 ≥ 0 +>> +Rule 3 (The sum of exponent_bits and mantissa_bits must be less than 64) +{v_2 : int, v_3 : int} |= v_2 + v_3 ≤ 64 +>> +Rule 4 (operand must have a floating-point dtype: 6–8) +{v_1: tensor} |= 6 ≤ dtype_(v_1) ∧ dtype_(v_1) ≤ 8 +>> +Rule 5 (if exponent_bits and mantissa_bits are zero, it acts as identity, but only for floating tensors) +{v_1: tensor, v_2 : int, v_3 : int} |= if v_2 = 0 ∧ v_3 = 0 then 6 ≤ dtype_(v_1) ∧ dtype_(v_1) ≤ 8 +>> +Rule 6 (mantissa_bits must be less than the bit-width of the tensor's dtype) +{v_1: tensor, v_3 : int} |= if dtype_(v_1) = 6 then v_3 ≤ 10 else if dtype_(v_1) = 7 then v_3 ≤ 23 else if dtype_(v_1) = 8 then v_3 ≤ 52 +>> +Rule 7 (If mantissa_bits is greater than 0, exponent_bits should also be greater than 0.) +{v_2 : int, v_3 : int} |= if v_3 > 0 then v_2 > 0 +>> +Rule 8 (If exponent_bits is greater than 0, mantissa_bits should also be greater than 0.) +{v_2 : int, v_3 : int} |= if v_2 > 0 then v_3 > 0 +>> +Rule 11 (exponent_bits or mantissa bits can be zero) +{v_2 : int, v_3 : int} |= v_2 = 0 ∨ v_3 = 0 +>> +Rule 12 (exponent_bits and mantissa_bits cannot be both zero if the input is a float16) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 6 then v_2 > 0 ∨ v_3 > 0 +>> +Rule 13 (exponent_bits cannot be greater than maximum allowed bits) +{v_2 : int} |= v_2 ≤ 63 +>> +Rule 14 (mantissa_bits cannot be greater than maximum allowed bits) +{v_3 : int} |= v_3 ≤ 63 +>> +Rule 15 (If operand is bool, then exponent_bits and mantissa_bits should be 0) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 0 then v_2 = 0 ∧ v_3 = 0 +>> +Rule 16 (If operand is complex, exponent_bits and mantissa_bits must be zero) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 9 ∨ dtype_(v_1) = 10 then v_2 = 0 ∧ v_3 = 0 +>> +Rule 17 (exponent_bits and mantissa_bits sum must be less than or equal to the total bits available in the float type) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 6 then v_2 + v_3 ≤ 11 else if dtype_(v_1) = 7 then v_2 + v_3 ≤ 24 else if dtype_(v_1) = 8 then v_2 + v_3 ≤ 53 +>> +Rule 18 (If operand is integer, then exponent_bits and mantissa_bits must be 0) +{v_1 : tensor, v_2 : int, v_3 : int} |= if 1 ≤ dtype_(v_1) ∧ dtype_(v_1) ≤ 5 then v_2 = 0 ∧ v_3 = 0 +>> +Rule 20 (If the input tensor is of type float16, the exponent_bits + mantissa_bits should be less than or equal to 11) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 6 then v_2 + v_3 ≤ 11 +>> +Rule 22 (If exponent_bits is zero, then mantissa_bits can be any non-negative number) +{v_2 : int, v_3 : int} |= if v_2 = 0 then v_3 ≥ 0 +>> +Rule 23 (If mantissa_bits is zero, then exponent_bits can be any non-negative number) +{v_2 : int, v_3 : int} |= if v_3 = 0 then v_2 ≥ 0 +>> +Rule 24 (If the input tensor is of type float32, the exponent_bits + mantissa_bits should be less than or equal to 24) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 7 then v_2 + v_3 ≤ 24 +>> +Rule 25 (If the input tensor is of type float64, the exponent_bits + mantissa_bits should be less than or equal to 53) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 8 then v_2 + v_3 ≤ 53 +>> +Rule 26 (If the input tensor is of type other than float, exponent_bits and mantissa_bits must be zero) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) ≠ 6 ∧ dtype_(v_1) ≠ 7 ∧ dtype_(v_1) ≠ 8 then v_2 = 0 ∧ v_3 = 0 +>> +Rule 27 (exponent_bits and mantissa_bits should be less than or equal to the number of bits in the dtype) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 then v_2 + v_3 <= 16 else if dtype_(v_1) = 7 then v_2 + v_3 <= 32 else if dtype_(v_1) = 8 then v_2 + v_3 <= 64 +>> +Rule 28 (exponent_bits must be less than the bit width of the tensor's dtype) +{v_1: tensor, v_2 : int} |= if dtype_(v_1) = 6 then v_2 < 16 else if dtype_(v_1) = 7 then v_2 < 32 else if dtype_(v_1) = 8 then v_2 < 64 +>> +Rule 29 (mantissa_bits must be less than the bit width of the tensor's dtype) +{v_1: tensor, v_3 : int} |= if dtype_(v_1) = 6 then v_3 < 16 else if dtype_(v_1) = 7 then v_3 < 32 else if dtype_(v_1) = 8 then v_3 < 64 +>> +Rule 31 (If the input tensor is a quantized type, exponent_bits and mantissa_bits have no effect) +{v_1 : tensor} |= if dtype_(v_1) = 1 ∨ dtype_(v_1) = 2 ∨ dtype_(v_1) = 3 ∨ dtype_(v_1) = 4 ∨ dtype_(v_1) = 5 then true +>> +Rule 32 (If exponent_bits + mantissa_bits is greater than zero, the input tensor must be a float type) +{v_1 : tensor, v_2 : int, v_3 : int} |= if v_2 + v_3 > 0 then dtype_(v_1) = 6 ∨ dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 +>> +Rule 33 (exponent_bits and mantissa_bits cannot be negative) +{v_2 : int, v_3 : int} |= v_2 ≥ 0 ∧ v_3 ≥ 0 +>> +Rule 34 (If exponent_bits is 0, then mantissa bits can be at most the maximum mantissa bits for the dtype) +{v_1: tensor, v_2 : int, v_3 : int} |= if v_2 = 0 then (if dtype_(v_1) = 6 then v_3 <= 11 else if dtype_(v_1) = 7 then v_3 <= 23 else if dtype_(v_1) = 8 then v_3 <= 52) +>> +Rule 35 (If mantissa_bits is 0, then exponent bits can be at most the maximum exponent bits for the dtype) +{v_1: tensor, v_2 : int, v_3 : int} |= if v_3 = 0 then (if dtype_(v_1) = 6 then v_2 <= 5 else if dtype_(v_1) = 7 then v_2 <= 8 else if dtype_(v_1) = 8 then v_2 <= 11) +>> +Rule 36 (exponent_bits and mantissa_bits should be less than the total number of bits representing the float value) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 then v_2 + v_3 <= 15 else if dtype_(v_1) = 7 then v_2 + v_3 <= 31 else if dtype_(v_1) = 8 then v_2 + v_3 <= 63 +>> +Rule 38 (If exponent_bits is specified, mantissa_bits must also be specified, and vice-versa for float tensors) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 ∨ dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 = 0 ∧ v_3 = 0) ∨ (v_2 ≠ 0 ∧ v_3 ≠ 0) +>> +Rule 39 (If reducing precision, exponent bits should be smaller than original type's exponent bits and same for mantissa) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 then (v_2 < 5 ∧ v_3 < 11) else if dtype_(v_1) = 7 then (v_2 < 8 ∧ v_3 < 23) else if dtype_(v_1) = 8 then (v_2 < 11 ∧ v_3 < 52) +>> +Rule 40 (It is valid to set only exponent bits and rely on implicit truncation for float types) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 ∨ dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 > 0 ∧ v_3 = 0) ∨ (v_2=0 ∧ v_3 > 0) ∨ (v_2>0 ∧ v_3 >0) +>> +Rule 41 (exponent_bits and mantissa_bits should both be zero for non-float tensors) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) ≠ 6 ∧ dtype_(v_1) ≠ 7 ∧ dtype_(v_1) ≠ 8 then v_2 = 0 ∧ v_3 = 0 +>> +Rule 42 (Reducing to bfloat16 - exponent bits and mantissa bits should be correctly set) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 = 8 ∧ v_3 = 7) +>> +Rule 43 (Reducing to fp16 - exponent bits and mantissa bits should be correctly set) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 = 5 ∧ v_3 = 10) +>> +Rule 44 (If reducing precision, the number of mantissa bits cannot be increased) +{v_1: tensor, v_3: int} |= if dtype_(v_1) = 6 then v_3 <= 10 else if dtype_(v_1) = 7 then v_3 <= 23 else if dtype_(v_1) = 8 then v_3 <= 52 +>> +Rule 45 (If reducing precision, the number of exponent bits cannot be increased) +{v_1: tensor, v_2: int} |= if dtype_(v_1) = 6 then v_2 <= 5 else if dtype_(v_1) = 7 then v_2 <= 8 else if dtype_(v_1) = 8 then v_2 <= 11 +>> +Rule 46 (If reducing precision to a lower bit-width, it should be possible to represent the original value in the reduced precision) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 7 then (v_2 <= 8 ∧ v_3 <= 7) ∨ (v_2 <= 5 ∧ v_3 <= 10) else if dtype_(v_1) = 8 then (v_2 <= 8 ∧ v_3 <= 7) ∨ (v_2 <= 5 ∧ v_3 <= 10) +>> +Rule 47 (When reducing to bfloat16, the original tensor must be fp32 or fp64) +{v_1: tensor, v_2: int, v_3: int} |= if v_2 = 8 ∧ v_3 = 7 then dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 +>> +Rule 48 (When reducing precision to fp16, the original tensor must be fp32 or fp64) +{v_1: tensor, v_2: int, v_3: int} |= if v_2 = 5 ∧ v_3 = 10 then dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 +>> +Rule 49 (Mantissa bits + exponent bits <= dtype size -1, for float types) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 6 then v_2 + v_3 <= 15 else if dtype_(v_1) = 7 then v_2 + v_3 <= 31 else if dtype_(v_1) = 8 then v_2 + v_3 <= 63 +>> +Rule 50 (If reducing precision, the exponent_bits and mantissa_bits combined can't be zero for fp32 and fp64) +{v_1 : tensor, v_2 : int, v_3 : int} |= if dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then v_2 + v_3 > 0 +>> +Rule 52 (Reducing precision is not defined on string type) +{v_1: tensor} |= if dtype_(v_1) = 11 then false +>> +Rule 53 (Reducing precision is not defined on dtype type) +{v_1: tensor} |= if dtype_(v_1) = 12 then false +>> +Rule 54 (For float16 tensors, exponent and mantissa bits have to be specified) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 then v_2 > 0 ∧ v_3 > 0 +>> +Rule 55 (If the input tensor is a float16, it will be promoted to float32 before reducing, exponent and mantissa bit constraints of float32 apply to that operation) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 then v_2 + v_3 <= 31 +>> +Rule 56 (It is invalid to specify only mantissa_bits and not exponent_bits in floating-point types) +{v_1: tensor, v_2: int, v_3: int} |= if dtype_(v_1) = 6 ∨ dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 then (v_2 ≠ 0 ∨ v_3 = 0) +>> +Rule 57 (If the input tensor is a float16, it will be promoted to float32 before reducing, if exponent bits are reduced, it should be smaller or equal to 8.) +{v_1: tensor, v_2: int} |= if dtype_(v_1) = 6 then v_2 <= 8 diff --git a/rules-tf/xla.rng_bit_generator/log-rulegen b/rules-tf/xla.rng_bit_generator/log-rulegen new file mode 100644 index 0000000000..bafadb47a3 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/log-rulegen @@ -0,0 +1,5314 @@ +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 1 (algorithm should be a valid string value) +{v_1 : str} |= v_1 = "threefry" ∨ v_1 = "philox" ∨ v_1 = "rbg" +Token usage: input=1458, output=520, total=1978 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 2 (shape list should have positive sizes) +{v_1 : list(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 +Token usage: input=1458, output=520, total=1978 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 3 (dtype should be a valid data type) +{v_1 : dtype} |= v_1 = 0 ∨ v_1 = 1 ∨ v_1 = 2 ∨ v_1 = 3 ∨ v_1 = 4 ∨ v_1 = 5 ∨ v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 ∨ v_1 = 9 ∨ v_1 = 10 ∨ v_1 = 12 +Token usage: input=1458, output=520, total=1978 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 4 (initial_state should be a tensor of integers) +{v_1 : tensor, v_2 : dtype} |= dtype_(v_1) = 1 ∨ dtype_(v_1) = 2 ∨ dtype_(v_1) = 3 ∨ dtype_(v_1) = 4 ∨ dtype_(v_1) = 5 +Token usage: input=1458, output=520, total=1978 +** REDUNDANT VARIABLES ** (num_failures: 1) + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 5 (initial_state must have a specific shape.) +{v_1 : tensor} |= ndim(v_1) = 1 ∧ shape(v_1, 0) = 2 +Token usage: input=1458, output=520, total=1978 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 6 (shape of output tensor should be within a maximum size) +{v_1 : list(int)} |= v_1.len < 10 +Token usage: input=1458, output=520, total=1978 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 7 (if shape is empty, the output is scalar.) +{v_1 : list(int), v_2 : dtype} |= if v_1.len = 0 then (v_2 = 0 ∨ v_2 = 6 ∨ v_2 = 7 ∨ v_2 = 8) +Token usage: input=1458, output=520, total=1978 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 8 (if initial state is provided, the shape is derived from it) +{v_1 : tensor, v_2 : list(int)} |= shape(v_1,0) ≥ 0 ∧ shape(v_1,0) = v_2.len +Token usage: input=1458, output=520, total=1978 +** SUCCESS ** + +>>> PROMPT +[Feedback Message from Prior Run] +Redundant variables: {v_1 : tensor, v_2 : dtype} |= dtype_(v_1) = 1 ∨ dtype_(v_1) = 2 ∨ dtype_(v_1) = 3 ∨ dtype_(v_1) = 4 ∨ dtype_(v_1) = 5 (Unused: v_2) + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 9 (initial_state should be a tensor of integers) +{v_1 : tensor} |= dtype_(v_1) = 1 ∨ dtype_(v_1) = 2 ∨ dtype_(v_1) = 3 ∨ dtype_(v_1) = 4 ∨ dtype_(v_1) = 5 +Token usage: input=3514, output=132, total=3646 +** SUCCESS ** + +>>> PROMPT +[Feedback Message from Prior Run] +Redundant variables: {v_1 : tensor, v_2 : dtype} |= dtype_(v_1) = 1 ∨ dtype_(v_1) = 2 ∨ dtype_(v_1) = 3 ∨ dtype_(v_1) = 4 ∨ dtype_(v_1) = 5 (Unused: v_2) + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 10 (algorithm name cannot be an empty string) +{v_1 : str} |= v_1 ≠ "" +Token usage: input=3514, output=132, total=3646 +** SUCCESS ** + +>>> PROMPT +[Feedback Message from Prior Run] +Redundant variables: {v_1 : tensor, v_2 : dtype} |= dtype_(v_1) = 1 ∨ dtype_(v_1) = 2 ∨ dtype_(v_1) = 3 ∨ dtype_(v_1) = 4 ∨ dtype_(v_1) = 5 (Unused: v_2) + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 11 (Dtype must not be boolean) +{v_1 : dtype} |= v_1 ≠ 0 +Token usage: input=3514, output=132, total=3646 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 12 (algorithm string should be one of the allowed values.) +{v_1 : str} |= v_1 = "threefry" ∨ v_1 = "philox" ∨ v_1 = "rbg" +Token usage: input=5022, output=191, total=5213 +** DUPLICATED RULE ** (num_failures: 2) + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 13 (initial state cannot be an empty string.) +{v_1 : str} |= v_1 ≠ "" +Token usage: input=5022, output=191, total=5213 +** DUPLICATED RULE ** (num_failures: 3) + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 14 (the elements of shape list must be non-negative integers) +{v_1 : list(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 +Token usage: input=5022, output=191, total=5213 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 15 (if the shape list is not empty, the dtype cannot be string) +{v_1 : list(int), v_2 : dtype} |= if v_1.len > 0 then v_2 ≠ 11 +Token usage: input=5022, output=191, total=5213 +** SUCCESS ** + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_1 : str} |= v_1 = "threefry" ∨ v_1 = "philox" ∨ v_1 = "rbg" +Duplicated rule: {v_1 : str} |= v_1 ≠ "" + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 16 (initial state should be a string with length not exceeding 256) +{v_1 : str} |= v_1.len < 256 +Token usage: input=6843, output=164, total=7007 +** SUCCESS ** + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_1 : str} |= v_1 = "threefry" ∨ v_1 = "philox" ∨ v_1 = "rbg" +Duplicated rule: {v_1 : str} |= v_1 ≠ "" + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 17 (the product of the shape list elements should not exceed maximum value of int32) +{v_1 : list(int)} |= ∃i ∈ [0, v_1.len - 1] : v_1[i] ≤ 2147483647 +Token usage: input=6843, output=164, total=7007 +** SUCCESS ** + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_1 : str} |= v_1 = "threefry" ∨ v_1 = "philox" ∨ v_1 = "rbg" +Duplicated rule: {v_1 : str} |= v_1 ≠ "" + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 18 (If the algorithm is "rbg", initial state must not be an empty string) +{v_1 : str, v_2 : str} |= if v_1 = "rbg" then v_2 ≠ "" +Token usage: input=6843, output=164, total=7007 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 19 (If the algorithm is "rbg", the initial state must be a valid hex string) +{v_1 : str, v_2 : str} |= if v_1 = "rbg" then ∀i ∈ [0, v_2.len - 1] : v_2[i] = "0" ∨ v_2[i] = "1" ∨ v_2[i] = "2" ∨ v_2[i] = "3" ∨ v_2[i] = "4" ∨ v_2[i] = "5" ∨ v_2[i] = "6" ∨ v_2[i] = "7" ∨ v_2[i] = "8" ∨ v_2[i] = "9" ∨ v_2[i] = "a" ∨ v_2[i] = "b" ∨ v_2[i] = "c" ∨ v_2[i] = "d" ∨ v_2[i] = "e" ∨ v_2[i] = "f" +Token usage: input=8400, output=351, total=8751 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 20 (If the algorithm is not "rbg", the initial state must be "default") +{v_1 : str, v_2 : str} |= if v_1 ≠ "rbg" then v_2 = "default" +Token usage: input=8400, output=351, total=8751 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 21 (The length of the shape list should not exceed 8) +{v_1 : list(int)} |= v_1.len < 9 +Token usage: input=8400, output=351, total=8751 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 22 (The shape list cannot contain zero) +{v_1 : list(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≠ 0 +Token usage: input=10253, output=146, total=10399 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 23 (The dtype must be a valid type from allowed integer range) +{v_1 : dtype} |= v_1 ≥ 0 ∧ v_1 ≤ 12 +Token usage: input=10253, output=146, total=10399 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 24 (If the algorithm is "default", shape list must be empty) +{v_1 : str, v_2 : list(int)} |= if v_1 = "default" then v_2.len = 0 +Token usage: input=10253, output=146, total=10399 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 25 (The product of shape list items should be less than max int32) +{v_1 : list(int)} |= ∃x ∈ [0, v_1.len-1] : v_1[x] < 2147483647 +Token usage: input=11916, output=188, total=12104 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 26 (If the algorithm is "threefry", shape list length should be equal to 1) +{v_1 : str, v_2 : list(int)} |= if v_1 = "threefry" then v_2.len = 1 +Token usage: input=11916, output=188, total=12104 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 27 (If the algorithm is "philox", shape list length should be equal to 1) +{v_1 : str, v_2 : list(int)} |= if v_1 = "philox" then v_2.len = 1 +Token usage: input=11916, output=188, total=12104 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 28 (The dtype must be int8, int16, int32, int64, uint8, float16, float32, float64, complex64, complex128) +{v_1 : dtype} |= v_1 = 1 ∨ v_1 = 2 ∨ v_1 = 3 ∨ v_1 = 4 ∨ v_1 = 5 ∨ v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 ∨ v_1 = 9 ∨ v_1 = 10 +Token usage: input=13622, output=279, total=13901 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 29 (If shape list is provided, dtype should not be bool or string) +{v_1 : list(int), v_2 : dtype} |= if v_1.len > 0 then v_2 ≠ 0 ∧ v_2 ≠ 11 +Token usage: input=13622, output=279, total=13901 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 30 (The initial state string length has to correspond to number of elements if "rbg" is the selected generator) +{v_1 : str, v_2: str, v_3 : list(int)} |= if v_1 = "rbg" then v_2.len = v_3[0] * 2 +Token usage: input=13622, output=279, total=13901 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 31 (If algorithm is rbg and initial state is provided, the length of the initial state has to be exactly twice the first dimension in shape list.) +{v_1 : str, v_2 : str, v_3 : list(int)} |= if v_1 = "rbg" ∧ v_3.len > 0 then v_2.len = 2 * v_3[0] +Token usage: input=15459, output=95, total=15554 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 32 (if the algorithm is "rbg" and the shape list has more than 1 element then this is an error) +{v_1 : str, v_2 : list(int)} |= if v_1 = "rbg" then v_2.len ≤ 1 +Token usage: input=16947, output=67, total=17014 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 33 (If the algorithm is "rbg" and shape list is not empty, then dtype can only be np.uint32 or np.uint64) +{v_1 : str, v_2 : list(int), v_3 : dtype} |= if v_1 = "rbg" ∧ v_2.len > 0 then v_3 = 3 ∨ v_3 = 4 +Token usage: input=18443, output=97, total=18540 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 34 (if the algorithm is "rbg" and the shape list is empty, the dtype must be specified.) +{v_1 : str, v_2 : list(int), v_3 : dtype} |= if v_1 = "rbg" ∧ v_2.len = 0 then v_3 ≠ 12 +Token usage: input=20155, output=79, total=20234 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 35 (If initial state is not 'default', the algorithm cannot be 'default') +{v_1 : str, v_2 : str} |= if v_2 ≠ "default" then v_1 ≠ "default" +Token usage: input=21585, output=54, total=21639 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 36 (If dtype is complex64 or complex128, shape must be specified) +{v_1 : dtype, v_2 : list(int)} |= if v_1 = 9 ∨ v_1 = 10 then v_2.len > 0 +Token usage: input=23011, output=67, total=23078 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 37 (if the algorithm is "rbg", and shape list is specified, then dtype must be np.uint32 or np.uint64) +{v_1 : str, v_2 : list(int), v_3 : dtype} |= if v_1 = "rbg" ∧ v_2.len > 0 then v_3 = 3 ∨ v_3 = 4 +Token usage: input=24537, output=95, total=24632 +** DUPLICATED RULE ** (num_failures: 4) + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_1 : str, v_2 : list(int), v_3 : dtype} |= if v_1 = "rbg" ∧ v_2.len > 0 then v_3 = 3 ∨ v_3 = 4 + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 38 (If algorithm is rbg, initial state length has to be exactly twice the first shape dimension) +{v_1 : str, v_2 : str, v_3 : list(int)} |= if v_1 = "rbg" ∧ v_3.len > 0 then v_2.len = 2 * v_3[0] +Token usage: input=26139, output=85, total=26224 +** DUPLICATED RULE ** (num_failures: 5) + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_1 : str, v_2 : str, v_3 : list(int)} |= if v_1 = "rbg" ∧ v_3.len > 0 then v_2.len = 2 * v_3[0] + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 39 (When the algorithm is "rbg", the initial state must consist of only hexadecimal characters) +{v_1 : str, v_2 : str} |= if v_1 = "rbg" then ∀i ∈ [0, v_2.len - 1] : v_2[i] = "0" ∨ v_2[i] = "1" ∨ v_2[i] = "2" ∨ v_2[i] = "3" ∨ v_2[i] = "4" ∨ v_2[i] = "5" ∨ v_2[i] = "6" ∨ v_2[i] = "7" ∨ v_2[i] = "8" ∨ v_2[i] = "9" ∨ v_2[i] = "a" ∨ v_2[i] = "b" ∨ v_2[i] = "c" ∨ v_2[i] = "d" ∨ v_2[i] = "e" ∨ v_2[i] = "f" +Token usage: input=27703, output=257, total=27960 +** DUPLICATED RULE ** (num_failures: 6) + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_1 : str, v_2 : str} |= if v_1 = "rbg" then ∀i ∈ [0, v_2.len - 1] : v_2[i] = "0" ∨ v_2[i] = "1" ∨ v_2[i] = "2" ∨ v_2[i] = "3" ∨ v_2[i] = "4" ∨ v_2[i] = "5" ∨ v_2[i] = "6" ∨ v_2[i] = "7" ∨ v_2[i] = "8" ∨ v_2[i] = "9" ∨ v_2[i] = "a" ∨ v_2[i] = "b" ∨ v_2[i] = "c" ∨ v_2[i] = "d" ∨ v_2[i] = "e" ∨ v_2[i] = "f" + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 40 (If the shape list is empty, the algorithm cannot be "threefry" or "philox") +{v_1 : str, v_2 : list(int)} |= if v_2.len = 0 then v_1 ≠ "threefry" ∧ v_1 ≠ "philox" +Token usage: input=29639, output=73, total=29712 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 41 (if algorithm is threefry or philox, the initial state must be 'default') +{v_1 : str, v_2 : str} |= if v_1 = "threefry" ∨ v_1 = "philox" then v_2 = "default" +Token usage: input=31224, output=67, total=31291 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 42 (If dtype is bool and shape is specified, the first dimension size should be small) +{v_1 : dtype, v_2 : list(int)} |= if v_1 = 0 ∧ v_2.len > 0 then v_2[0] < 256 +Token usage: input=32756, output=71, total=32827 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 43 (If dtype is bool and shape is specified, the product of the dimensions should be small.) +{v_1 : dtype, v_2 : list(int)} |= if v_1 = 0 ∧ v_2.len > 0 then ∃i ∈ [0, v_2.len - 1] : v_2[i] < 1024 +Token usage: input=34323, output=90, total=34413 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 44 (if dtype is string, shape must be empty) +{v_1 : dtype, v_2 : list(int)} |= if v_1 = 11 then v_2.len = 0 +Token usage: input=35958, output=52, total=36010 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 45 (If dtype is dtype and shape is specified, it must not be empty) +{v_1 : dtype, v_2 : list(int)} |= if v_1 = 12 then v_2.len > 0 +Token usage: input=37388, output=57, total=37445 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 46 (If algorithm is philox or threefry, the shape list length should be one.) +{v_1 : str, v_2 : list(int)} |= if v_1 = "philox" ∨ v_1 = "threefry" then v_2.len = 1 +Token usage: input=39030, output=70, total=39100 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 47 (If algorithm is neither philox nor threefry, then the initial state should be "default") +{v_1 : str, v_2 : str} |= if v_1 ≠ "philox" ∧ v_1 ≠ "threefry" then v_2 = "default" +Token usage: input=40484, output=69, total=40553 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 48 (if algorithm is rbg, and shape list is not empty, then first dimension should not exceed 1024) +{v_1 : str, v_2 : list(int)} |= if v_1 = "rbg" ∧ v_2.len > 0 then v_2[0] ≤ 1024 +Token usage: input=41991, output=82, total=42073 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 49 (If the dtype is specified, then it cannot be string.) +{v_1 : dtype} |= v_1 ≠ 11 +Token usage: input=43452, output=34, total=43486 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 50 (If the dtype is not specified, and algorithm is rbg, then an error is thrown.) +{v_1 : str, v_2 : dtype} |= if v_1 = "rbg" then v_2 ≠ 12 +Token usage: input=44927, output=59, total=44986 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 51 (If dtype is complex128, the algorithm should not be threefry or philox.) +{v_1 : dtype, v_2 : str} |= if v_1 = 10 then v_2 ≠ "threefry" ∧ v_2 ≠ "philox" +Token usage: input=46464, output=69, total=46533 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 52 (If dtype is complex64, the algorithm should not be threefry or philox.) +{v_1 : dtype, v_2 : str} |= if v_1 = 9 then v_2 ≠ "threefry" ∧ v_2 ≠ "philox" +Token usage: input=48041, output=67, total=48108 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 53 (If the algorithm is rbg, then the shape list can be empty or contain exactly one element.) +{v_1 : str, v_2 : list(int)} |= if v_1 = "rbg" then v_2.len = 0 ∨ v_2.len = 1 +Token usage: input=49614, output=73, total=49687 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 54 (If dtype is np.complex64 or np.complex128, shape must not be empty) +{v_1 : dtype, v_2 : list(int)} |= if v_1 = 9 ∨ v_1 = 10 then v_2.len > 0 +Token usage: input=51290, output=72, total=51362 +** DUPLICATED RULE ** (num_failures: 7) + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_1 : dtype, v_2 : list(int)} |= if v_1 = 9 ∨ v_1 = 10 then v_2.len > 0 + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 55 (The initial state length cannot be zero) +{v_1 : str} |= v_1.len > 0 +Token usage: input=52947, output=31, total=52978 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 56 (The algorithm must be in the accepted list: threefry, philox, rbg) +{v_1 : str} |= v_1 = "threefry" ∨ v_1 = "philox" ∨ v_1 = "rbg" +Token usage: input=54454, output=61, total=54515 +** DUPLICATED RULE ** (num_failures: 8) + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_1 : str} |= v_1 = "threefry" ∨ v_1 = "philox" ∨ v_1 = "rbg" + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 57 (if the shape list is empty, then the algorithm can be either rbg or it should not be threefry or philox) +{v_1 : str, v_2 : list(int)} |= if v_2.len = 0 then v_1 = "rbg" ∨ v_1 ≠ "threefry" ∨ v_1 ≠ "philox" +Token usage: input=56120, output=89, total=56209 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.rng_bit_generator API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] algorithm: string, initial_state: string, shape: list, dtype: dtype + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 58 (If algorithm is rbg, and the shape list is empty, dtype should be uint32 or uint64 or should be explicitly specified) +{v_1 : str, v_2 : list(int), v_3 : dtype} |= if v_1 = "rbg" ∧ v_2.len = 0 then v_3 = 3 ∨ v_3 = 4 ∨ v_3 ≠ 12 +Token usage: input=57726, output=103, total=57829 +** SUCCESS ** + diff --git a/rules-tf/xla.rng_bit_generator/rule_11.py b/rules-tf/xla.rng_bit_generator/rule_11.py new file mode 100644 index 0000000000..7c9185cd6f --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_11.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# Dtype must not be boolean (Rule 11) + +rule_11 = lambda s, v, n=False: ( + s.add(Not(v["arg1_value"] != 0) if n else + v["arg1_value"] != 0) +) + +def rule_11_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, torch.dtype) or isinstance(arg1, tf.dtypes.DType)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + + # Value assignments + solver.add(arg1_value == list_of_available_dtypes.index(np_dtype(arg1))) + + # Constraints for rule 11 + rule_11(solver, {'arg1_value': arg1_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_11(solver, {'arg1_value': arg1['value']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_14.py b/rules-tf/xla.rng_bit_generator/rule_14.py new file mode 100644 index 0000000000..f84f22a492 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_14.py @@ -0,0 +1,39 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# the elements of shape list must be non-negative integers (Rule 14) + +rule_14 = lambda s, v, n=False: ( + s.add(Not(And([Implies(i < (v["arg1_length"] - 1 + 1), Select(v["arg1_values"], i) >= 0) for i in range(6)])) if n else + And([Implies(i < (v["arg1_length"] - 1 + 1), Select(v["arg1_values"], i) >= 0) for i in range(6)])) +) + +def rule_14_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg1)): + return False + + # Variable declarations + solver = Solver() + arg1_length = Int('arg1_length') + arg1_values = Array('arg1_values', IntSort(), IntSort()) + + # Value assignments + solver.add(arg1_length == len(arg1)) + for i in range(len(arg1)): + arg1_values = Store(arg1_values, i, arg1[i]) + + # Constraints for rule 14 + rule_14(solver, {'arg1_values': arg1_values, 'arg1_length': arg1_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_14(solver, {'arg1_values': arg1['values'], 'arg1_length': arg1['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_15.py b/rules-tf/xla.rng_bit_generator/rule_15.py new file mode 100644 index 0000000000..5520cfebaa --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_15.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# if the shape list is not empty, the dtype cannot be string (Rule 15) + +rule_15 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_length"] > 0, v["arg2_value"] != 11, True)) if n else + If(v["arg1_length"] > 0, v["arg2_value"] != 11, True)) +) + +def rule_15_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg1)): + return False + if not (isinstance(arg2, torch.dtype) or isinstance(arg2, tf.dtypes.DType)): + return False + + # Variable declarations + solver = Solver() + arg1_length = Int('arg1_length') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_length == len(arg1)) + solver.add(arg2_value == list_of_available_dtypes.index(np_dtype(arg2))) + + # Constraints for rule 15 + rule_15(solver, {'arg1_length': arg1_length, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_15(solver, {'arg1_length': arg1['length'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_17.py b/rules-tf/xla.rng_bit_generator/rule_17.py new file mode 100644 index 0000000000..bca4e67ecf --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_17.py @@ -0,0 +1,39 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# the product of the shape list elements should not exceed maximum value of int32 (Rule 17) + +rule_17 = lambda s, v, n=False: ( + s.add(Not(Or([And(i < (v["arg1_length"] - 1 + 1), Select(v["arg1_values"], i) <= 2147483647) for i in range(6)])) if n else + Or([And(i < (v["arg1_length"] - 1 + 1), Select(v["arg1_values"], i) <= 2147483647) for i in range(6)])) +) + +def rule_17_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg1)): + return False + + # Variable declarations + solver = Solver() + arg1_length = Int('arg1_length') + arg1_values = Array('arg1_values', IntSort(), IntSort()) + + # Value assignments + solver.add(arg1_length == len(arg1)) + for i in range(len(arg1)): + arg1_values = Store(arg1_values, i, arg1[i]) + + # Constraints for rule 17 + rule_17(solver, {'arg1_values': arg1_values, 'arg1_length': arg1_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_17(solver, {'arg1_values': arg1['values'], 'arg1_length': arg1['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_2.py b/rules-tf/xla.rng_bit_generator/rule_2.py new file mode 100644 index 0000000000..0965e153d9 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_2.py @@ -0,0 +1,39 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# shape list should have positive sizes (Rule 2) + +rule_2 = lambda s, v, n=False: ( + s.add(Not(And([Implies(i < (v["arg1_length"] - 1 + 1), Select(v["arg1_values"], i) > 0) for i in range(6)])) if n else + And([Implies(i < (v["arg1_length"] - 1 + 1), Select(v["arg1_values"], i) > 0) for i in range(6)])) +) + +def rule_2_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg1)): + return False + + # Variable declarations + solver = Solver() + arg1_length = Int('arg1_length') + arg1_values = Array('arg1_values', IntSort(), IntSort()) + + # Value assignments + solver.add(arg1_length == len(arg1)) + for i in range(len(arg1)): + arg1_values = Store(arg1_values, i, arg1[i]) + + # Constraints for rule 2 + rule_2(solver, {'arg1_values': arg1_values, 'arg1_length': arg1_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_2(solver, {'arg1_values': arg1['values'], 'arg1_length': arg1['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_21.py b/rules-tf/xla.rng_bit_generator/rule_21.py new file mode 100644 index 0000000000..dadc184574 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_21.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# The length of the shape list should not exceed 8 (Rule 21) + +rule_21 = lambda s, v, n=False: ( + s.add(Not(v["arg1_length"] < 9) if n else + v["arg1_length"] < 9) +) + +def rule_21_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg1)): + return False + + # Variable declarations + solver = Solver() + arg1_length = Int('arg1_length') + + # Value assignments + solver.add(arg1_length == len(arg1)) + + # Constraints for rule 21 + rule_21(solver, {'arg1_length': arg1_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_21(solver, {'arg1_length': arg1['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_22.py b/rules-tf/xla.rng_bit_generator/rule_22.py new file mode 100644 index 0000000000..0c7123fbb6 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_22.py @@ -0,0 +1,39 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# The shape list cannot contain zero (Rule 22) + +rule_22 = lambda s, v, n=False: ( + s.add(Not(And([Implies(i < (v["arg1_length"] - 1 + 1), Select(v["arg1_values"], i) != 0) for i in range(6)])) if n else + And([Implies(i < (v["arg1_length"] - 1 + 1), Select(v["arg1_values"], i) != 0) for i in range(6)])) +) + +def rule_22_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg1)): + return False + + # Variable declarations + solver = Solver() + arg1_length = Int('arg1_length') + arg1_values = Array('arg1_values', IntSort(), IntSort()) + + # Value assignments + solver.add(arg1_length == len(arg1)) + for i in range(len(arg1)): + arg1_values = Store(arg1_values, i, arg1[i]) + + # Constraints for rule 22 + rule_22(solver, {'arg1_values': arg1_values, 'arg1_length': arg1_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_22(solver, {'arg1_values': arg1['values'], 'arg1_length': arg1['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_23.py b/rules-tf/xla.rng_bit_generator/rule_23.py new file mode 100644 index 0000000000..1ae962f6d8 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_23.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# The dtype must be a valid type from allowed integer range (Rule 23) + +rule_23 = lambda s, v, n=False: ( + s.add(Not(And(v["arg1_value"] >= 0, v["arg1_value"] <= 12)) if n else + And(v["arg1_value"] >= 0, v["arg1_value"] <= 12)) +) + +def rule_23_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, torch.dtype) or isinstance(arg1, tf.dtypes.DType)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + + # Value assignments + solver.add(arg1_value == list_of_available_dtypes.index(np_dtype(arg1))) + + # Constraints for rule 23 + rule_23(solver, {'arg1_value': arg1_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_23(solver, {'arg1_value': arg1['value']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_25.py b/rules-tf/xla.rng_bit_generator/rule_25.py new file mode 100644 index 0000000000..a151ce53cb --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_25.py @@ -0,0 +1,39 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# The product of shape list items should be less than max int32 (Rule 25) + +rule_25 = lambda s, v, n=False: ( + s.add(Not(Or([And(x < (v["arg1_length"] - 1 + 1), Select(v["arg1_values"], x) < 2147483647) for x in range(6)])) if n else + Or([And(x < (v["arg1_length"] - 1 + 1), Select(v["arg1_values"], x) < 2147483647) for x in range(6)])) +) + +def rule_25_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg1)): + return False + + # Variable declarations + solver = Solver() + arg1_length = Int('arg1_length') + arg1_values = Array('arg1_values', IntSort(), IntSort()) + + # Value assignments + solver.add(arg1_length == len(arg1)) + for i in range(len(arg1)): + arg1_values = Store(arg1_values, i, arg1[i]) + + # Constraints for rule 25 + rule_25(solver, {'arg1_values': arg1_values, 'arg1_length': arg1_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_25(solver, {'arg1_values': arg1['values'], 'arg1_length': arg1['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_28.py b/rules-tf/xla.rng_bit_generator/rule_28.py new file mode 100644 index 0000000000..b7128fff41 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_28.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# The dtype must be int8, int16, int32, int64, uint8, float16, float32, float64, complex64, complex128 (Rule 28) + +rule_28 = lambda s, v, n=False: ( + s.add(Not(Or(Or(Or(Or(Or(Or(Or(Or(Or(v["arg1_value"] == 1, v["arg1_value"] == 2), v["arg1_value"] == 3), v["arg1_value"] == 4), v["arg1_value"] == 5), v["arg1_value"] == 6), v["arg1_value"] == 7), v["arg1_value"] == 8), v["arg1_value"] == 9), v["arg1_value"] == 10)) if n else + Or(Or(Or(Or(Or(Or(Or(Or(Or(v["arg1_value"] == 1, v["arg1_value"] == 2), v["arg1_value"] == 3), v["arg1_value"] == 4), v["arg1_value"] == 5), v["arg1_value"] == 6), v["arg1_value"] == 7), v["arg1_value"] == 8), v["arg1_value"] == 9), v["arg1_value"] == 10)) +) + +def rule_28_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, torch.dtype) or isinstance(arg1, tf.dtypes.DType)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + + # Value assignments + solver.add(arg1_value == list_of_available_dtypes.index(np_dtype(arg1))) + + # Constraints for rule 28 + rule_28(solver, {'arg1_value': arg1_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_28(solver, {'arg1_value': arg1['value']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_29.py b/rules-tf/xla.rng_bit_generator/rule_29.py new file mode 100644 index 0000000000..eb1ccc93f6 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_29.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If shape list is provided, dtype should not be bool or string (Rule 29) + +rule_29 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_length"] > 0, And(v["arg2_value"] != 0, v["arg2_value"] != 11), True)) if n else + If(v["arg1_length"] > 0, And(v["arg2_value"] != 0, v["arg2_value"] != 11), True)) +) + +def rule_29_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg1)): + return False + if not (isinstance(arg2, torch.dtype) or isinstance(arg2, tf.dtypes.DType)): + return False + + # Variable declarations + solver = Solver() + arg1_length = Int('arg1_length') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_length == len(arg1)) + solver.add(arg2_value == list_of_available_dtypes.index(np_dtype(arg2))) + + # Constraints for rule 29 + rule_29(solver, {'arg1_length': arg1_length, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_29(solver, {'arg1_length': arg1['length'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_3.py b/rules-tf/xla.rng_bit_generator/rule_3.py new file mode 100644 index 0000000000..952f57970c --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_3.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# dtype should be a valid data type (Rule 3) + +rule_3 = lambda s, v, n=False: ( + s.add(Not(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(v["arg1_value"] == 0, v["arg1_value"] == 1), v["arg1_value"] == 2), v["arg1_value"] == 3), v["arg1_value"] == 4), v["arg1_value"] == 5), v["arg1_value"] == 6), v["arg1_value"] == 7), v["arg1_value"] == 8), v["arg1_value"] == 9), v["arg1_value"] == 10), v["arg1_value"] == 12)) if n else + Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(v["arg1_value"] == 0, v["arg1_value"] == 1), v["arg1_value"] == 2), v["arg1_value"] == 3), v["arg1_value"] == 4), v["arg1_value"] == 5), v["arg1_value"] == 6), v["arg1_value"] == 7), v["arg1_value"] == 8), v["arg1_value"] == 9), v["arg1_value"] == 10), v["arg1_value"] == 12)) +) + +def rule_3_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, torch.dtype) or isinstance(arg1, tf.dtypes.DType)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + + # Value assignments + solver.add(arg1_value == list_of_available_dtypes.index(np_dtype(arg1))) + + # Constraints for rule 3 + rule_3(solver, {'arg1_value': arg1_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_3(solver, {'arg1_value': arg1['value']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_36.py b/rules-tf/xla.rng_bit_generator/rule_36.py new file mode 100644 index 0000000000..304bc1f703 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_36.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If dtype is complex64 or complex128, shape must be specified (Rule 36) + +rule_36 = lambda s, v, n=False: ( + s.add(Not(If(Or(v["arg1_value"] == 9, v["arg1_value"] == 10), v["arg2_length"] > 0, True)) if n else + If(Or(v["arg1_value"] == 9, v["arg1_value"] == 10), v["arg2_length"] > 0, True)) +) + +def rule_36_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, torch.dtype) or isinstance(arg1, tf.dtypes.DType)): + return False + if not (isinstance(arg2, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg2)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + arg2_length = Int('arg2_length') + + # Value assignments + solver.add(arg1_value == list_of_available_dtypes.index(np_dtype(arg1))) + solver.add(arg2_length == len(arg2)) + + # Constraints for rule 36 + rule_36(solver, {'arg1_value': arg1_value, 'arg2_length': arg2_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_36(solver, {'arg1_value': arg1['value'], 'arg2_length': arg2['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_42.py b/rules-tf/xla.rng_bit_generator/rule_42.py new file mode 100644 index 0000000000..eea27f34c1 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_42.py @@ -0,0 +1,44 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If dtype is bool and shape is specified, the first dimension size should be small (Rule 42) + +rule_42 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg1_value"] == 0, v["arg2_length"] > 0), Select(v["arg2_values"], 0) < 256, True)) if n else + If(And(v["arg1_value"] == 0, v["arg2_length"] > 0), Select(v["arg2_values"], 0) < 256, True)) +) + +def rule_42_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, torch.dtype) or isinstance(arg1, tf.dtypes.DType)): + return False + if not (isinstance(arg2, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg2)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + arg2_length = Int('arg2_length') + arg2_values = Array('arg2_values', IntSort(), IntSort()) + + # Value assignments + solver.add(arg1_value == list_of_available_dtypes.index(np_dtype(arg1))) + solver.add(arg2_length == len(arg2)) + for i in range(len(arg2)): + arg2_values = Store(arg2_values, i, arg2[i]) + + # Constraints for rule 42 + rule_42(solver, {'arg1_value': arg1_value, 'arg2_values': arg2_values, 'arg2_length': arg2_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_42(solver, {'arg1_value': arg1['value'], 'arg2_values': arg2['values'], 'arg2_length': arg2['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_43.py b/rules-tf/xla.rng_bit_generator/rule_43.py new file mode 100644 index 0000000000..3b14e8bc0d --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_43.py @@ -0,0 +1,44 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If dtype is bool and shape is specified, the product of the dimensions should be small. (Rule 43) + +rule_43 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg1_value"] == 0, v["arg2_length"] > 0), Or([And(i < (v["arg2_length"] - 1 + 1), Select(v["arg2_values"], i) < 1024) for i in range(6)]), True)) if n else + If(And(v["arg1_value"] == 0, v["arg2_length"] > 0), Or([And(i < (v["arg2_length"] - 1 + 1), Select(v["arg2_values"], i) < 1024) for i in range(6)]), True)) +) + +def rule_43_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, torch.dtype) or isinstance(arg1, tf.dtypes.DType)): + return False + if not (isinstance(arg2, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg2)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + arg2_length = Int('arg2_length') + arg2_values = Array('arg2_values', IntSort(), IntSort()) + + # Value assignments + solver.add(arg1_value == list_of_available_dtypes.index(np_dtype(arg1))) + solver.add(arg2_length == len(arg2)) + for i in range(len(arg2)): + arg2_values = Store(arg2_values, i, arg2[i]) + + # Constraints for rule 43 + rule_43(solver, {'arg1_value': arg1_value, 'arg2_values': arg2_values, 'arg2_length': arg2_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_43(solver, {'arg1_value': arg1['value'], 'arg2_values': arg2['values'], 'arg2_length': arg2['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_44.py b/rules-tf/xla.rng_bit_generator/rule_44.py new file mode 100644 index 0000000000..19844c8a2d --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_44.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# if dtype is string, shape must be empty (Rule 44) + +rule_44 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_value"] == 11, v["arg2_length"] == 0, True)) if n else + If(v["arg1_value"] == 11, v["arg2_length"] == 0, True)) +) + +def rule_44_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, torch.dtype) or isinstance(arg1, tf.dtypes.DType)): + return False + if not (isinstance(arg2, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg2)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + arg2_length = Int('arg2_length') + + # Value assignments + solver.add(arg1_value == list_of_available_dtypes.index(np_dtype(arg1))) + solver.add(arg2_length == len(arg2)) + + # Constraints for rule 44 + rule_44(solver, {'arg1_value': arg1_value, 'arg2_length': arg2_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_44(solver, {'arg1_value': arg1['value'], 'arg2_length': arg2['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_45.py b/rules-tf/xla.rng_bit_generator/rule_45.py new file mode 100644 index 0000000000..681f897cf7 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_45.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If dtype is dtype and shape is specified, it must not be empty (Rule 45) + +rule_45 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_value"] == 12, v["arg2_length"] > 0, True)) if n else + If(v["arg1_value"] == 12, v["arg2_length"] > 0, True)) +) + +def rule_45_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, torch.dtype) or isinstance(arg1, tf.dtypes.DType)): + return False + if not (isinstance(arg2, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg2)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + arg2_length = Int('arg2_length') + + # Value assignments + solver.add(arg1_value == list_of_available_dtypes.index(np_dtype(arg1))) + solver.add(arg2_length == len(arg2)) + + # Constraints for rule 45 + rule_45(solver, {'arg1_value': arg1_value, 'arg2_length': arg2_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_45(solver, {'arg1_value': arg1['value'], 'arg2_length': arg2['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_49.py b/rules-tf/xla.rng_bit_generator/rule_49.py new file mode 100644 index 0000000000..f2c20f72e5 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_49.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the dtype is specified, then it cannot be string. (Rule 49) + +rule_49 = lambda s, v, n=False: ( + s.add(Not(v["arg1_value"] != 11) if n else + v["arg1_value"] != 11) +) + +def rule_49_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, torch.dtype) or isinstance(arg1, tf.dtypes.DType)): + return False + + # Variable declarations + solver = Solver() + arg1_value = Int('arg1_value') + + # Value assignments + solver.add(arg1_value == list_of_available_dtypes.index(np_dtype(arg1))) + + # Constraints for rule 49 + rule_49(solver, {'arg1_value': arg1_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_49(solver, {'arg1_value': arg1['value']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_5.py b/rules-tf/xla.rng_bit_generator/rule_5.py new file mode 100644 index 0000000000..40117324f3 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_5.py @@ -0,0 +1,39 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# initial_state must have a specific shape. (Rule 5) + +rule_5 = lambda s, v, n=False: ( + s.add(Not(And(v["arg1_ndim"] == 1, Select(v["arg1_shape"], 0) == 2)) if n else + And(v["arg1_ndim"] == 1, Select(v["arg1_shape"], 0) == 2)) +) + +def rule_5_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg1_shape = Array('arg1_shape', IntSort(), IntSort()) + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + for i in range(arg1.ndim): + arg1_shape = Store(arg1_shape, i, arg1.shape[i]) + + # Constraints for rule 5 + rule_5(solver, {'arg1_ndim': arg1_ndim, 'arg1_shape': arg1_shape}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_5(solver, {'arg1_ndim': arg1['ndim'], 'arg1_shape': arg1['shape']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_6.py b/rules-tf/xla.rng_bit_generator/rule_6.py new file mode 100644 index 0000000000..34cfc44c19 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_6.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# shape of output tensor should be within a maximum size (Rule 6) + +rule_6 = lambda s, v, n=False: ( + s.add(Not(v["arg1_length"] < 10) if n else + v["arg1_length"] < 10) +) + +def rule_6_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg1)): + return False + + # Variable declarations + solver = Solver() + arg1_length = Int('arg1_length') + + # Value assignments + solver.add(arg1_length == len(arg1)) + + # Constraints for rule 6 + rule_6(solver, {'arg1_length': arg1_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_6(solver, {'arg1_length': arg1['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_7.py b/rules-tf/xla.rng_bit_generator/rule_7.py new file mode 100644 index 0000000000..73c94c9dde --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_7.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# if shape is empty, the output is scalar. (Rule 7) + +rule_7 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_length"] == 0, (Or(Or(Or(v["arg2_value"] == 0, v["arg2_value"] == 6), v["arg2_value"] == 7), v["arg2_value"] == 8)), True)) if n else + If(v["arg1_length"] == 0, (Or(Or(Or(v["arg2_value"] == 0, v["arg2_value"] == 6), v["arg2_value"] == 7), v["arg2_value"] == 8)), True)) +) + +def rule_7_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not (isinstance(arg1, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg1)): + return False + if not (isinstance(arg2, torch.dtype) or isinstance(arg2, tf.dtypes.DType)): + return False + + # Variable declarations + solver = Solver() + arg1_length = Int('arg1_length') + arg2_value = Int('arg2_value') + + # Value assignments + solver.add(arg1_length == len(arg1)) + solver.add(arg2_value == list_of_available_dtypes.index(np_dtype(arg2))) + + # Constraints for rule 7 + rule_7(solver, {'arg1_length': arg1_length, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_7(solver, {'arg1_length': arg1['length'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_8.py b/rules-tf/xla.rng_bit_generator/rule_8.py new file mode 100644 index 0000000000..620ed94e6e --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_8.py @@ -0,0 +1,42 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# if initial state is provided, the shape is derived from it (Rule 8) + +rule_8 = lambda s, v, n=False: ( + s.add(Not(And(Select(v["arg1_shape"], 0) >= 0, Select(v["arg1_shape"], 0) == v["arg2_length"])) if n else + And(Select(v["arg1_shape"], 0) >= 0, Select(v["arg1_shape"], 0) == v["arg2_length"])) +) + +def rule_8_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not (isinstance(arg2, list) and all((isinstance(e, (int, np.integer)) and not isinstance(e, bool)) for e in arg2)): + return False + + # Variable declarations + solver = Solver() + arg1_shape = Array('arg1_shape', IntSort(), IntSort()) + arg2_length = Int('arg2_length') + + # Value assignments + for i in range(arg1.ndim): + arg1_shape = Store(arg1_shape, i, arg1.shape[i]) + solver.add(arg2_length == len(arg2)) + + # Constraints for rule 8 + rule_8(solver, {'arg1_shape': arg1_shape, 'arg2_length': arg2_length}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_8(solver, {'arg1_shape': arg1['shape'], 'arg2_length': arg2['length']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rule_9.py b/rules-tf/xla.rng_bit_generator/rule_9.py new file mode 100644 index 0000000000..ca53a77cd1 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rule_9.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# initial_state should be a tensor of integers (Rule 9) + +rule_9 = lambda s, v, n=False: ( + s.add(Not(Or(Or(Or(Or(v["arg1_dtype"] == 1, v["arg1_dtype"] == 2), v["arg1_dtype"] == 3), v["arg1_dtype"] == 4), v["arg1_dtype"] == 5)) if n else + Or(Or(Or(Or(v["arg1_dtype"] == 1, v["arg1_dtype"] == 2), v["arg1_dtype"] == 3), v["arg1_dtype"] == 4), v["arg1_dtype"] == 5)) +) + +def rule_9_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + + # Constraints for rule 9 + rule_9(solver, {'arg1_dtype': arg1_dtype}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_9(solver, {'arg1_dtype': arg1['dtype']}, neg) diff --git a/rules-tf/xla.rng_bit_generator/rules-ebnf b/rules-tf/xla.rng_bit_generator/rules-ebnf new file mode 100644 index 0000000000..f44e5e28b1 --- /dev/null +++ b/rules-tf/xla.rng_bit_generator/rules-ebnf @@ -0,0 +1,150 @@ +>> +Rule 1 (algorithm should be a valid string value) +{v_1 : str} |= v_1 = "threefry" ∨ v_1 = "philox" ∨ v_1 = "rbg" +>> +Rule 2 (shape list should have positive sizes) +{v_1 : list(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 +>> +Rule 3 (dtype should be a valid data type) +{v_1 : dtype} |= v_1 = 0 ∨ v_1 = 1 ∨ v_1 = 2 ∨ v_1 = 3 ∨ v_1 = 4 ∨ v_1 = 5 ∨ v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 ∨ v_1 = 9 ∨ v_1 = 10 ∨ v_1 = 12 +>> +Rule 5 (initial_state must have a specific shape.) +{v_1 : tensor} |= ndim(v_1) = 1 ∧ shape(v_1, 0) = 2 +>> +Rule 6 (shape of output tensor should be within a maximum size) +{v_1 : list(int)} |= v_1.len < 10 +>> +Rule 7 (if shape is empty, the output is scalar.) +{v_1 : list(int), v_2 : dtype} |= if v_1.len = 0 then (v_2 = 0 ∨ v_2 = 6 ∨ v_2 = 7 ∨ v_2 = 8) +>> +Rule 8 (if initial state is provided, the shape is derived from it) +{v_1 : tensor, v_2 : list(int)} |= shape(v_1,0) ≥ 0 ∧ shape(v_1,0) = v_2.len +>> +Rule 9 (initial_state should be a tensor of integers) +{v_1 : tensor} |= dtype_(v_1) = 1 ∨ dtype_(v_1) = 2 ∨ dtype_(v_1) = 3 ∨ dtype_(v_1) = 4 ∨ dtype_(v_1) = 5 +>> +Rule 10 (algorithm name cannot be an empty string) +{v_1 : str} |= v_1 ≠ "" +>> +Rule 11 (Dtype must not be boolean) +{v_1 : dtype} |= v_1 ≠ 0 +>> +Rule 14 (the elements of shape list must be non-negative integers) +{v_1 : list(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 +>> +Rule 15 (if the shape list is not empty, the dtype cannot be string) +{v_1 : list(int), v_2 : dtype} |= if v_1.len > 0 then v_2 ≠ 11 +>> +Rule 16 (initial state should be a string with length not exceeding 256) +{v_1 : str} |= v_1.len < 256 +>> +Rule 17 (the product of the shape list elements should not exceed maximum value of int32) +{v_1 : list(int)} |= ∃i ∈ [0, v_1.len - 1] : v_1[i] ≤ 2147483647 +>> +Rule 18 (If the algorithm is "rbg", initial state must not be an empty string) +{v_1 : str, v_2 : str} |= if v_1 = "rbg" then v_2 ≠ "" +>> +Rule 19 (If the algorithm is "rbg", the initial state must be a valid hex string) +{v_1 : str, v_2 : str} |= if v_1 = "rbg" then ∀i ∈ [0, v_2.len - 1] : v_2[i] = "0" ∨ v_2[i] = "1" ∨ v_2[i] = "2" ∨ v_2[i] = "3" ∨ v_2[i] = "4" ∨ v_2[i] = "5" ∨ v_2[i] = "6" ∨ v_2[i] = "7" ∨ v_2[i] = "8" ∨ v_2[i] = "9" ∨ v_2[i] = "a" ∨ v_2[i] = "b" ∨ v_2[i] = "c" ∨ v_2[i] = "d" ∨ v_2[i] = "e" ∨ v_2[i] = "f" +>> +Rule 20 (If the algorithm is not "rbg", the initial state must be "default") +{v_1 : str, v_2 : str} |= if v_1 ≠ "rbg" then v_2 = "default" +>> +Rule 21 (The length of the shape list should not exceed 8) +{v_1 : list(int)} |= v_1.len < 9 +>> +Rule 22 (The shape list cannot contain zero) +{v_1 : list(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≠ 0 +>> +Rule 23 (The dtype must be a valid type from allowed integer range) +{v_1 : dtype} |= v_1 ≥ 0 ∧ v_1 ≤ 12 +>> +Rule 24 (If the algorithm is "default", shape list must be empty) +{v_1 : str, v_2 : list(int)} |= if v_1 = "default" then v_2.len = 0 +>> +Rule 25 (The product of shape list items should be less than max int32) +{v_1 : list(int)} |= ∃x ∈ [0, v_1.len-1] : v_1[x] < 2147483647 +>> +Rule 26 (If the algorithm is "threefry", shape list length should be equal to 1) +{v_1 : str, v_2 : list(int)} |= if v_1 = "threefry" then v_2.len = 1 +>> +Rule 27 (If the algorithm is "philox", shape list length should be equal to 1) +{v_1 : str, v_2 : list(int)} |= if v_1 = "philox" then v_2.len = 1 +>> +Rule 28 (The dtype must be int8, int16, int32, int64, uint8, float16, float32, float64, complex64, complex128) +{v_1 : dtype} |= v_1 = 1 ∨ v_1 = 2 ∨ v_1 = 3 ∨ v_1 = 4 ∨ v_1 = 5 ∨ v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 ∨ v_1 = 9 ∨ v_1 = 10 +>> +Rule 29 (If shape list is provided, dtype should not be bool or string) +{v_1 : list(int), v_2 : dtype} |= if v_1.len > 0 then v_2 ≠ 0 ∧ v_2 ≠ 11 +>> +Rule 30 (The initial state string length has to correspond to number of elements if "rbg" is the selected generator) +{v_1 : str, v_2: str, v_3 : list(int)} |= if v_1 = "rbg" then v_2.len = v_3[0] * 2 +>> +Rule 31 (If algorithm is rbg and initial state is provided, the length of the initial state has to be exactly twice the first dimension in shape list.) +{v_1 : str, v_2 : str, v_3 : list(int)} |= if v_1 = "rbg" ∧ v_3.len > 0 then v_2.len = 2 * v_3[0] +>> +Rule 32 (if the algorithm is "rbg" and the shape list has more than 1 element then this is an error) +{v_1 : str, v_2 : list(int)} |= if v_1 = "rbg" then v_2.len ≤ 1 +>> +Rule 33 (If the algorithm is "rbg" and shape list is not empty, then dtype can only be np.uint32 or np.uint64) +{v_1 : str, v_2 : list(int), v_3 : dtype} |= if v_1 = "rbg" ∧ v_2.len > 0 then v_3 = 3 ∨ v_3 = 4 +>> +Rule 34 (if the algorithm is "rbg" and the shape list is empty, the dtype must be specified.) +{v_1 : str, v_2 : list(int), v_3 : dtype} |= if v_1 = "rbg" ∧ v_2.len = 0 then v_3 ≠ 12 +>> +Rule 35 (If initial state is not 'default', the algorithm cannot be 'default') +{v_1 : str, v_2 : str} |= if v_2 ≠ "default" then v_1 ≠ "default" +>> +Rule 36 (If dtype is complex64 or complex128, shape must be specified) +{v_1 : dtype, v_2 : list(int)} |= if v_1 = 9 ∨ v_1 = 10 then v_2.len > 0 +>> +Rule 40 (If the shape list is empty, the algorithm cannot be "threefry" or "philox") +{v_1 : str, v_2 : list(int)} |= if v_2.len = 0 then v_1 ≠ "threefry" ∧ v_1 ≠ "philox" +>> +Rule 41 (if algorithm is threefry or philox, the initial state must be 'default') +{v_1 : str, v_2 : str} |= if v_1 = "threefry" ∨ v_1 = "philox" then v_2 = "default" +>> +Rule 42 (If dtype is bool and shape is specified, the first dimension size should be small) +{v_1 : dtype, v_2 : list(int)} |= if v_1 = 0 ∧ v_2.len > 0 then v_2[0] < 256 +>> +Rule 43 (If dtype is bool and shape is specified, the product of the dimensions should be small.) +{v_1 : dtype, v_2 : list(int)} |= if v_1 = 0 ∧ v_2.len > 0 then ∃i ∈ [0, v_2.len - 1] : v_2[i] < 1024 +>> +Rule 44 (if dtype is string, shape must be empty) +{v_1 : dtype, v_2 : list(int)} |= if v_1 = 11 then v_2.len = 0 +>> +Rule 45 (If dtype is dtype and shape is specified, it must not be empty) +{v_1 : dtype, v_2 : list(int)} |= if v_1 = 12 then v_2.len > 0 +>> +Rule 46 (If algorithm is philox or threefry, the shape list length should be one.) +{v_1 : str, v_2 : list(int)} |= if v_1 = "philox" ∨ v_1 = "threefry" then v_2.len = 1 +>> +Rule 47 (If algorithm is neither philox nor threefry, then the initial state should be "default") +{v_1 : str, v_2 : str} |= if v_1 ≠ "philox" ∧ v_1 ≠ "threefry" then v_2 = "default" +>> +Rule 48 (if algorithm is rbg, and shape list is not empty, then first dimension should not exceed 1024) +{v_1 : str, v_2 : list(int)} |= if v_1 = "rbg" ∧ v_2.len > 0 then v_2[0] ≤ 1024 +>> +Rule 49 (If the dtype is specified, then it cannot be string.) +{v_1 : dtype} |= v_1 ≠ 11 +>> +Rule 50 (If the dtype is not specified, and algorithm is rbg, then an error is thrown.) +{v_1 : str, v_2 : dtype} |= if v_1 = "rbg" then v_2 ≠ 12 +>> +Rule 51 (If dtype is complex128, the algorithm should not be threefry or philox.) +{v_1 : dtype, v_2 : str} |= if v_1 = 10 then v_2 ≠ "threefry" ∧ v_2 ≠ "philox" +>> +Rule 52 (If dtype is complex64, the algorithm should not be threefry or philox.) +{v_1 : dtype, v_2 : str} |= if v_1 = 9 then v_2 ≠ "threefry" ∧ v_2 ≠ "philox" +>> +Rule 53 (If the algorithm is rbg, then the shape list can be empty or contain exactly one element.) +{v_1 : str, v_2 : list(int)} |= if v_1 = "rbg" then v_2.len = 0 ∨ v_2.len = 1 +>> +Rule 55 (The initial state length cannot be zero) +{v_1 : str} |= v_1.len > 0 +>> +Rule 57 (if the shape list is empty, then the algorithm can be either rbg or it should not be threefry or philox) +{v_1 : str, v_2 : list(int)} |= if v_2.len = 0 then v_1 = "rbg" ∨ v_1 ≠ "threefry" ∨ v_1 ≠ "philox" +>> +Rule 58 (If algorithm is rbg, and the shape list is empty, dtype should be uint32 or uint64 or should be explicitly specified) +{v_1 : str, v_2 : list(int), v_3 : dtype} |= if v_1 = "rbg" ∧ v_2.len = 0 then v_3 = 3 ∨ v_3 = 4 ∨ v_3 ≠ 12 diff --git a/rules-tf/xla.sort/log-rulegen b/rules-tf/xla.sort/log-rulegen new file mode 100644 index 0000000000..c2dc81def2 --- /dev/null +++ b/rules-tf/xla.sort/log-rulegen @@ -0,0 +1,4024 @@ +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 1 (input tensor must be at least 1-dimensional) +{v_1 : tensor} |= ndim(v_1) ≥ 1 +Token usage: input=1667, output=366, total=2033 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 2 (name must be a valid string) +{v_2 : str} |= v_2 = "ii" ∨ v_2 = "ii->i" ∨ v_2 = "i,j->ij" ∨ v_2 = "bij,bjk->bik" ∨ v_2 = "...ij->...ji" ∨ v_2 = "bn,anm,bm->ba" ∨ v_2 = "none" ∨ v_2 = "sum" ∨ v_2 = "max" ∨ v_2 = "min" ∨ v_2 = "prod" ∨ v_2 = "relu" ∨ v_2 = "tanh" ∨ v_2 = "sigmoid" ∨ v_2 = "softmax" ∨ v_2 = "elu" ∨ v_2 = "selu" ∨ v_2 = "gelu" ∨ v_2 = "swish" ∨ v_2 = "softplus" ∨ v_2 = "linear" ∨ v_2 = "valid" ∨ v_2 = "same" ∨ v_2 = "causal" ∨ v_2 = "channels_last" ∨ v_2 = "channels_first" +Token usage: input=1667, output=366, total=2033 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 3 (input tensor must be of float32 or float64 dtype) +{v_1 : tensor} |= dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 +Token usage: input=1667, output=366, total=2033 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 4 (name cannot be an empty string) +{v_2 : str} |= v_2 ≠ "" +Token usage: input=3415, output=110, total=3525 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 5 (Input tensor dimensions must be less than 5) +{v_1 : tensor} |= ndim(v_1) < 5 +Token usage: input=3415, output=110, total=3525 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 6 (Input tensor must have positive shape) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) - 1] : shape(v_1, i) > 0 +Token usage: input=3415, output=110, total=3525 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 7 (The input tensor cannot have dimension zero.) +{v_1 : tensor} |= ndim(v_1) ≠ 0 +Token usage: input=4987, output=88, total=5075 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 8 (If name is "none", input tensor ndim should be 1.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" then ndim(v_1) = 1 +Token usage: input=4987, output=88, total=5075 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 9 (If name is "sum", "max", "min", or "prod", input tensor should have integer or float type) +{v_1 : tensor, v_2 : str} |= if v_2 = "sum" ∨ v_2 = "max" ∨ v_2 = "min" ∨ v_2 = "prod" then (dtype_(v_1) ≥ 1 ∧ dtype_(v_1) ≤ 9) +Token usage: input=6497, output=105, total=6602 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 10 (If name is "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", or "linear", the input tensor should have a floating-point type) +{v_1 : tensor, v_2 : str} |= if v_2 = "relu" ∨ v_2 = "tanh" ∨ v_2 = "sigmoid" ∨ v_2 = "softmax" ∨ v_2 = "elu" ∨ v_2 = "selu" ∨ v_2 = "gelu" ∨ v_2 = "swish" ∨ v_2 = "softplus" ∨ v_2 = "linear" then (dtype_(v_1) ≥ 6 ∧ dtype_(v_1) ≤ 8) +Token usage: input=7961, output=188, total=8149 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 11 (The input tensor's dtype should be a supported type (1-11 or 6-8)) +{v_1 : tensor} |= (dtype_(v_1) ≥ 1 ∧ dtype_(v_1) ≤ 11) ∨ (dtype_(v_1) ≥ 6 ∧ dtype_(v_1) ≤ 8) +Token usage: input=9550, output=84, total=9634 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 12 (If name is "valid", "same", or "causal", input tensor should have 3 or 4 dimensions) +{v_1 : tensor, v_2 : str} |= if v_2 = "valid" ∨ v_2 = "same" ∨ v_2 = "causal" then (ndim(v_1) = 3 ∨ ndim(v_1) = 4) +Token usage: input=11044, output=99, total=11143 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 13 (If name is "channels_last" or "channels_first", input tensor should have 3 or 4 dimensions) +{v_1 : tensor, v_2 : str} |= if v_2 = "channels_last" ∨ v_2 = "channels_first" then (ndim(v_1) = 3 ∨ ndim(v_1) = 4) +Token usage: input=12597, output=93, total=12690 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 14 (If name is "bij,bjk->bik" or "bn,anm,bm->ba", input tensor should have 3 dimensions) +{v_1 : tensor, v_2 : str} |= if v_2 = "bij,bjk->bik" ∨ v_2 = "bn,anm,bm->ba" then ndim(v_1) = 3 +Token usage: input=14200, output=93, total=14293 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 15 (If name is "...ij->...ji", input tensor should have more than 1 dimension) +{v_1 : tensor, v_2 : str} |= if v_2 = "...ij->...ji" then ndim(v_1) > 1 +Token usage: input=15767, output=64, total=15831 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 16 (If the name is "i,j->ij", input tensor must have exactly two dimensions) +{v_1 : tensor, v_2 : str} |= if v_2 = "i,j->ij" then ndim(v_1) = 2 +Token usage: input=17264, output=65, total=17329 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 17 (If name is "ii" or "ii->i", input tensor can be of any dimension and data type.) +{v_1 : tensor, v_2 : str} |= if v_2 = "ii" ∨ v_2 = "ii->i" then true +Token usage: input=18757, output=67, total=18824 +** REDUNDANT VARIABLES ** (num_failures: 1) + +>>> PROMPT +[Feedback Message from Prior Run] +Redundant variables: {v_1 : tensor, v_2 : str} |= if v_2 = "ii" ∨ v_2 = "ii->i" then true (Unused: v_1) + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 18 (If name is "ii" or "ii->i", no specific constraint is placed on the input tensor.) +{v_2 : str} |= if v_2 = "ii" ∨ v_2 = "ii->i" then true +Token usage: input=20307, output=60, total=20367 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 19 (If name is not in the defined string values, it is invalid.) +{v_2 : str} |= v_2 = "ii" ∨ v_2 = "ii->i" ∨ v_2 = "i,j->ij" ∨ v_2 = "bij,bjk->bik" ∨ v_2 = "...ij->...ji" ∨ v_2 = "bn,anm,bm->ba" ∨ v_2 = "none" ∨ v_2 = "sum" ∨ v_2 = "max" ∨ v_2 = "min" ∨ v_2 = "prod" ∨ v_2 = "relu" ∨ v_2 = "tanh" ∨ v_2 = "sigmoid" ∨ v_2 = "softmax" ∨ v_2 = "elu" ∨ v_2 = "selu" ∨ v_2 = "gelu" ∨ v_2 = "swish" ∨ v_2 = "softplus" ∨ v_2 = "linear" ∨ v_2 = "valid" ∨ v_2 = "same" ∨ v_2 = "causal" ∨ v_2 = "channels_last" ∨ v_2 = "channels_first" +Token usage: input=21723, output=291, total=22014 +** DUPLICATED RULE ** (num_failures: 2) + +>>> PROMPT +[Feedback Message from Prior Run] +Duplicated rule: {v_2 : str} |= v_2 = "ii" ∨ v_2 = "ii->i" ∨ v_2 = "i,j->ij" ∨ v_2 = "bij,bjk->bik" ∨ v_2 = "...ij->...ji" ∨ v_2 = "bn,anm,bm->ba" ∨ v_2 = "none" ∨ v_2 = "sum" ∨ v_2 = "max" ∨ v_2 = "min" ∨ v_2 = "prod" ∨ v_2 = "relu" ∨ v_2 = "tanh" ∨ v_2 = "sigmoid" ∨ v_2 = "softmax" ∨ v_2 = "elu" ∨ v_2 = "selu" ∨ v_2 = "gelu" ∨ v_2 = "swish" ∨ v_2 = "softplus" ∨ v_2 = "linear" ∨ v_2 = "valid" ∨ v_2 = "same" ∨ v_2 = "causal" ∨ v_2 = "channels_last" ∨ v_2 = "channels_first" + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 20 (Input tensor must not be of boolean type.) +{v_1 : tensor} |= dtype_(v_1) ≠ 0 +Token usage: input=23810, output=104, total=23914 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 21 (If input tensor is complex, the name parameter is not allowed to be relu, tanh, sigmoid, softmax, elu, selu, gelu, swish, softplus, linear) +{v_1 : tensor, v_2 : str} |= if (dtype_(v_1) = 9) ∨ (dtype_(v_1) = 10) then v_2 ≠ "relu" ∧ v_2 ≠ "tanh" ∧ v_2 ≠ "sigmoid" ∧ v_2 ≠ "softmax" ∧ v_2 ≠ "elu" ∧ v_2 ≠ "selu" ∧ v_2 ≠ "gelu" ∧ v_2 ≠ "swish" ∧ v_2 ≠ "softplus" ∧ v_2 ≠ "linear" +Token usage: input=25401, output=182, total=25583 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 22 (If input tensor is complex, the name parameter is not allowed to be valid, same, causal, channels_last, channels_first) +{v_1 : tensor, v_2 : str} |= if (dtype_(v_1) = 9) ∨ (dtype_(v_1) = 10) then v_2 ≠ "valid" ∧ v_2 ≠ "same" ∧ v_2 ≠ "causal" ∧ v_2 ≠ "channels_last" ∧ v_2 ≠ "channels_first" +Token usage: input=26977, output=127, total=27104 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 23 (If input tensor is complex, the name parameter is not allowed to be sum, max, min, prod) +{v_1 : tensor, v_2 : str} |= if (dtype_(v_1) = 9) ∨ (dtype_(v_1) = 10) then v_2 ≠ "sum" ∧ v_2 ≠ "max" ∧ v_2 ≠ "min" ∧ v_2 ≠ "prod" +Token usage: input=28480, output=107, total=28587 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 24 (If dtype is string, name must be 'none') +{v_1: tensor, v_2: str} |= if dtype_(v_1) = 11 then v_2 = "none" +Token usage: input=30115, output=53, total=30168 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 25 (If input tensor has bool dtype, name must be 'none') +{v_1: tensor, v_2: str} |= if dtype_(v_1) = 0 then v_2 = "none" +Token usage: input=31585, output=54, total=31639 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 25 (tensor shape matches given tuple shape) +{v_1 : tensor, v_2 : tuple(int)} |= ndim(v_1) = v_2.len ∧ ∀i ∈ [0, v_2.len - 1] : shape(v_1, i) = v_2[i] + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 26 (If name is 'none', input tensor can have arbitrary shape and dtype) +{v_1: tensor, v_2: str} |= if v_2 = "none" then true +Token usage: input=33075, output=48, total=33123 +** REDUNDANT VARIABLES ** (num_failures: 3) + +>>> PROMPT +[Feedback Message from Prior Run] +Redundant variables: {v_1: tensor, v_2: str} |= if v_2 = "none" then true (Unused: v_1) + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 27 (If name is 'none', no requirements exist) +{v_2 : str} |= if v_2 = "none" then true +Token usage: input=34700, output=37, total=34737 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 28 (If name is 'none', there are no shape restrictions on input) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" then true +Token usage: input=36139, output=82, total=36221 +** REDUNDANT VARIABLES ** (num_failures: 4) + +>>> PROMPT +[Feedback Message from Prior Run] +Redundant variables: {v_1 : tensor, v_2 : str} |= if v_2 = "none" then true (Unused: v_1) + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +Rule 1 (tensor shapes should be the same) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = shape(v_2, i) + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 29 (If the input tensor has more than 2 dimensions, and the name is equal to 'none' there are no constraints.) +{v_1 : tensor, v_2 : str} |= if ndim(v_1) > 2 ∧ v_2 = "none" then true +Token usage: input=37628, output=261, total=37889 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +The problem remains. + +I'm forced to conclude that, given the information available (just the API signature and the limited string list), I've exhausted the possibilities for defining *new* and *meaningful* rules that are not tautologies or duplicates. + +The core issue is the disconnect between the *name* string and any *properties of the input tensor*. The strings seem to act as flags to select different sorting methods or pre/post-processing steps, but without knowing what those steps are or how they relate to the tensor's data, I can't formulate any substantive rules. +Token usage: input=39306, output=123, total=39429 +** FORMAT ERROR ** (num_failures: 5) + +>>> PROMPT +[Feedback Message from Prior Run] +No valid rules detected. Please follow the expected output format for each rule. + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Given the constraints and repeated failures, I have tried several rules, but none seem to fulfill the requirements adequately. I am stopping here due to the limited information about the API behavior and the repetitive nature of the errors. +Token usage: input=40837, output=44, total=40881 +** FORMAT ERROR ** (num_failures: 6) + +>>> PROMPT +[Feedback Message from Prior Run] +No valid rules detected. Please follow the expected output format for each rule. + +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 32 (Integer indices only valid with int-compatible dtype) +{v_1 : tuple(int), v_2 : dtype} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] ≥ 0 ∧ v_2 = 1 ∨ v_2 = 2 ∨ v_2 = 3 ∨ v_2 = 4 ∨ v_2 = 5 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 30 (If name is not "none", the tensor must have at least one element) +{v_1 : tensor, v_2 : str} |= if v_2 ≠ "none" then (∃i ∈ [0, ndim(v_1) - 1] : shape(v_1, i) > 0) +Token usage: input=42318, output=140, total=42458 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 31 (If name is not "none", then the input tensor's dtype cannot be a np.dtype) +{v_1 : tensor, v_2 : str} |= if v_2 ≠ "none" then dtype_(v_1) ≠ 12 +Token usage: input=43917, output=63, total=43980 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 32 (If input tensor's dtype is string and name is "none" then the shape must be one-dimensional) +{v_1: tensor, v_2: str} |= if dtype_(v_1) = 11 ∧ v_2 = "none" then ndim(v_1) = 1 +Token usage: input=45339, output=77, total=45416 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 23 (3-dimensional tensor with all positive shape dimensions) +{v_1 : tensor} |= ndim(v_1) = 3 ∧ ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 9 (4D tensor with all shape dimensions positive) +{v_1 : tensor} |= ndim(v_1) = 4 ∧ ∀i ∈ [0, 3] : shape(v_1, i) > 0 + +Rule 21 (primitive type variable should not be zero) +{v_1 : int ⊎ float} |= v_1 ≠ 0 + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 33 (If input tensor's dtype is a np.dtype, and name is "none" then the shape must be one-dimensional) +{v_1: tensor, v_2: str} |= if dtype_(v_1) = 12 ∧ v_2 = "none" then ndim(v_1) = 1 +Token usage: input=46755, output=81, total=46836 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 4 (tensor data types should match) +{v_1 : tensor, v_2 : tensor} |= dtype(v_1) = dtype(v_2) + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 28 (list of ints used as dimensions/axes, all non-negative and valid for tensor shape) +{v_1 : tensor, v_2 : list(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 6 (last dimension of a tensor matches first dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 34 (If the name is equal to 'none' and dtype is in [int8, int16, int32, int64, uint8] then the number of dimensions should be 1.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ (dtype_(v_1) = 1 ∨ dtype_(v_1) = 2 ∨ dtype_(v_1) = 3 ∨ dtype_(v_1) = 4 ∨ dtype_(v_1) = 5) then ndim(v_1) = 1 +Token usage: input=48465, output=144, total=48609 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 35 (If the name is equal to 'none' and dtype is in [float16, float32, float64] then the number of dimensions should be 1.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ (dtype_(v_1) = 6 ∨ dtype_(v_1) = 7 ∨ dtype_(v_1) = 8) then ndim(v_1) = 1 +Token usage: input=50132, output=116, total=50248 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 36 (If the name is equal to 'none' and dtype is in [complex64, complex128] then the number of dimensions should be 1.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ (dtype_(v_1) = 9 ∨ dtype_(v_1) = 10) then ndim(v_1) = 1 +Token usage: input=51594, output=103, total=51697 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 18 (input tensor is empty or only contains non-negative values) +{v_1 : tensor} |= (∃i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) = 0) ∨ min(v_1) ≥ 0 + +Rule 15 (broadcasting compatibility for tensor shapes) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) > 0 ∧ ndim(v_2) > 0 ∧ ∀i ∈ [0, if ndim(v_1) ≥ ndim(v_2) then ndim(v_1) − 1 else ndim(v_2) − 1] : ndim(v_1) − i − 1 < 0 ∨ ndim(v_2) − i − 1 < 0 ∨ shape(v_1, ndim(v_1) − i − 1) = 1 ∨ shape(v_2, ndim(v_2) − i − 1) = 1 ∨ shape(v_1, ndim(v_1) − i − 1) = shape(v_2, ndim(v_2) − i − 1) + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 27 (reduction over valid dimensions) +{v_1 : tensor, v_2 : tuple(int)} |= ∀i ∈ [0, v_2.len - 1] : 0 ≤ v_2[i] ∧ v_2[i] < ndim(v_1) + +Rule 3 (input tensors must have the same number of dimensions) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) = ndim(v_2) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 37 (If the name is equal to 'none' and dtype is bool then the number of dimensions should be 1.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ (dtype_(v_1) = 0) then ndim(v_1) = 1 +Token usage: input=53262, output=81, total=53343 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 30 (list of bools for masking or selection) +{v_1 : tensor, v_2 : list(bool)} |= v_2.len = shape(v_1, 0) + +Rule 19 (compatibility of integer or float (data) type tensor and variable) +{v1 : tensor, v2 : int ⊎ float} |= if 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 then 1 ≤ v2 ∧ v2 ≤ 5 else if 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 then 1 ≤ v2 ∧ v2 ≤ 8 else false + +Rule 11 (index tensor (v_3) is within the input tensor along the specified dimension) +{v_1 : tensor, v_2 : int, v_3 : tensor} |= min(v_3) ≥ 0 ∧ max(v_3) ≤ shape(v_1, v_2) − 1 + +Rule 7 (first dimension of a tensor matches second dimension of the other) +{v_1 : tensor, v_2 : tensor} |= ndim(v_1) ≥ 1 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, 0) = shape(v_2, 1) + +Rule 16 (shape alignment for matrix multiplication) +{v_1 : tensor, v_2 : tensor} |= (ndim(v_1) ≥ 2 ∧ ndim(v_2) ≥ 2 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, ndim(v_2) − 2)) ∨ (ndim(v_1) ≥ 2 ∧ ndim(v_2) = 1 ∧ shape(v_1, ndim(v_1) − 1) = shape(v_2, 0)) + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 38 (If the name is equal to 'none' and dtype is uint8 then the number of dimensions should be 1.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ (dtype_(v_1) = 5) then ndim(v_1) = 1 +Token usage: input=54884, output=82, total=54966 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 10 (valid 2D transposed convolution) +{v_1 : tensor, v_2 : tensor, v_3 : int, v_4 : int} |= ndim(v_1) = 4 ∧ ndim(v_2) = 4 ∧ v_3 ≥ 1 ∧ v_4 ≥ 0 ∧ v_3 × (shape(v_1, 2) − 1) + shape(v_2, 2) − 2 × v_4 > 0 ∧ v_3 × (shape(v_1, 3) − 1) + shape(v_2, 3) − 2 × v_4 > 0 + +Rule 31 (dtype must be a floating-point type) +{v_1 : dtype} |= v_1 = 6 ∨ v_1 = 7 ∨ v_1 = 8 + +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 24 (tuple of ints represents valid shape dimensions) +{v_1 : tuple(int)} |= ∀i ∈ [0, v_1.len - 1] : v_1[i] > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 39 (If name is equal to 'none' and dtype is np.dtype then the number of dimensions should be greater than 0.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ (dtype_(v_1) = 12) then ndim(v_1) > 0 +Token usage: input=56431, output=85, total=56516 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 29 (list of floats for weights must match length of a tensor dimension) +{v_1 : tensor, v_2 : list(float)} |= v_2.len = shape(v_1, 0) ∧ ∀i ∈ [0, v_2.len - 1] : v_2[i] ≥ 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +Rule 8 (tensor must have an integer dtype: 1–5) +{v1: tensor} |= 1 ≤ dtype(v1) ∧ dtype(v1) ≤ 5 + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 40 (If the name is equal to 'none' then the minimum value of the tensor must be smaller than or equal to the maximum value of the tensor.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" then min(v_1) ≤ max(v_1) +Token usage: input=57925, output=78, total=58003 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 20 (input tensor must be 1-dimensional) +{v_1 : tensor} |= ndim(v_1) = 1 + +Rule 22 (valid step size for a range) +{v_1 : int ⊎ float, v_2 : int ⊎ float, v_3 : int ⊎ float} |= if v_1 > 0 then v_2 ≤ v_3 else if v_1 < 0 then v_2 ≥ v_3 else true + +Rule 26 (tuple of ints used as kernel size must have length 2) +{v_1 : tuple(int)} |= v_1.len = 2 ∧ ∀i ∈ [0, 1] : v_1[i] > 0 + +Rule 14 (tensor should not be empty) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) − 1] : shape(v_1, i) > 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 41 (If the name is equal to 'none' then all values of a bool tensor must be either all true or all false ) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ dtype_(v_1) = 0 then (∀i ∈ [0, shape(v_1, 0) - 1] : v_1[i] = true) ∨ (∀i ∈ [0, shape(v_1, 0) - 1] : v_1[i] = false) +Token usage: input=59375, output=133, total=59508 +** SUCCESS ** + +>>> PROMPT +[Rule Grammar in EBNF Notation] + ::= "{" "}" "|=" + + ::= ("," )* + ::= ":" + + ::= "tensor" + | "int" + | "float" + | "bool" + | "dtype" + | "str" + | "list" "(" ")" + | "tuple" "(" ")" + | "⊎" + + ::= + ::= | "∧" + ::= | "∨" + ::= "∀" "∈" "[" "," "]" ":" + | "∃" "∈" "[" "," "]" ":" + | + | + + ::= "if" "then" [ "else" ] + ::= | + ::= | + ::= | + ::= | | | | "(" ")" + + ::= "[" "]" | ".len" + ::= "(" [ "," ] ")" + ::= | "true" | "false" | + ::= "=" | "≠" | ">" | "<" | "≥" | "≤" + ::= "+" | "-" + ::= "*" | "/" | "%" + ::= "ndim" | "shape" | "dtype_" | "min" | "max" + ::= any variable name (e.g., matches [a-zA-Z_][a-zA-Z_0-9]*) + ::= same format as PRIMVAR + ::= same format as PRIMVAR + + ::= same format as PRIMVAR + ::= any integer or decimal number (e.g., -5, 0.3, +7) + ::= any quoted string (e.g., "hello", 'world') + +[Task Description] +Define rules that xla.sort API parameters should satisfy. Refer to the API documentation. + +Type is encoded as an integer (index of the following list): +[bool, np.int8, np.int16, np.int32, np.int64, np.uint8, np.float16, np.float32, np.float64, np.complex64, np.complex128, str, np.dtype] + +String value should be selected from the following list: +["ii", "ii->i", "i,j->ij", "bij,bjk->bik", "...ij->...ji", "bn,anm,bm->ba", "none", "sum", "max", "min", "prod", "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", "linear", "valid", "same", "causal", "channels_last", "channels_first"] + +[API Signature] input: tensor, name: string + +[Output Format] +Rule {Number} ({Description})\n{Rule Definition} +Ex) Rule 21 (primitive type variable should not be zero) + {v_1 : int ⊎ float} |= v_1 ≠ 0 + +[Example Rules] +Rule 2 (v_2 should be a valid dimension of input tensor) +{v_1 : tensor, v_2 : int} |= −1 × ndim(v_1) ≤ v_2 ∧ v_2 ≤ ndim(v_1) − 1 + +Rule 5 (index tensor (v_2) should be within the range of input tensor) +{v_1 : tensor, v_2 : tensor} |= min(v_2) ≥ 0 ∧ ∀i ∈ [0, ndim(v_1) − 1] : max(v_2) ≤ shape(v_1, i) − 1 + +Rule 12 (a primitive type variable is smaller than the other) +{v_1 : int ⊎ float, v_2 : int ⊎ float} |= v_1 ≤ v_2 + +Rule 17 (primitive type variable must be non-negative) +{v_1 : int ⊎ float} |= v_1 ≥ 0 + +Rule 13 (tensor must have a floating-point dtype: 6–8) +{v1: tensor} |= 6 ≤ dtype(v1) ∧ dtype(v1) ≤ 8 + +** IMPORTANT: The rule definition should be a new one and strictly follow the grammar. ** +** IMPORTANT: Rules should span diverse types (tensor, int, float, bool, dtype, str, tuple, list, union), properties, and numbers of parameters. ** +** IMPORTANT: Variables should be named v_1, v_2, and so on. ** +** IMPORTANT: Bindings should be API parameters and include only variables that are used in the expression. ** +** IMPORTANT: Rules should comply with API signature(s). If there are multiple, cover all signatures with diverse rules. ** +** IMPORTANT: For module classes returning instances, include rules for their parameters. ** + +<<< RESPONSE +Rule 42 (If the name is equal to 'none' then the tensor should not have any NaN values) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" then ∃i ∈ [0, ndim(v_1) - 1] : shape(v_1, i) ≥ 0 +Token usage: input=60883, output=84, total=60967 +** SUCCESS ** + diff --git a/rules-tf/xla.sort/rule_1.py b/rules-tf/xla.sort/rule_1.py new file mode 100644 index 0000000000..4b30c33367 --- /dev/null +++ b/rules-tf/xla.sort/rule_1.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# input tensor must be at least 1-dimensional (Rule 1) + +rule_1 = lambda s, v, n=False: ( + s.add(Not(v["arg1_ndim"] >= 1) if n else + v["arg1_ndim"] >= 1) +) + +def rule_1_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + + # Constraints for rule 1 + rule_1(solver, {'arg1_ndim': arg1_ndim}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_1(solver, {'arg1_ndim': arg1['ndim']}, neg) diff --git a/rules-tf/xla.sort/rule_10.py b/rules-tf/xla.sort/rule_10.py new file mode 100644 index 0000000000..2c2a3271bc --- /dev/null +++ b/rules-tf/xla.sort/rule_10.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If name is "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", or "linear", the input tensor should have a floating-point type (Rule 10) + +rule_10 = lambda s, v, n=False: ( + s.add(Not(If(Or(Or(Or(Or(Or(Or(Or(Or(Or(v["arg2_value"] == 11, v["arg2_value"] == 12), v["arg2_value"] == 13), v["arg2_value"] == 14), v["arg2_value"] == 15), v["arg2_value"] == 16), v["arg2_value"] == 17), v["arg2_value"] == 18), v["arg2_value"] == 19), v["arg2_value"] == 20), (And(v["arg1_dtype"] >= 6, v["arg1_dtype"] <= 8)), True)) if n else + If(Or(Or(Or(Or(Or(Or(Or(Or(Or(v["arg2_value"] == 11, v["arg2_value"] == 12), v["arg2_value"] == 13), v["arg2_value"] == 14), v["arg2_value"] == 15), v["arg2_value"] == 16), v["arg2_value"] == 17), v["arg2_value"] == 18), v["arg2_value"] == 19), v["arg2_value"] == 20), (And(v["arg1_dtype"] >= 6, v["arg1_dtype"] <= 8)), True)) +) + +def rule_10_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 10 + rule_10(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_10(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_11.py b/rules-tf/xla.sort/rule_11.py new file mode 100644 index 0000000000..92bf3dcff8 --- /dev/null +++ b/rules-tf/xla.sort/rule_11.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# The input tensor's dtype should be a supported type (1-11 or 6-8 (Rule 11) + +rule_11 = lambda s, v, n=False: ( + s.add(Not(Or((And(v["arg1_dtype"] >= 1, v["arg1_dtype"] <= 11)), (And(v["arg1_dtype"] >= 6, v["arg1_dtype"] <= 8)))) if n else + Or((And(v["arg1_dtype"] >= 1, v["arg1_dtype"] <= 11)), (And(v["arg1_dtype"] >= 6, v["arg1_dtype"] <= 8)))) +) + +def rule_11_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + + # Constraints for rule 11 + rule_11(solver, {'arg1_dtype': arg1_dtype}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_11(solver, {'arg1_dtype': arg1['dtype']}, neg) diff --git a/rules-tf/xla.sort/rule_12.py b/rules-tf/xla.sort/rule_12.py new file mode 100644 index 0000000000..96ceb61d5b --- /dev/null +++ b/rules-tf/xla.sort/rule_12.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If name is "valid", "same", or "causal", input tensor should have 3 or 4 dimensions (Rule 12) + +rule_12 = lambda s, v, n=False: ( + s.add(Not(If(Or(Or(v["arg2_value"] == 21, v["arg2_value"] == 22), v["arg2_value"] == 23), (Or(v["arg1_ndim"] == 3, v["arg1_ndim"] == 4)), True)) if n else + If(Or(Or(v["arg2_value"] == 21, v["arg2_value"] == 22), v["arg2_value"] == 23), (Or(v["arg1_ndim"] == 3, v["arg1_ndim"] == 4)), True)) +) + +def rule_12_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 12 + rule_12(solver, {'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_12(solver, {'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_13.py b/rules-tf/xla.sort/rule_13.py new file mode 100644 index 0000000000..5dc85c356e --- /dev/null +++ b/rules-tf/xla.sort/rule_13.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If name is "channels_last" or "channels_first", input tensor should have 3 or 4 dimensions (Rule 13) + +rule_13 = lambda s, v, n=False: ( + s.add(Not(If(Or(v["arg2_value"] == 24, v["arg2_value"] == 25), (Or(v["arg1_ndim"] == 3, v["arg1_ndim"] == 4)), True)) if n else + If(Or(v["arg2_value"] == 24, v["arg2_value"] == 25), (Or(v["arg1_ndim"] == 3, v["arg1_ndim"] == 4)), True)) +) + +def rule_13_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 13 + rule_13(solver, {'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_13(solver, {'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_14.py b/rules-tf/xla.sort/rule_14.py new file mode 100644 index 0000000000..21dbb460b8 --- /dev/null +++ b/rules-tf/xla.sort/rule_14.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If name is "bij,bjk->bik" or "bn,anm,bm->ba", input tensor should have 3 dimensions (Rule 14) + +rule_14 = lambda s, v, n=False: ( + s.add(Not(If(Or(v["arg2_value"] == 3, v["arg2_value"] == 5), v["arg1_ndim"] == 3, True)) if n else + If(Or(v["arg2_value"] == 3, v["arg2_value"] == 5), v["arg1_ndim"] == 3, True)) +) + +def rule_14_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 14 + rule_14(solver, {'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_14(solver, {'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_15.py b/rules-tf/xla.sort/rule_15.py new file mode 100644 index 0000000000..b318ff3c74 --- /dev/null +++ b/rules-tf/xla.sort/rule_15.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If name is "...ij->...ji", input tensor should have more than 1 dimension (Rule 15) + +rule_15 = lambda s, v, n=False: ( + s.add(Not(If(v["arg2_value"] == 4, v["arg1_ndim"] > 1, True)) if n else + If(v["arg2_value"] == 4, v["arg1_ndim"] > 1, True)) +) + +def rule_15_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 15 + rule_15(solver, {'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_15(solver, {'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_16.py b/rules-tf/xla.sort/rule_16.py new file mode 100644 index 0000000000..9983dbd47d --- /dev/null +++ b/rules-tf/xla.sort/rule_16.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the name is "i,j->ij", input tensor must have exactly two dimensions (Rule 16) + +rule_16 = lambda s, v, n=False: ( + s.add(Not(If(v["arg2_value"] == 2, v["arg1_ndim"] == 2, True)) if n else + If(v["arg2_value"] == 2, v["arg1_ndim"] == 2, True)) +) + +def rule_16_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 16 + rule_16(solver, {'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_16(solver, {'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_18.py b/rules-tf/xla.sort/rule_18.py new file mode 100644 index 0000000000..2d654cad60 --- /dev/null +++ b/rules-tf/xla.sort/rule_18.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If name is "ii" or "ii->i", no specific constraint is placed on the input tensor. (Rule 18) + +rule_18 = lambda s, v, n=False: ( + s.add(Not(If(Or(v["arg1_value"] == 0, v["arg1_value"] == 1), True, True)) if n else + If(Or(v["arg1_value"] == 0, v["arg1_value"] == 1), True, True)) +) + +def rule_18_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, str): + return False + + # Variable declarations + solver = Solver() + arg1_value = String('arg1_value') + + # Value assignments + solver.add(arg1_value == list_of_string_values_tf.index(arg1)) + + # Constraints for rule 18 + rule_18(solver, {'arg1_value': arg1_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_18(solver, {'arg1_value': arg1['value']}, neg) diff --git a/rules-tf/xla.sort/rule_2.py b/rules-tf/xla.sort/rule_2.py new file mode 100644 index 0000000000..cb8b53f0c0 --- /dev/null +++ b/rules-tf/xla.sort/rule_2.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# name must be a valid string (Rule 2) + +rule_2 = lambda s, v, n=False: ( + s.add(Not(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(v["arg1_value"] == 0, v["arg1_value"] == 1), v["arg1_value"] == 2), v["arg1_value"] == 3), v["arg1_value"] == 4), v["arg1_value"] == 5), v["arg1_value"] == 6), v["arg1_value"] == 7), v["arg1_value"] == 8), v["arg1_value"] == 9), v["arg1_value"] == 10), v["arg1_value"] == 11), v["arg1_value"] == 12), v["arg1_value"] == 13), v["arg1_value"] == 14), v["arg1_value"] == 15), v["arg1_value"] == 16), v["arg1_value"] == 17), v["arg1_value"] == 18), v["arg1_value"] == 19), v["arg1_value"] == 20), v["arg1_value"] == 21), v["arg1_value"] == 22), v["arg1_value"] == 23), v["arg1_value"] == 24), v["arg1_value"] == 25)) if n else + Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(Or(v["arg1_value"] == 0, v["arg1_value"] == 1), v["arg1_value"] == 2), v["arg1_value"] == 3), v["arg1_value"] == 4), v["arg1_value"] == 5), v["arg1_value"] == 6), v["arg1_value"] == 7), v["arg1_value"] == 8), v["arg1_value"] == 9), v["arg1_value"] == 10), v["arg1_value"] == 11), v["arg1_value"] == 12), v["arg1_value"] == 13), v["arg1_value"] == 14), v["arg1_value"] == 15), v["arg1_value"] == 16), v["arg1_value"] == 17), v["arg1_value"] == 18), v["arg1_value"] == 19), v["arg1_value"] == 20), v["arg1_value"] == 21), v["arg1_value"] == 22), v["arg1_value"] == 23), v["arg1_value"] == 24), v["arg1_value"] == 25)) +) + +def rule_2_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, str): + return False + + # Variable declarations + solver = Solver() + arg1_value = String('arg1_value') + + # Value assignments + solver.add(arg1_value == list_of_string_values_tf.index(arg1)) + + # Constraints for rule 2 + rule_2(solver, {'arg1_value': arg1_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_2(solver, {'arg1_value': arg1['value']}, neg) diff --git a/rules-tf/xla.sort/rule_20.py b/rules-tf/xla.sort/rule_20.py new file mode 100644 index 0000000000..58be61baf6 --- /dev/null +++ b/rules-tf/xla.sort/rule_20.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# Input tensor must not be of boolean type. (Rule 20) + +rule_20 = lambda s, v, n=False: ( + s.add(Not(v["arg1_dtype"] != 0) if n else + v["arg1_dtype"] != 0) +) + +def rule_20_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + + # Constraints for rule 20 + rule_20(solver, {'arg1_dtype': arg1_dtype}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_20(solver, {'arg1_dtype': arg1['dtype']}, neg) diff --git a/rules-tf/xla.sort/rule_21.py b/rules-tf/xla.sort/rule_21.py new file mode 100644 index 0000000000..c23e3c00eb --- /dev/null +++ b/rules-tf/xla.sort/rule_21.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If input tensor is complex, the name parameter is not allowed to be relu, tanh, sigmoid, softmax, elu, selu, gelu, swish, softplus, linear (Rule 21) + +rule_21 = lambda s, v, n=False: ( + s.add(Not(If(Or((v["arg1_dtype"] == 9), (v["arg1_dtype"] == 10)), And(And(And(And(And(And(And(And(And(v["arg2_value"] != 11, v["arg2_value"] != 12), v["arg2_value"] != 13), v["arg2_value"] != 14), v["arg2_value"] != 15), v["arg2_value"] != 16), v["arg2_value"] != 17), v["arg2_value"] != 18), v["arg2_value"] != 19), v["arg2_value"] != 20), True)) if n else + If(Or((v["arg1_dtype"] == 9), (v["arg1_dtype"] == 10)), And(And(And(And(And(And(And(And(And(v["arg2_value"] != 11, v["arg2_value"] != 12), v["arg2_value"] != 13), v["arg2_value"] != 14), v["arg2_value"] != 15), v["arg2_value"] != 16), v["arg2_value"] != 17), v["arg2_value"] != 18), v["arg2_value"] != 19), v["arg2_value"] != 20), True)) +) + +def rule_21_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 21 + rule_21(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_21(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_22.py b/rules-tf/xla.sort/rule_22.py new file mode 100644 index 0000000000..2710a06d57 --- /dev/null +++ b/rules-tf/xla.sort/rule_22.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If input tensor is complex, the name parameter is not allowed to be valid, same, causal, channels_last, channels_first (Rule 22) + +rule_22 = lambda s, v, n=False: ( + s.add(Not(If(Or((v["arg1_dtype"] == 9), (v["arg1_dtype"] == 10)), And(And(And(And(v["arg2_value"] != 21, v["arg2_value"] != 22), v["arg2_value"] != 23), v["arg2_value"] != 24), v["arg2_value"] != 25), True)) if n else + If(Or((v["arg1_dtype"] == 9), (v["arg1_dtype"] == 10)), And(And(And(And(v["arg2_value"] != 21, v["arg2_value"] != 22), v["arg2_value"] != 23), v["arg2_value"] != 24), v["arg2_value"] != 25), True)) +) + +def rule_22_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 22 + rule_22(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_22(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_23.py b/rules-tf/xla.sort/rule_23.py new file mode 100644 index 0000000000..5e23a0f562 --- /dev/null +++ b/rules-tf/xla.sort/rule_23.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If input tensor is complex, the name parameter is not allowed to be sum, max, min, prod (Rule 23) + +rule_23 = lambda s, v, n=False: ( + s.add(Not(If(Or((v["arg1_dtype"] == 9), (v["arg1_dtype"] == 10)), And(And(And(v["arg2_value"] != 7, v["arg2_value"] != 8), v["arg2_value"] != 9), v["arg2_value"] != 10), True)) if n else + If(Or((v["arg1_dtype"] == 9), (v["arg1_dtype"] == 10)), And(And(And(v["arg2_value"] != 7, v["arg2_value"] != 8), v["arg2_value"] != 9), v["arg2_value"] != 10), True)) +) + +def rule_23_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 23 + rule_23(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_23(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_24.py b/rules-tf/xla.sort/rule_24.py new file mode 100644 index 0000000000..25ee559f82 --- /dev/null +++ b/rules-tf/xla.sort/rule_24.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If dtype is string, name must be 'none' (Rule 24) + +rule_24 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 11, v["arg2_value"] == 6, True)) if n else + If(v["arg1_dtype"] == 11, v["arg2_value"] == 6, True)) +) + +def rule_24_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 24 + rule_24(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_24(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_25.py b/rules-tf/xla.sort/rule_25.py new file mode 100644 index 0000000000..ba1b7e8d21 --- /dev/null +++ b/rules-tf/xla.sort/rule_25.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If input tensor has bool dtype, name must be 'none' (Rule 25) + +rule_25 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_dtype"] == 0, v["arg2_value"] == 6, True)) if n else + If(v["arg1_dtype"] == 0, v["arg2_value"] == 6, True)) +) + +def rule_25_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 25 + rule_25(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_25(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_27.py b/rules-tf/xla.sort/rule_27.py new file mode 100644 index 0000000000..f2276373a8 --- /dev/null +++ b/rules-tf/xla.sort/rule_27.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If name is 'none', no requirements exist (Rule 27) + +rule_27 = lambda s, v, n=False: ( + s.add(Not(If(v["arg1_value"] == 6, True, True)) if n else + If(v["arg1_value"] == 6, True, True)) +) + +def rule_27_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, str): + return False + + # Variable declarations + solver = Solver() + arg1_value = String('arg1_value') + + # Value assignments + solver.add(arg1_value == list_of_string_values_tf.index(arg1)) + + # Constraints for rule 27 + rule_27(solver, {'arg1_value': arg1_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_27(solver, {'arg1_value': arg1['value']}, neg) diff --git a/rules-tf/xla.sort/rule_29.py b/rules-tf/xla.sort/rule_29.py new file mode 100644 index 0000000000..d942c03ef9 --- /dev/null +++ b/rules-tf/xla.sort/rule_29.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the input tensor has more than 2 dimensions, and the name is equal to 'none' there are no constraints. (Rule 29) + +rule_29 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg1_ndim"] > 2, v["arg2_value"] == 6), True, True)) if n else + If(And(v["arg1_ndim"] > 2, v["arg2_value"] == 6), True, True)) +) + +def rule_29_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 29 + rule_29(solver, {'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_29(solver, {'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_3.py b/rules-tf/xla.sort/rule_3.py new file mode 100644 index 0000000000..29c9b437e7 --- /dev/null +++ b/rules-tf/xla.sort/rule_3.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# input tensor must be of float32 or float64 dtype (Rule 3) + +rule_3 = lambda s, v, n=False: ( + s.add(Not(Or(v["arg1_dtype"] == 7, v["arg1_dtype"] == 8)) if n else + Or(v["arg1_dtype"] == 7, v["arg1_dtype"] == 8)) +) + +def rule_3_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + + # Constraints for rule 3 + rule_3(solver, {'arg1_dtype': arg1_dtype}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_3(solver, {'arg1_dtype': arg1['dtype']}, neg) diff --git a/rules-tf/xla.sort/rule_30.py b/rules-tf/xla.sort/rule_30.py new file mode 100644 index 0000000000..f478e2356f --- /dev/null +++ b/rules-tf/xla.sort/rule_30.py @@ -0,0 +1,44 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If name is not "none", the tensor must have at least one element (Rule 30) + +rule_30 = lambda s, v, n=False: ( + s.add(Not(If(v["arg2_value"] != 6, (Or([And(i < (v["arg1_ndim"] - 1 + 1), Select(v["arg1_shape"], i) > 0) for i in range(6)])), True)) if n else + If(v["arg2_value"] != 6, (Or([And(i < (v["arg1_ndim"] - 1 + 1), Select(v["arg1_shape"], i) > 0) for i in range(6)])), True)) +) + +def rule_30_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg1_shape = Array('arg1_shape', IntSort(), IntSort()) + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + for i in range(arg1.ndim): + arg1_shape = Store(arg1_shape, i, arg1.shape[i]) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 30 + rule_30(solver, {'arg1_ndim': arg1_ndim, 'arg1_shape': arg1_shape, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_30(solver, {'arg1_ndim': arg1['ndim'], 'arg1_shape': arg1['shape'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_31.py b/rules-tf/xla.sort/rule_31.py new file mode 100644 index 0000000000..a7a79f221b --- /dev/null +++ b/rules-tf/xla.sort/rule_31.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If name is not "none", then the input tensor's dtype cannot be a np.dtype (Rule 31) + +rule_31 = lambda s, v, n=False: ( + s.add(Not(If(v["arg2_value"] != 6, v["arg1_dtype"] != 12, True)) if n else + If(v["arg2_value"] != 6, v["arg1_dtype"] != 12, True)) +) + +def rule_31_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 31 + rule_31(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_31(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_32.py b/rules-tf/xla.sort/rule_32.py new file mode 100644 index 0000000000..619c71522f --- /dev/null +++ b/rules-tf/xla.sort/rule_32.py @@ -0,0 +1,43 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If input tensor's dtype is string and name is "none" then the shape must be one-dimensional (Rule 32) + +rule_32 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg1_dtype"] == 11, v["arg2_value"] == 6), v["arg1_ndim"] == 1, True)) if n else + If(And(v["arg1_dtype"] == 11, v["arg2_value"] == 6), v["arg1_ndim"] == 1, True)) +) + +def rule_32_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 32 + rule_32(solver, {'arg1_dtype': arg1_dtype, 'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_32(solver, {'arg1_dtype': arg1['dtype'], 'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_33.py b/rules-tf/xla.sort/rule_33.py new file mode 100644 index 0000000000..d43fa82858 --- /dev/null +++ b/rules-tf/xla.sort/rule_33.py @@ -0,0 +1,43 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If input tensor's dtype is a np.dtype, and name is "none" then the shape must be one-dimensional (Rule 33) + +rule_33 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg1_dtype"] == 12, v["arg2_value"] == 6), v["arg1_ndim"] == 1, True)) if n else + If(And(v["arg1_dtype"] == 12, v["arg2_value"] == 6), v["arg1_ndim"] == 1, True)) +) + +def rule_33_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 33 + rule_33(solver, {'arg1_dtype': arg1_dtype, 'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_33(solver, {'arg1_dtype': arg1['dtype'], 'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_34.py b/rules-tf/xla.sort/rule_34.py new file mode 100644 index 0000000000..b5ecdf0d24 --- /dev/null +++ b/rules-tf/xla.sort/rule_34.py @@ -0,0 +1,43 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the name is equal to 'none' and dtype is in [int8, int16, int32, int64, uint8] then the number of dimensions should be 1. (Rule 34) + +rule_34 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg2_value"] == 6, (Or(Or(Or(Or(v["arg1_dtype"] == 1, v["arg1_dtype"] == 2), v["arg1_dtype"] == 3), v["arg1_dtype"] == 4), v["arg1_dtype"] == 5))), v["arg1_ndim"] == 1, True)) if n else + If(And(v["arg2_value"] == 6, (Or(Or(Or(Or(v["arg1_dtype"] == 1, v["arg1_dtype"] == 2), v["arg1_dtype"] == 3), v["arg1_dtype"] == 4), v["arg1_dtype"] == 5))), v["arg1_ndim"] == 1, True)) +) + +def rule_34_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 34 + rule_34(solver, {'arg1_dtype': arg1_dtype, 'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_34(solver, {'arg1_dtype': arg1['dtype'], 'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_35.py b/rules-tf/xla.sort/rule_35.py new file mode 100644 index 0000000000..30e0dcf684 --- /dev/null +++ b/rules-tf/xla.sort/rule_35.py @@ -0,0 +1,43 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the name is equal to 'none' and dtype is in [float16, float32, float64] then the number of dimensions should be 1. (Rule 35) + +rule_35 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg2_value"] == 6, (Or(Or(v["arg1_dtype"] == 6, v["arg1_dtype"] == 7), v["arg1_dtype"] == 8))), v["arg1_ndim"] == 1, True)) if n else + If(And(v["arg2_value"] == 6, (Or(Or(v["arg1_dtype"] == 6, v["arg1_dtype"] == 7), v["arg1_dtype"] == 8))), v["arg1_ndim"] == 1, True)) +) + +def rule_35_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 35 + rule_35(solver, {'arg1_dtype': arg1_dtype, 'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_35(solver, {'arg1_dtype': arg1['dtype'], 'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_36.py b/rules-tf/xla.sort/rule_36.py new file mode 100644 index 0000000000..12bee60f78 --- /dev/null +++ b/rules-tf/xla.sort/rule_36.py @@ -0,0 +1,43 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the name is equal to 'none' and dtype is in [complex64, complex128] then the number of dimensions should be 1. (Rule 36) + +rule_36 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg2_value"] == 6, (Or(v["arg1_dtype"] == 9, v["arg1_dtype"] == 10))), v["arg1_ndim"] == 1, True)) if n else + If(And(v["arg2_value"] == 6, (Or(v["arg1_dtype"] == 9, v["arg1_dtype"] == 10))), v["arg1_ndim"] == 1, True)) +) + +def rule_36_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 36 + rule_36(solver, {'arg1_dtype': arg1_dtype, 'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_36(solver, {'arg1_dtype': arg1['dtype'], 'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_37.py b/rules-tf/xla.sort/rule_37.py new file mode 100644 index 0000000000..d27c913637 --- /dev/null +++ b/rules-tf/xla.sort/rule_37.py @@ -0,0 +1,43 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the name is equal to 'none' and dtype is bool then the number of dimensions should be 1. (Rule 37) + +rule_37 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg2_value"] == 6, (v["arg1_dtype"] == 0)), v["arg1_ndim"] == 1, True)) if n else + If(And(v["arg2_value"] == 6, (v["arg1_dtype"] == 0)), v["arg1_ndim"] == 1, True)) +) + +def rule_37_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 37 + rule_37(solver, {'arg1_dtype': arg1_dtype, 'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_37(solver, {'arg1_dtype': arg1['dtype'], 'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_38.py b/rules-tf/xla.sort/rule_38.py new file mode 100644 index 0000000000..15742389a8 --- /dev/null +++ b/rules-tf/xla.sort/rule_38.py @@ -0,0 +1,43 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the name is equal to 'none' and dtype is uint8 then the number of dimensions should be 1. (Rule 38) + +rule_38 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg2_value"] == 6, (v["arg1_dtype"] == 5)), v["arg1_ndim"] == 1, True)) if n else + If(And(v["arg2_value"] == 6, (v["arg1_dtype"] == 5)), v["arg1_ndim"] == 1, True)) +) + +def rule_38_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 38 + rule_38(solver, {'arg1_dtype': arg1_dtype, 'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_38(solver, {'arg1_dtype': arg1['dtype'], 'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_39.py b/rules-tf/xla.sort/rule_39.py new file mode 100644 index 0000000000..f3047e0bc5 --- /dev/null +++ b/rules-tf/xla.sort/rule_39.py @@ -0,0 +1,43 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If name is equal to 'none' and dtype is np.dtype then the number of dimensions should be greater than 0. (Rule 39) + +rule_39 = lambda s, v, n=False: ( + s.add(Not(If(And(v["arg2_value"] == 6, (v["arg1_dtype"] == 12)), v["arg1_ndim"] > 0, True)) if n else + If(And(v["arg2_value"] == 6, (v["arg1_dtype"] == 12)), v["arg1_ndim"] > 0, True)) +) + +def rule_39_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 39 + rule_39(solver, {'arg1_dtype': arg1_dtype, 'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_39(solver, {'arg1_dtype': arg1['dtype'], 'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_40.py b/rules-tf/xla.sort/rule_40.py new file mode 100644 index 0000000000..c7bc95f4f6 --- /dev/null +++ b/rules-tf/xla.sort/rule_40.py @@ -0,0 +1,42 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the name is equal to 'none' then the minimum value of the tensor must be smaller than or equal to the maximum value of the tensor. (Rule 40) + +rule_40 = lambda s, v, n=False: ( + s.add(Not(If(v["arg2_value"] == 6, Select(v["arg1_range"], 0) <= Select(v["arg1_range"], 1), True)) if n else + If(v["arg2_value"] == 6, Select(v["arg1_range"], 0) <= Select(v["arg1_range"], 1), True)) +) + +def rule_40_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_range = Array('arg1_range', IntSort(), IntSort()) + arg2_value = String('arg2_value') + + # Value assignments + arg1_range = Store(arg1_range, 0, int(np.min(arg1))) + arg1_range = Store(arg1_range, 1, int(np.max(arg1))) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 40 + rule_40(solver, {'arg1_range': arg1_range, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_40(solver, {'arg1_range': arg1['range'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_42.py b/rules-tf/xla.sort/rule_42.py new file mode 100644 index 0000000000..7564eba185 --- /dev/null +++ b/rules-tf/xla.sort/rule_42.py @@ -0,0 +1,44 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If the name is equal to 'none' then the tensor should not have any NaN values (Rule 42) + +rule_42 = lambda s, v, n=False: ( + s.add(Not(If(v["arg2_value"] == 6, Or([And(i < (v["arg1_ndim"] - 1 + 1), Select(v["arg1_shape"], i) >= 0) for i in range(6)]), True)) if n else + If(v["arg2_value"] == 6, Or([And(i < (v["arg1_ndim"] - 1 + 1), Select(v["arg1_shape"], i) >= 0) for i in range(6)]), True)) +) + +def rule_42_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg1_shape = Array('arg1_shape', IntSort(), IntSort()) + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + for i in range(arg1.ndim): + arg1_shape = Store(arg1_shape, i, arg1.shape[i]) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 42 + rule_42(solver, {'arg1_ndim': arg1_ndim, 'arg1_shape': arg1_shape, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_42(solver, {'arg1_ndim': arg1['ndim'], 'arg1_shape': arg1['shape'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_5.py b/rules-tf/xla.sort/rule_5.py new file mode 100644 index 0000000000..31af55ff53 --- /dev/null +++ b/rules-tf/xla.sort/rule_5.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# Input tensor dimensions must be less than 5 (Rule 5) + +rule_5 = lambda s, v, n=False: ( + s.add(Not(v["arg1_ndim"] < 5) if n else + v["arg1_ndim"] < 5) +) + +def rule_5_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + + # Constraints for rule 5 + rule_5(solver, {'arg1_ndim': arg1_ndim}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_5(solver, {'arg1_ndim': arg1['ndim']}, neg) diff --git a/rules-tf/xla.sort/rule_6.py b/rules-tf/xla.sort/rule_6.py new file mode 100644 index 0000000000..4a9099136e --- /dev/null +++ b/rules-tf/xla.sort/rule_6.py @@ -0,0 +1,39 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# Input tensor must have positive shape (Rule 6) + +rule_6 = lambda s, v, n=False: ( + s.add(Not(And([Implies(i < (v["arg1_ndim"] - 1 + 1), Select(v["arg1_shape"], i) > 0) for i in range(6)])) if n else + And([Implies(i < (v["arg1_ndim"] - 1 + 1), Select(v["arg1_shape"], i) > 0) for i in range(6)])) +) + +def rule_6_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg1_shape = Array('arg1_shape', IntSort(), IntSort()) + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + for i in range(arg1.ndim): + arg1_shape = Store(arg1_shape, i, arg1.shape[i]) + + # Constraints for rule 6 + rule_6(solver, {'arg1_ndim': arg1_ndim, 'arg1_shape': arg1_shape}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_6(solver, {'arg1_ndim': arg1['ndim'], 'arg1_shape': arg1['shape']}, neg) diff --git a/rules-tf/xla.sort/rule_7.py b/rules-tf/xla.sort/rule_7.py new file mode 100644 index 0000000000..e48f42f039 --- /dev/null +++ b/rules-tf/xla.sort/rule_7.py @@ -0,0 +1,36 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# The input tensor cannot have dimension zero. (Rule 7) + +rule_7 = lambda s, v, n=False: ( + s.add(Not(v["arg1_ndim"] != 0) if n else + v["arg1_ndim"] != 0) +) + +def rule_7_func(arg1, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + + # Constraints for rule 7 + rule_7(solver, {'arg1_ndim': arg1_ndim}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_7(solver, {'arg1_ndim': arg1['ndim']}, neg) diff --git a/rules-tf/xla.sort/rule_8.py b/rules-tf/xla.sort/rule_8.py new file mode 100644 index 0000000000..edb8255bdd --- /dev/null +++ b/rules-tf/xla.sort/rule_8.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If name is "none", input tensor ndim should be 1. (Rule 8) + +rule_8 = lambda s, v, n=False: ( + s.add(Not(If(v["arg2_value"] == 6, v["arg1_ndim"] == 1, True)) if n else + If(v["arg2_value"] == 6, v["arg1_ndim"] == 1, True)) +) + +def rule_8_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_ndim = Int('arg1_ndim') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_ndim == arg1.ndim) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 8 + rule_8(solver, {'arg1_ndim': arg1_ndim, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_8(solver, {'arg1_ndim': arg1['ndim'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rule_9.py b/rules-tf/xla.sort/rule_9.py new file mode 100644 index 0000000000..48051f5e39 --- /dev/null +++ b/rules-tf/xla.sort/rule_9.py @@ -0,0 +1,41 @@ +import numpy as np +import torch +import tensorflow as tf + +from utils.defaults import MAX_N_DIM, MAX_SZ_DIM, MAX_SZ_NUM, list_of_available_dtypes, list_of_string_values_tf, np_dtype +from z3 import * + +# If name is "sum", "max", "min", or "prod", input tensor should have integer or float type (Rule 9) + +rule_9 = lambda s, v, n=False: ( + s.add(Not(If(Or(Or(Or(v["arg2_value"] == 7, v["arg2_value"] == 8), v["arg2_value"] == 9), v["arg2_value"] == 10), (And(v["arg1_dtype"] >= 1, v["arg1_dtype"] <= 9)), True)) if n else + If(Or(Or(Or(v["arg2_value"] == 7, v["arg2_value"] == 8), v["arg2_value"] == 9), v["arg2_value"] == 10), (And(v["arg1_dtype"] >= 1, v["arg1_dtype"] <= 9)), True)) +) + +def rule_9_func(arg1, arg2, solver=None, neg=False): + arg1 = next(iter(arg1.values())) + arg2 = next(iter(arg2.values())) + + # Invariant learning phase + if not solver: + if not isinstance(arg1, np.ndarray): + return False + if not isinstance(arg2, str): + return False + + # Variable declarations + solver = Solver() + arg1_dtype = Int('arg1_dtype') + arg2_value = String('arg2_value') + + # Value assignments + solver.add(arg1_dtype == list_of_available_dtypes.index(arg1.dtype)) + solver.add(arg2_value == list_of_string_values_tf.index(arg2)) + + # Constraints for rule 9 + rule_9(solver, {'arg1_dtype': arg1_dtype, 'arg2_value': arg2_value}) + return solver.check() == sat + + # Fuzz input generation phase + else: + rule_9(solver, {'arg1_dtype': arg1['dtype'], 'arg2_value': arg2['value']}, neg) diff --git a/rules-tf/xla.sort/rules-ebnf b/rules-tf/xla.sort/rules-ebnf new file mode 100644 index 0000000000..50eb1f3d9e --- /dev/null +++ b/rules-tf/xla.sort/rules-ebnf @@ -0,0 +1,114 @@ +>> +Rule 1 (input tensor must be at least 1-dimensional) +{v_1 : tensor} |= ndim(v_1) ≥ 1 +>> +Rule 2 (name must be a valid string) +{v_2 : str} |= v_2 = "ii" ∨ v_2 = "ii->i" ∨ v_2 = "i,j->ij" ∨ v_2 = "bij,bjk->bik" ∨ v_2 = "...ij->...ji" ∨ v_2 = "bn,anm,bm->ba" ∨ v_2 = "none" ∨ v_2 = "sum" ∨ v_2 = "max" ∨ v_2 = "min" ∨ v_2 = "prod" ∨ v_2 = "relu" ∨ v_2 = "tanh" ∨ v_2 = "sigmoid" ∨ v_2 = "softmax" ∨ v_2 = "elu" ∨ v_2 = "selu" ∨ v_2 = "gelu" ∨ v_2 = "swish" ∨ v_2 = "softplus" ∨ v_2 = "linear" ∨ v_2 = "valid" ∨ v_2 = "same" ∨ v_2 = "causal" ∨ v_2 = "channels_last" ∨ v_2 = "channels_first" +>> +Rule 3 (input tensor must be of float32 or float64 dtype) +{v_1 : tensor} |= dtype_(v_1) = 7 ∨ dtype_(v_1) = 8 +>> +Rule 4 (name cannot be an empty string) +{v_2 : str} |= v_2 ≠ "" +>> +Rule 5 (Input tensor dimensions must be less than 5) +{v_1 : tensor} |= ndim(v_1) < 5 +>> +Rule 6 (Input tensor must have positive shape) +{v_1 : tensor} |= ∀i ∈ [0, ndim(v_1) - 1] : shape(v_1, i) > 0 +>> +Rule 7 (The input tensor cannot have dimension zero.) +{v_1 : tensor} |= ndim(v_1) ≠ 0 +>> +Rule 8 (If name is "none", input tensor ndim should be 1.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" then ndim(v_1) = 1 +>> +Rule 9 (If name is "sum", "max", "min", or "prod", input tensor should have integer or float type) +{v_1 : tensor, v_2 : str} |= if v_2 = "sum" ∨ v_2 = "max" ∨ v_2 = "min" ∨ v_2 = "prod" then (dtype_(v_1) ≥ 1 ∧ dtype_(v_1) ≤ 9) +>> +Rule 10 (If name is "relu", "tanh", "sigmoid", "softmax", "elu", "selu", "gelu", "swish", "softplus", or "linear", the input tensor should have a floating-point type) +{v_1 : tensor, v_2 : str} |= if v_2 = "relu" ∨ v_2 = "tanh" ∨ v_2 = "sigmoid" ∨ v_2 = "softmax" ∨ v_2 = "elu" ∨ v_2 = "selu" ∨ v_2 = "gelu" ∨ v_2 = "swish" ∨ v_2 = "softplus" ∨ v_2 = "linear" then (dtype_(v_1) ≥ 6 ∧ dtype_(v_1) ≤ 8) +>> +Rule 11 (The input tensor's dtype should be a supported type (1-11 or 6-8)) +{v_1 : tensor} |= (dtype_(v_1) ≥ 1 ∧ dtype_(v_1) ≤ 11) ∨ (dtype_(v_1) ≥ 6 ∧ dtype_(v_1) ≤ 8) +>> +Rule 12 (If name is "valid", "same", or "causal", input tensor should have 3 or 4 dimensions) +{v_1 : tensor, v_2 : str} |= if v_2 = "valid" ∨ v_2 = "same" ∨ v_2 = "causal" then (ndim(v_1) = 3 ∨ ndim(v_1) = 4) +>> +Rule 13 (If name is "channels_last" or "channels_first", input tensor should have 3 or 4 dimensions) +{v_1 : tensor, v_2 : str} |= if v_2 = "channels_last" ∨ v_2 = "channels_first" then (ndim(v_1) = 3 ∨ ndim(v_1) = 4) +>> +Rule 14 (If name is "bij,bjk->bik" or "bn,anm,bm->ba", input tensor should have 3 dimensions) +{v_1 : tensor, v_2 : str} |= if v_2 = "bij,bjk->bik" ∨ v_2 = "bn,anm,bm->ba" then ndim(v_1) = 3 +>> +Rule 15 (If name is "...ij->...ji", input tensor should have more than 1 dimension) +{v_1 : tensor, v_2 : str} |= if v_2 = "...ij->...ji" then ndim(v_1) > 1 +>> +Rule 16 (If the name is "i,j->ij", input tensor must have exactly two dimensions) +{v_1 : tensor, v_2 : str} |= if v_2 = "i,j->ij" then ndim(v_1) = 2 +>> +Rule 18 (If name is "ii" or "ii->i", no specific constraint is placed on the input tensor.) +{v_2 : str} |= if v_2 = "ii" ∨ v_2 = "ii->i" then true +>> +Rule 20 (Input tensor must not be of boolean type.) +{v_1 : tensor} |= dtype_(v_1) ≠ 0 +>> +Rule 21 (If input tensor is complex, the name parameter is not allowed to be relu, tanh, sigmoid, softmax, elu, selu, gelu, swish, softplus, linear) +{v_1 : tensor, v_2 : str} |= if (dtype_(v_1) = 9) ∨ (dtype_(v_1) = 10) then v_2 ≠ "relu" ∧ v_2 ≠ "tanh" ∧ v_2 ≠ "sigmoid" ∧ v_2 ≠ "softmax" ∧ v_2 ≠ "elu" ∧ v_2 ≠ "selu" ∧ v_2 ≠ "gelu" ∧ v_2 ≠ "swish" ∧ v_2 ≠ "softplus" ∧ v_2 ≠ "linear" +>> +Rule 22 (If input tensor is complex, the name parameter is not allowed to be valid, same, causal, channels_last, channels_first) +{v_1 : tensor, v_2 : str} |= if (dtype_(v_1) = 9) ∨ (dtype_(v_1) = 10) then v_2 ≠ "valid" ∧ v_2 ≠ "same" ∧ v_2 ≠ "causal" ∧ v_2 ≠ "channels_last" ∧ v_2 ≠ "channels_first" +>> +Rule 23 (If input tensor is complex, the name parameter is not allowed to be sum, max, min, prod) +{v_1 : tensor, v_2 : str} |= if (dtype_(v_1) = 9) ∨ (dtype_(v_1) = 10) then v_2 ≠ "sum" ∧ v_2 ≠ "max" ∧ v_2 ≠ "min" ∧ v_2 ≠ "prod" +>> +Rule 24 (If dtype is string, name must be 'none') +{v_1: tensor, v_2: str} |= if dtype_(v_1) = 11 then v_2 = "none" +>> +Rule 25 (If input tensor has bool dtype, name must be 'none') +{v_1: tensor, v_2: str} |= if dtype_(v_1) = 0 then v_2 = "none" +>> +Rule 27 (If name is 'none', no requirements exist) +{v_2 : str} |= if v_2 = "none" then true +>> +Rule 29 (If the input tensor has more than 2 dimensions, and the name is equal to 'none' there are no constraints.) +{v_1 : tensor, v_2 : str} |= if ndim(v_1) > 2 ∧ v_2 = "none" then true +>> +Rule 30 (If name is not "none", the tensor must have at least one element) +{v_1 : tensor, v_2 : str} |= if v_2 ≠ "none" then (∃i ∈ [0, ndim(v_1) - 1] : shape(v_1, i) > 0) +>> +Rule 31 (If name is not "none", then the input tensor's dtype cannot be a np.dtype) +{v_1 : tensor, v_2 : str} |= if v_2 ≠ "none" then dtype_(v_1) ≠ 12 +>> +Rule 32 (If input tensor's dtype is string and name is "none" then the shape must be one-dimensional) +{v_1: tensor, v_2: str} |= if dtype_(v_1) = 11 ∧ v_2 = "none" then ndim(v_1) = 1 +>> +Rule 33 (If input tensor's dtype is a np.dtype, and name is "none" then the shape must be one-dimensional) +{v_1: tensor, v_2: str} |= if dtype_(v_1) = 12 ∧ v_2 = "none" then ndim(v_1) = 1 +>> +Rule 34 (If the name is equal to 'none' and dtype is in [int8, int16, int32, int64, uint8] then the number of dimensions should be 1.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ (dtype_(v_1) = 1 ∨ dtype_(v_1) = 2 ∨ dtype_(v_1) = 3 ∨ dtype_(v_1) = 4 ∨ dtype_(v_1) = 5) then ndim(v_1) = 1 +>> +Rule 35 (If the name is equal to 'none' and dtype is in [float16, float32, float64] then the number of dimensions should be 1.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ (dtype_(v_1) = 6 ∨ dtype_(v_1) = 7 ∨ dtype_(v_1) = 8) then ndim(v_1) = 1 +>> +Rule 36 (If the name is equal to 'none' and dtype is in [complex64, complex128] then the number of dimensions should be 1.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ (dtype_(v_1) = 9 ∨ dtype_(v_1) = 10) then ndim(v_1) = 1 +>> +Rule 37 (If the name is equal to 'none' and dtype is bool then the number of dimensions should be 1.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ (dtype_(v_1) = 0) then ndim(v_1) = 1 +>> +Rule 38 (If the name is equal to 'none' and dtype is uint8 then the number of dimensions should be 1.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ (dtype_(v_1) = 5) then ndim(v_1) = 1 +>> +Rule 39 (If name is equal to 'none' and dtype is np.dtype then the number of dimensions should be greater than 0.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ (dtype_(v_1) = 12) then ndim(v_1) > 0 +>> +Rule 40 (If the name is equal to 'none' then the minimum value of the tensor must be smaller than or equal to the maximum value of the tensor.) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" then min(v_1) ≤ max(v_1) +>> +Rule 41 (If the name is equal to 'none' then all values of a bool tensor must be either all true or all false ) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" ∧ dtype_(v_1) = 0 then (∀i ∈ [0, shape(v_1, 0) - 1] : v_1[i] = true) ∨ (∀i ∈ [0, shape(v_1, 0) - 1] : v_1[i] = false) +>> +Rule 42 (If the name is equal to 'none' then the tensor should not have any NaN values) +{v_1 : tensor, v_2 : str} |= if v_2 = "none" then ∃i ∈ [0, ndim(v_1) - 1] : shape(v_1, i) ≥ 0