Primitive Operations Reference
Type Conversion Operations
Operation | Key Assertions | Notes |
---|---|---|
parse_boolean | Output maintains input shape | Converts any input type to boolean |
parse_decimal | Output maintains input shape | Converts to floating point values |
parse_integer | Output maintains input shape | Decimals are rounded down |
parse_text | Output maintains input shape | Converts to string representation |
Shape & Dimension Operations
Operation | Key Assertions | Notes |
---|---|---|
broadcast_to_shape | Target shape size must be ≥ input shape size Target dimension sizes must be ≥ corresponding input sizes | Broadcasting follows numpy/PyTorch rules |
deduplicate_to_vector | Input must be array | Returns 1D array with unique elements |
expand_one_dimension | New dimension index must be valid | Adds a dimension of size 1 at specified position |
get_dimension_size | Dimension index must be valid | Returns scalar integer |
get_shape | Input must be an array | Returns 1D tensor of shape dimensions |
reduce_one_dimension | Dimension index & selected index must be valid | Reduces array by one dimension |
reduce_one_dimension_with_element_wise_selected_indices | Selected indices shape must match reduced shape | Allows different selection indices for each element |
reshape | New shape must have same total elements | Total element count must match |
swap_dimensions | Array must have > 1 dimension Indices must be different | Swaps two dimensions of array |
Indexing & Selection Operations
Operation | Key Assertions | Notes |
---|---|---|
argwhere | Input must be boolean | Returns indices where input is true |
argument_maximum | Dimension index must be valid Array must be numeric | Returns indices of max values |
argument_minimum | Dimension index must be valid Array must be numeric | Returns indices of min values |
gather | Index array must be integer & ≥ 0 Index array dims must match input | Gathers values at indices along dimension |
get_sub_arrays | Selected indices must be valid | Extracts sub-arrays at indices |
slice | Start index must be ≥ 0 & < end index Start index must be < array size at dimension | Extracts slice from array |
slice_with_multiple_indices | Start indices must be ≥ 0 & < end indices | Allows different start/end for each slice |
top_k | Array must be numeric k must be > 0 & ≤ dimension size | Returns top k values and indices |
Mathematical Operations
Operation | Key Assertions | Notes |
---|---|---|
absolute_value | Input must be numeric | Returns absolute values |
add | Operands must have same shape & type | Element-wise addition |
cumulative_sum | Array must be numeric Dimension index must be valid | Computes running sum along dimension |
divide | Operands must have same shape & type Right operand must be non-zero | Element-wise division |
element_wise_exponentiate | Base & exponent must be decimal | Raises base to power of exponent |
element_wise_logarithm | Base & argument must be decimal | Computes logarithm of argument with given base |
element_wise_multiply | Arrays must have same shape & type | Element-wise multiplication |
maximum | Array must be numeric Dimension index must be valid | Returns maximum values along dimension |
mean | Array must be numeric Dimension index must be valid | Returns mean along dimension |
minimum | Array must be numeric Dimension index must be valid | Returns minimum values along dimension |
modulo | Operands must be integer | Returns remainder of division |
multiply | Operands must have compatible shapes | Matrix multiplication |
product | Array must be numeric Dimension index must be valid | Returns product along dimension |
subtract | Operands must have same shape & type | Element-wise subtraction |
sum | Array must be numeric Dimension index must be valid | Returns sum along dimension |
Logical & Comparison Operations
Operation | Key Assertions | Notes |
---|---|---|
conditional_filter | Condition must be boolean Data arrays must have same shape & type | Selects between two arrays based on condition |
contain | Target & check_against must have same type Check_against must be array | Checks if values are in array |
contain_combination | Arrays must be integer Target must be 2D | Checks if combinations are contained |
contain_seq | Arrays must be integer | Checks if sequences are contained |
count_occurrences | Arrays must have same type | Counts occurrences of values |
equal | Operands must have same shape & type | Element-wise equality check |
greater_than | Operands must be numeric & same shape | Element-wise greater than check |
id_to_one_hot | ID array must be integer Num classes must be ≥ 1 | Converts IDs to one-hot vectors |
less_than | Operands must be numeric & same shape | Element-wise less than check |
logical_and | Conditions must be boolean & same shape | Element-wise AND |
logical_not | Condition must be boolean | Element-wise NOT |
logical_or | Conditions must be boolean & same shape | Element-wise OR |
is_scalar | No specific constraints | Checks if input is scalar |
is_nan | Input must be decimal | Checks for NaN values |
Array Manipulation Operations
Operation | Key Assertions | Notes |
---|---|---|
concatenate | Arrays must have same number of dimensions Dimension sizes must match except at concatenation dimension | Joins arrays along specified dimension |
filter | Condition must be boolean Dimension index must be valid | Filters array along dimension based on condition |
reverse_order | Array must be array Dimension index must be valid | Reverses array along dimension |
scatter | Arrays must have same dimensions Indices must be valid | Updates values at indices |
scatter_add | Dimension index must be valid Indices must be integer | Adds values at indices |
set | Input and values must have same type Coordinates must be integer | Sets values at coordinates |
split | Array must be array Element index must be valid | Splits array into two parts at specified index |
swap_elements | Indices must be different & valid Dimension index must be valid | Swaps elements within array |
Randomness & Sampling Operations
Operation | Key Assertions | Notes |
---|---|---|
argument_multinomial | Probabilities must be decimal Number samples must be > 0 | Samples indices from probability distribution |
generate_combinations | Array must be 1D Samples must be integer | Generates combinations |
generate_combinations_batch | Array must be 1D Samples and batch size must be integer | Generates batches of combinations |
generate_uniform_random_number | Shape must be > 0 Seed must be integer | Generates random numbers |
range | Start/end/step must be numeric Start must not equal end Step must be compatible with direction | Generates range of values |
sample_by_step | Step value must be > 0 | Samples at regular intervals |
shuffle | Array must be array Dimension index must be valid | Randomly reorders elements along dimension |
Text Operations
Operation | Key Assertions | Notes |
---|---|---|
concatenate_text | Inputs must be text & same shape | Element-wise text concatenation |
contain_text | Inputs must be text Search regex must be valid | Checks if regex matches text |
get_text_length | Input must be text | Returns length of each text element |
index_text | Text must be text Vocabulary must be 1D | Converts text to indices |
index_text_to_condensed_one_hot | Text must be text Vocabulary must be 1D | Creates condensed one-hot encoding |
index_text_to_one_hot | Text must be text Vocabulary must be 1D | Creates one-hot encoding |
insert_text | Inputs must be text Search regex must be valid | Inserts text at regex matches |
join_text | Text must be array Separator must be text | Joins text elements with separator |
lower_upper_case_text | Text & is_lower_case must have same shape | Converts text case based on boolean |
replace_text | Inputs must be text Search regex must be valid | Replaces regex matches |
slice_text | Text must be text Indices must be integer | Extracts substring between indices |
split_subwords_longest_match_first | Arrays must be text | Tokenizes words into subwords |
split_text | Text must be text Regex must be valid | Splits text by regex pattern |
File Operations
Operation | Key Assertions | Notes |
---|---|---|
delete_folder | Path must be text | Deletes folder if exists |
exist_in_files | Paths must be text | Checks if file exists |
read_from_file | Paths must be text File must exist | Reads data from file |
read_sub_arrays_from_file | Paths must be text File must exist Indices must be ≥ 0 | Reads specific indices from file |
write_to_file | Paths must be text Overwrite flag must be boolean | Writes data to file |
Special Operations
Operation | Key Assertions | Notes |
---|---|---|
bilinear_interpolate | Input must be decimal & multi-dimensional Scale factor must be 2-element array | Applies bilinear interpolation |
conv2d | Input must be 4D decimal Kernel must match input channels | Applies 2D convolution |
conv2d_transpose | Input must be 4D decimal Kernel must match input channels | Applies transposed 2D convolution |
diagonal | Input must be 2D | Sets diagonal elements to value |
differentiate | Input/output must be decimal | Computes derivative |
dropout | Array must be decimal Probability must be between 0-1 | Applies dropout with rescaling |
eigen | Input must be square matrix | Returns eigenvalues and eigenvectors |
error_function | Input must be decimal | Computes error function (erf) |
identity | No specific constraints | Returns input unchanged |
max_pooling2d | Input must be 4D decimal | Applies 2D max pooling |
sine | Input must be decimal | Computes sine of input |
cosine | Input must be decimal | Computes cosine of input |