deephaven.lang.transformer

Transforms analyzed nodes into vectorized functions.

The contents of this module are intended only for internal Deephaven use and may change at any time.

class Transformer(analyzed, return_type, ref_values=None, mode=<VecMode.vectorize: 1>)

Transforms the analyzed node into a vectorized function. This operation is ~O(1) if you do not use any assignments (we only visit children if needed)

arg_types()

Argument types. :return: argument types.

choose_decorator()

Choose an appropriate vectorization decorator. :return: decorator.

compute_sigs(suffix='', sig_return=None)

Compute a list of signatures that are valid for the function we are building.

for example, int32 + int32 w/out explicit return would yield: @vectorize (empty suffix): [‘int32(int32,int32), int64(int32, int32)’] @jit (suffix=’[:]’): [‘int32[:](int32[:],int32[:],int32[:])’, ‘int64[:](int32[:], int32[:],int64[:])’] @guivectorize (suffix=’[:]’, sig_return=’void’): [‘void(int32[:],int32[:],int32[:])’, ‘void(int32[:], int32[:],int64[:])’]

@vectorize will implicitly add optional output array. @guivectorize _requires_ explicit output array (void return type) @jit we generate code to add optional output array

Parameters
  • suffix – A suffix to apply, to explicitly increase vector dimension (turn scalar into vector)

  • sig_return – The explicit return type to use. Defaults to the function’s expected output type.

Returns

list of valid function signatures.

generic_visit(node)

Called if no explicit visitor function exists for a node.

classmethod next_func_name()

Returns the next name that will be generated by any transformer instance. Visible for testing.

return_type_name()

Gets the return type name. :return: return type name.

visit_Module(node)

This is the main entry point of the source AST. We want to wrap the expression the user sent us with a function definition, a loop, and then an initialization of all references variables.

This might be easier to read if we just modified the source, but it is far more dependable to work with raw ast nodes, and never even think of manually parsing any strings.

visit_Name(node)