Einsum_parserEntry point for the einsum parser library.
This module provides functions to parse einsum notation specifications using a Menhir-based parser.
Use_padding specification for convolutions.
val compare_use_padding_spec : use_padding_spec -> use_padding_spec -> Base.intval __use_padding_spec_of_sexp__ : Sexplib0.Sexp.t -> use_padding_specval use_padding_spec_of_sexp : Sexplib0.Sexp.t -> use_padding_specval sexp_of_use_padding_spec : use_padding_spec -> Sexplib0.Sexp.ttype conv_spec = {dilation : Base.string;kernel_label : Base.string;use_padding : use_padding_spec;}Convolution component for affine axis specifications. Note: dilation is a string because it can be an identifier at parse time, and is resolved to an int at runtime.
val conv_spec_of_sexp : Sexplib0.Sexp.t -> conv_specval sexp_of_conv_spec : conv_spec -> Sexplib0.Sexp.ttype axis_spec = | Label of Base.stringA variable axis label.
*)| Fixed_index of Base.intA fixed index, used for projection.
*)| Affine_spec of {stride : Base.string;Coefficient for the over dimension (string to allow identifiers).
*)over_label : Base.string;The output/iteration dimension label.
*)conv : conv_spec Base.option;Optional convolution: dilation*kernel.
*)stride_offset : Base.int;Constant offset added after stride*over.
*)}Affine axis specification: stride*over + stride_offset + dilation*kernel. Corresponds to Row.Affine in shape inference.
Specification for individual axes in the einsum notation. Note: stride is a string because it can be an identifier at parse time, and is resolved to an int at runtime.
val axis_spec_of_sexp : Sexplib0.Sexp.t -> axis_specval sexp_of_axis_spec : axis_spec -> Sexplib0.Sexp.tmodule AxisKey : sig ... endAn index pointing to any of a shape's axes, including the kind of the axis (Batch, Input, Output) and the position (which is counted from the end to facilitate broadcasting).
type axis_key = AxisKey.tval axis_key_of_sexp : Sexplib0.Sexp.t -> axis_keyval sexp_of_axis_key : axis_key -> Sexplib0.Sexp.tval axis_map_of_sexp :
'a. (Sexplib0.Sexp.t -> 'a) ->
Sexplib0.Sexp.t ->
'a axis_mapval sexp_of_axis_map :
'a. ('a -> Sexplib0.Sexp.t) ->
'a axis_map ->
Sexplib0.Sexp.ttype parsed_axis_labels = {bcast_batch : Base.string Base.option;bcast_input : Base.string Base.option;bcast_output : Base.string Base.option;given_batch : axis_spec Base.list;given_input : axis_spec Base.list;given_output : axis_spec Base.list;given_beg_batch : axis_spec Base.list;given_beg_input : axis_spec Base.list;given_beg_output : axis_spec Base.list;labels : axis_spec axis_map;}The labels are strings assigned to AxisKey axes. Moreover the bcast_ fields represent whether additional leading/middle axes are allowed (corresponding to the dot-ellipsis syntax for broadcasting). The string can be used to identify a row variable, and defaults to "batch", "input", "output" respectively when parsing "...". The given_ fields are lists of axis specs of the corresponding kind in labels where from_end=true, given_beg_ where from_end=false.
val compare_parsed_axis_labels :
parsed_axis_labels ->
parsed_axis_labels ->
Base.intval parsed_axis_labels_of_sexp : Sexplib0.Sexp.t -> parsed_axis_labelsval sexp_of_parsed_axis_labels : parsed_axis_labels -> Sexplib0.Sexp.tval labels : parsed_axis_labels -> axis_spec axis_mapval given_beg_output : parsed_axis_labels -> axis_spec Base.listval given_beg_input : parsed_axis_labels -> axis_spec Base.listval given_beg_batch : parsed_axis_labels -> axis_spec Base.listval given_output : parsed_axis_labels -> axis_spec Base.listval given_input : parsed_axis_labels -> axis_spec Base.listval given_batch : parsed_axis_labels -> axis_spec Base.listval bcast_output : parsed_axis_labels -> Base.string Base.optionval bcast_input : parsed_axis_labels -> Base.string Base.optionval bcast_batch : parsed_axis_labels -> Base.string Base.optionmodule Fields_of_parsed_axis_labels : sig ... endval axis_labels : parsed_axis_labels -> axis_spec axis_mapDetermine if a spec uses multichar mode. Multichar mode is triggered by presence of: ',', '*', '+', '^', '&'
val axis_labels_of_spec : Base.string -> parsed_axis_labelsParse an axis labels specification.
Examples:
val einsum_of_spec :
Base.string ->
parsed_axis_labels * parsed_axis_labels Base.option * parsed_axis_labelsParse an einsum specification.
Examples: