Operators#
2024-10-16
121 min read time
operation#
-
struct operation#
The operation interface represents an action an instruction will perform. All operation classes must be CopyConstructible.
Public Functions
-
std::string name() const#
A unique name identifying the operation.
-
void finalize(context &ctx)#
An optional method that can be used to finalize the operator before running.
-
shape compute_shape(const std::vector<shape> &input) const#
This is used to compute the resulting shape from an operation. If an operation cannot be run with input shapes, then it should throw an exception.
-
argument compute(context &ctx, const shape &output, const std::vector<argument> &input) const#
This performs the operation’s computation.
This method can be optional when the operation is only used as a placeholder to be lowered later on.
- Parameters:
ctx – This is the context created by the
target
during compilation. Implementations can use the target’scontext
class rather than thecontext
interface class.output – Equivalent to running
compute_shape
with eachshape
of theargument
. For a fixed shape, the returned argument will have the same shape asoutput
. For a dynamic shape, the returnedargument
will be a fixed shape within the bounds set in the dynamic shapeoutput
.input – This is the
argument
result from the previous instruction’s computation.
- Returns:
Return an
argument
of the result computation. Theshape
ofargument
should be the same theoutput
shape.
-
std::string name() const#
operators#
-
namespace op#
Enums
-
enum class normalize_attribute#
normalize_attribute
settings: Note that default options are not included as enums.use_input
(default) vs.use_output
: Affects the rank of the attribute.use_input -> lens.size()
,use_output -> lens.size() + vec.size()
.use_rank (default) vs use_len:
use_rank
sets the max value/index of the attribute as the rank of lens.use_lens
sets the max value/index as the corresponding value in lens at the axes index. Uses the dynamic_dimension.max value for dynamic shapes. Returns the original vector (no normalization) if any of dynamic_dimension[axes] are not fixed.clip_min
vs.not_clip_min
(default): Clip values less than the minimum to the minimum or not.include_min
vs.exclude_min
(default): Include or exclude the minimum value/index for range checking and clipping.clip_max
vs.not_clip_max
(default): Clip values greater than the maximum or not.include_max
vs.exclude_max
(default): Include or exclude the maximum value/index for range checking and clipping.normalize_padding
: To normalize the padding to2*(pad ndim)
dimensions.
Values:
-
enumerator use_output#
-
enumerator use_len#
-
enumerator clip_max#
-
enumerator clip_min#
-
enumerator include_max#
-
enumerator include_min#
-
enumerator normalize_padding#
Functions
-
std::ostream &operator<<(std::ostream &os, pooling_mode v)#
-
std::ostream &operator<<(std::ostream &os, rnn_direction v)#
-
struct abs : public migraphx::internal::op::unary<abs>#
- #include <migraphx/op/abs.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct acos : public migraphx::internal::op::unary<acos>#
- #include <migraphx/op/acos.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct acosh : public migraphx::internal::op::unary<acosh>#
- #include <migraphx/op/acosh.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct allocate#
- #include <migraphx/op/allocate.hpp>
Static allocate: No inputs:
allocate()
this.s
attribute set to the static output shape of the buffer.this.s
attribute can be set to a dynamic output shape; however this will allocate the maximum buffer size for that caseDynamic allocate: One input:
allocate(output_dims)
output_dims
are the output buffer dimensions and has a static shape. Eitherthis.s
orthis.buf_type
(but not both) must be set to calculate the dynamic output shape at compute time. Ifthis.buf_type
is set, the compute_shape() of allocate at compile time will have dynamic_dimensions from {0, max_int} with rank = output_dims.ndim(). Ifthis.s
is set then the compute_shape() will outputthis.s
;this.s
should be a dynamic shape.Public Functions
-
inline std::string name() const#
-
inline std::string name() const#
-
struct argmax#
- #include <migraphx/op/argmax.hpp>
-
struct argmin#
- #include <migraphx/op/argmin.hpp>
-
struct as_shape#
- #include <migraphx/op/as_shape.hpp>
Public Functions
-
inline std::string name() const#
-
inline std::string name() const#
-
struct asin : public migraphx::internal::op::unary<asin>#
- #include <migraphx/op/asin.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct asinh : public migraphx::internal::op::unary<asinh>#
- #include <migraphx/op/asinh.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct atan : public migraphx::internal::op::unary<atan>#
- #include <migraphx/op/atan.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct atanh : public migraphx::internal::op::unary<atanh>#
- #include <migraphx/op/atanh.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
template<class Derived>
struct binary : public migraphx::internal::op::op_name<Derived># - #include <migraphx/op/binary.hpp>
-
struct bitwise_and : public migraphx::internal::op::binary<bitwise_and>#
- #include <migraphx/op/bitwise_and.hpp>
-
struct broadcast#
- #include <migraphx/op/broadcast.hpp>
1 input version: Broadcasts a tensor from the original shape to the broadcast_lens by setting the stride of broadcasted dimensions to zero.
axis
attribute for a 1D input shape is the output dimension that stays the same. ex: broadcasting shape [1024] -> [4, 1024, 3] has axis = 1.For higher rank input shapes, axis is an offset parameter for the broadcasting. Such that this operator would work in the opposite direction of NumPy broadcasting (left-most to rightwards element-wise comparison) ex: broadcasting shape [2, 2] -> [2, 2, 3] with axis = 0
2 input version: Broadcast the first input 1D shape into the second input shape based on the axis parameter. Handles broadcasting a 1D static shape into a higher rank dynamic shape. broadcast_lens is not used
Public Functions
-
inline std::string name() const#
-
inline std::string name() const#
-
struct broadcast_for_dot#
- #include <migraphx/op/broadcast_for_dot.hpp>
Broadcast dimensions between two tensors for the
dot
operator. Essentially broadcasts between two shapes for dimensions other than the last two. This operator is only needed if one of the shapes are dynamic. Example: a = shape[{1, 4}, 3, 248, 248] b = shape[248, 365] broadcast_for_dot(a, b) => shape[{1, 4}, 3, 248, 248] (no change) broadcast_for_dot(b, a) => shape[{1, 4}, 3, 248, 365]
-
struct broadcast_with_dims#
- #include <migraphx/op/broadcast_with_dims.hpp>
Broadcast the input tensor to the shape defined by the values of the second input. Used as
broadcast_with_dims(input_tensor, dims)
, where dims is a vector of integer dimensions.input_tensor
must be broadcastable withdims
, otherwise this operator with throw at compute. This operator can be replaced withmultibroadcast(input_tensor)
if thedims
vector is constant.Example: input_tensor shape: lens = {2, 3}, strides = {3, 1} dims = [4, 1, 3] output shape: lens = {4, 2, 3}, strides = {0, 3, 1}
-
struct capture#
- #include <migraphx/op/capture.hpp>
Public Functions
-
inline std::string name() const#
Public Members
-
std::size_t ins_index#
-
inline std::string name() const#
-
struct ceil : public migraphx::internal::op::unary<ceil>#
- #include <migraphx/op/ceil.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct clip#
- #include <migraphx/op/clip.hpp>
-
struct concat#
- #include <migraphx/op/concat.hpp>
Public Functions
-
inline value attributes() const#
-
inline std::string name() const#
Public Members
-
int64_t axis = 0#
-
inline value attributes() const#
-
struct contiguous#
- #include <migraphx/op/contiguous.hpp>
The contiguous operator takes a non-standard input tensor and returns the same tensor but in standard form. For example, if input tensor A which has lens = (4,5) is first transposed, i.e. lens = (5,4), this tensor’s data layout remained the same during the transpose operation; only it’s shape lengths and strides were changed. This leaves the tensor in a non-standard form. The contiguous operator copies the underlying data such that resulting tensor is returned to a standard form.
-
struct convolution#
- #include <migraphx/op/convolution.hpp>
Convolution operator. Does not support optimal dimensions for spatial dimensions. Returns empty optimals.
Public Functions
-
inline std::string name() const#
-
inline void check_attribute_size() const#
-
inline value attributes() const#
-
inline std::vector<std::size_t> calc_conv_lens(std::vector<std::size_t> x_lens, std::vector<std::size_t> w_lens) const#
-
inline size_t kdims() const#
-
inline std::string name() const#
-
struct convolution_backwards#
- #include <migraphx/op/convolution_backwards.hpp>
Public Functions
-
inline std::string name() const#
-
inline void check_attribute_size() const#
-
inline std::vector<std::size_t> calc_spatial_lens(std::vector<std::size_t> x_lens, std::vector<std::size_t> w_lens) const#
-
inline size_t kdims() const#
-
inline std::string name() const#
-
struct cos : public migraphx::internal::op::unary<cos>#
- #include <migraphx/op/cos.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct cosh : public migraphx::internal::op::unary<cosh>#
- #include <migraphx/op/cosh.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct dequantizelinear#
- #include <migraphx/op/dequantizelinear.hpp>
-
struct dimensions_of#
- #include <migraphx/op/dimensions_of.hpp>
Returns the dimensions of the input argument from starting axis to ending axis. Atleast
end
must be set to use this operator (setend
to ndim for default ONNX behavior ofShape
operator) This should only be used for dynamic shapes as this can be simplified to a literal for static shapes.Public Functions
-
inline std::string name() const#
-
inline std::string name() const#
-
struct dot#
- #include <migraphx/op/dot.hpp>
Matrix multiplication of two tensors.
-
struct elu : public migraphx::internal::op::unary<elu>#
- #include <migraphx/op/elu.hpp>
Public Members
-
float alpha = 1#
-
float alpha = 1#
-
struct erf : public migraphx::internal::op::unary<erf>#
- #include <migraphx/op/erf.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct exp : public migraphx::internal::op::unary<exp>#
- #include <migraphx/op/exp.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct fill#
- #include <migraphx/op/fill.hpp>
fill(default_value, output_buffer) Fill an output buffer with the given default_value. Note that if the default_value is a literal and the output_buffer has a static shape this operator can be replaced with a literal.
-
struct floor : public migraphx::internal::op::unary<floor>#
- #include <migraphx/op/floor.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct gathernd#
- #include <migraphx/op/gathernd.hpp>
Public Functions
-
inline std::string name() const#
Public Members
-
int batch_dims = 0#
-
inline std::string name() const#
-
struct get_tuple_elem#
- #include <migraphx/op/get_tuple_elem.hpp>
Public Functions
-
inline std::string name() const#
Public Members
-
std::size_t index = 0#
-
inline std::string name() const#
-
struct gqa_parameters#
- #include <migraphx/op/group_query_attention.hpp>
Public Members
-
std::size_t batch_size = 0#
-
std::size_t sequence_length = 0#
-
std::size_t head_size = 0#
-
std::size_t rotary_embedding_dim = 0#
-
std::size_t num_heads = 0#
-
std::size_t max_sequence_length = 0#
-
std::size_t head_stride = 0#
-
std::size_t seq_stride = 0#
-
std::size_t batch_stride = 0#
-
bool position_ids_use_batch = false#
-
std::size_t seqlen_present_kv_cache = 0#
-
std::size_t batch_size = 0#
-
struct group_query_attention#
- #include <migraphx/op/group_query_attention.hpp>
Public Functions
-
inline std::string name() const#
-
template<class T>
inline void run_rotary_embedding(T input, T cos_cache, T sin_cache, T output, bool interleaved, const std::size_t *pos_ids, gqa_parameters parameters) const#
-
template<class T>
inline void pack_v_into_rotary_qkv(gqa_parameters parameters, const T input, T output) const#
-
template<typename T>
inline T concat_state_chunk(const T past, const T chunk, T present, std::size_t present_buff_chunk_length, std::size_t past_buff_chunk_length, std::size_t past_chunk_length, std::size_t new_chunk_length, bool is_prompt, bool past_present_share_buffer, std::ptrdiff_t i) const#
-
template<class T, class U>
inline void calculate_attention_probs(T attention_probs, T query, T key, U seqlens_k, T past_key, T present_key, shape::type_t dtype, gqa_parameters params) const#
-
template<class T, class U, class W>
inline void calculate_attention_score(T output, const W attention_probs, const T val, const U seqlens_k, const T past_value, T present_value, shape::type_t dtype, gqa_parameters params) const#
-
inline std::string name() const#
-
struct gru#
- #include <migraphx/op/gru.hpp>
Public Functions
-
inline std::string name() const#
Public Members
-
rnn_direction direction = rnn_direction::forward#
-
float clip = 0.0f#
-
int linear_before_reset = 0#
-
inline std::string name() const#
-
struct highest#
- #include <migraphx/op/reduce_op.hpp>
-
struct identity#
- #include <migraphx/op/identity.hpp>
-
struct im2col#
- #include <migraphx/op/im2col.hpp>
-
struct layout : public migraphx::internal::op::unary<layout>#
- #include <migraphx/op/layout.hpp>
Public Functions
-
inline auto apply() const#
Public Members
-
std::vector<int64_t> permutation#
-
inline auto apply() const#
-
struct leaky_relu : public migraphx::internal::op::unary<leaky_relu>#
- #include <migraphx/op/leaky_relu.hpp>
Public Functions
-
inline std::string point_op() const#
-
inline std::string name() const#
-
inline auto apply() const#
Public Members
-
float alpha = 0.01#
-
inline std::string point_op() const#
-
struct load#
- #include <migraphx/op/load.hpp>
-
struct log : public migraphx::internal::op::unary<log>#
- #include <migraphx/op/log.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct log2 : public migraphx::internal::op::unary<log2>#
- #include <migraphx/op/log2.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct logical_and : public migraphx::internal::op::binary<logical_and>#
- #include <migraphx/op/logical_and.hpp>
-
struct logical_or : public migraphx::internal::op::binary<logical_or>#
- #include <migraphx/op/logical_or.hpp>
-
struct logical_xor : public migraphx::internal::op::binary<logical_xor>#
- #include <migraphx/op/logical_xor.hpp>
-
struct logsoftmax#
- #include <migraphx/op/logsoftmax.hpp>
Public Functions
-
inline value attributes() const#
-
inline std::string name() const#
-
inline auto output() const#
Public Members
-
int64_t axis = 1#
-
inline value attributes() const#
-
struct loop#
- #include <migraphx/op/loop.hpp>
Public Functions
-
inline std::string name() const#
-
struct ref_loop#
- #include <migraphx/op/loop.hpp>
Public Functions
-
inline void append(const std::vector<argument> &iter_state, const std::vector<argument> &concatenated_outputs, const std::vector<int64_t> &scan_output_dirs, int64_t curr_iter, int64_t num_iters) const#
-
inline std::unordered_map<std::string, int> get_output_params(const module&) const#
Public Members
-
int64_t max_iterations = 0#
-
inline void append(const std::vector<argument> &iter_state, const std::vector<argument> &concatenated_outputs, const std::vector<int64_t> &scan_output_dirs, int64_t curr_iter, int64_t num_iters) const#
-
inline std::string name() const#
-
struct lowest#
- #include <migraphx/op/reduce_op.hpp>
-
struct lstm#
- #include <migraphx/op/lstm.hpp>
Public Functions
-
inline std::string name() const#
Public Members
-
rnn_direction direction = rnn_direction::forward#
-
float clip = 0.0f#
-
int input_forget = 0#
-
inline std::string name() const#
-
struct multibroadcast#
- #include <migraphx/op/multibroadcast.hpp>
Broadcast multiple dimensions between two tensors. Two versions of this operator: 1 input and 2+ inputs. One input version uses output_lens attribute and broadcasts to it. 2+ inputs version broadcasts first input to the common shape at evaluation time.
Public Functions
-
inline std::string name() const#
Public Members
-
std::vector<std::size_t> output_lens = {}#
-
inline std::string name() const#
-
struct multinomial#
- #include <migraphx/op/multinomial.hpp>
Public Functions
-
inline std::string name() const#
-
inline std::string name() const#
-
struct nearbyint : public migraphx::internal::op::unary<nearbyint>#
- #include <migraphx/op/nearbyint.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct nonmaxsuppression#
- #include <migraphx/op/nonmaxsuppression.hpp>
Public Functions
-
inline std::string name() const#
-
template<class T>
inline std::vector<std::pair<double, int64_t>> filter_boxes_by_score(T scores_start, std::size_t num_boxes, double score_threshold) const#
-
inline std::string name() const#
-
struct nonzero#
- #include <migraphx/op/nonzero.hpp>
-
struct one#
- #include <migraphx/op/reduce_op.hpp>
-
struct onehot#
- #include <migraphx/op/onehot.hpp>
Produces a one-hot tensor. Called with
axis
attribute that defaults to the last output axis Constant depth:onehot(indices, values), depth attribute must be set; Variable depth:
onehot(indices, depth, values);
indiciesas a N rank tensor of indices where value is
on_valuescalar with the number of classes for the one-hot dimension
values[off_value, on_value]which axis to add the one-hot dimension to For axis = 0 and rank(indices) = 2: output is A[indicies[j, k], j, k] = on_value; A[i, j, k] = off_value otherwise Can be simplified to other operators when
indiceshas a static shape and
depth` is constant at compile-time.Public Functions
-
inline std::string name() const#
-
inline std::string name() const#
-
template<class Derived>
struct op_name# - #include <migraphx/op/name.hpp>
Create name from class.
Subclassed by migraphx::internal::op::binary< add >, migraphx::internal::op::binary< bitwise_and >, migraphx::internal::op::binary< div >, migraphx::internal::op::binary< equal >, migraphx::internal::op::binary< fmod >, migraphx::internal::op::binary< greater >, migraphx::internal::op::binary< less >, migraphx::internal::op::binary< logical_and >, migraphx::internal::op::binary< logical_or >, migraphx::internal::op::binary< logical_xor >, migraphx::internal::op::binary< max >, migraphx::internal::op::binary< min >, migraphx::internal::op::binary< mod >, migraphx::internal::op::binary< mul >, migraphx::internal::op::binary< pow >, migraphx::internal::op::binary< prelu >, migraphx::internal::op::binary< sqdiff >, migraphx::internal::op::binary< sub >, migraphx::internal::op::prefix_scan_op< prefix_scan_sum >, migraphx::internal::op::reduce_op< reduce_all >, migraphx::internal::op::reduce_op< reduce_any >, migraphx::internal::op::reduce_op< reduce_max >, migraphx::internal::op::reduce_op< reduce_mean >, migraphx::internal::op::reduce_op< reduce_min >, migraphx::internal::op::reduce_op< reduce_prod >, migraphx::internal::op::reduce_op< reduce_sum >, migraphx::internal::op::scatter_op< scatter_add >, migraphx::internal::op::scatter_op< scatter_max >, migraphx::internal::op::scatter_op< scatter_min >, migraphx::internal::op::scatter_op< scatter_mul >, migraphx::internal::op::scatter_op< scatter_none >, migraphx::internal::op::scatternd_op< scatternd_add >, migraphx::internal::op::scatternd_op< scatternd_max >, migraphx::internal::op::scatternd_op< scatternd_min >, migraphx::internal::op::scatternd_op< scatternd_mul >, migraphx::internal::op::scatternd_op< scatternd_none >, migraphx::internal::op::unary< abs >, migraphx::internal::op::unary< acos >, migraphx::internal::op::unary< acosh >, migraphx::internal::op::unary< asin >, migraphx::internal::op::unary< asinh >, migraphx::internal::op::unary< atan >, migraphx::internal::op::unary< atanh >, migraphx::internal::op::unary< ceil >, migraphx::internal::op::unary< convert >, migraphx::internal::op::unary< cos >, migraphx::internal::op::unary< cosh >, migraphx::internal::op::unary< elu >, migraphx::internal::op::unary< erf >, migraphx::internal::op::unary< exp >, migraphx::internal::op::unary< floor >, migraphx::internal::op::unary< isinf >, migraphx::internal::op::unary< isnan >, migraphx::internal::op::unary< layout >, migraphx::internal::op::unary< leaky_relu >, migraphx::internal::op::unary< log >, migraphx::internal::op::unary< log2 >, migraphx::internal::op::unary< nearbyint >, migraphx::internal::op::unary< neg >, migraphx::internal::op::unary< recip >, migraphx::internal::op::unary< relu >, migraphx::internal::op::unary< rsqrt >, migraphx::internal::op::unary< sigmoid >, migraphx::internal::op::unary< sign >, migraphx::internal::op::unary< sin >, migraphx::internal::op::unary< sinh >, migraphx::internal::op::unary< sqrt >, migraphx::internal::op::unary< tan >, migraphx::internal::op::unary< tanh >, migraphx::internal::op::unary< unary_not >, migraphx::internal::op::binary< Derived >, migraphx::internal::op::prefix_scan_op< Derived >, migraphx::internal::op::reduce_op< Derived >, migraphx::internal::op::scatter_op< Derived >, migraphx::internal::op::scatternd_op< Derived >, migraphx::internal::op::unary< Derived >
Public Functions
-
inline std::string name() const#
-
inline std::string name() const#
-
struct outline#
- #include <migraphx/op/outline.hpp>
Public Functions
-
inline std::string name() const#
-
inline std::string name() const#
-
struct pad#
- #include <migraphx/op/pad.hpp>
Public Types
-
struct pointwise#
- #include <migraphx/op/pointwise.hpp>
Public Functions
-
inline std::string name() const#
-
inline std::string name() const#
-
struct pooling#
- #include <migraphx/op/pooling.hpp>
Public Functions
-
inline std::string name() const#
-
inline void check_attribute_size() const#
-
inline size_t kdims() const#
-
inline value attributes() const#
-
inline std::size_t dilate_dim(std::size_t dim, std::size_t dilation) const#
-
inline std::vector<std::size_t> calc_spatial_dim_out(const std::vector<std::size_t> &input_lens, std::size_t kdims) const#
Public Members
-
pooling_mode mode = {pooling_mode::average}#
-
std::vector<std::size_t> padding = {0, 0}#
-
std::vector<std::size_t> stride = {1, 1}#
-
std::vector<std::size_t> lengths = {1, 1}#
-
std::vector<std::size_t> dilations = {1, 1}#
-
bool ceil_mode = false#
-
int lp_order = 2#
-
padding_mode_t padding_mode = padding_mode_t::default_#
-
bool dyn_global = false#
-
bool count_include_pad = false#
-
struct avg_pool#
- #include <migraphx/op/pooling.hpp>
-
struct lpnorm_pool#
- #include <migraphx/op/pooling.hpp>
Public Functions
-
lpnorm_pool() = delete#
-
inline explicit lpnorm_pool(int x)#
-
template<class T>
inline double init() const#
-
inline double operator()(double x, double y) const#
-
inline double final(double x, std::size_t) const#
Public Members
-
int p = 0#
-
lpnorm_pool() = delete#
-
struct max_pool#
- #include <migraphx/op/pooling.hpp>
-
inline std::string name() const#
-
struct pow : public migraphx::internal::op::binary<pow>#
- #include <migraphx/op/pow.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
template<class Derived>
struct prefix_scan_op : public migraphx::internal::op::op_name<Derived># - #include <migraphx/op/prefix_scan_op.hpp>
Parent struct for prefix scan operations. A prefix scan is equivalent to the C++ std::exclusive_scan or std::inclusive_scan. Given a list of numbers, a prefix scan sum op returns an equal size list of running totals of the values. Other operations besides addition can be supported by their own child ops.
-
struct prefix_scan_sum : public migraphx::internal::op::prefix_scan_op<prefix_scan_sum>#
- #include <migraphx/op/prefix_scan_sum.hpp>
-
struct quant_convolution#
- #include <migraphx/op/quant_convolution.hpp>
Public Functions
-
inline value attributes() const#
-
inline std::string name() const#
-
inline void check_attribute_size() const#
-
inline size_t kdims() const#
-
inline value attributes() const#
-
struct quant_dot#
- #include <migraphx/op/quant_dot.hpp>
-
struct quantizelinear#
- #include <migraphx/op/quantizelinear.hpp>
-
struct random_seed#
- #include <migraphx/op/random_seed.hpp>
Generates a random seed for the use of random number generators. Generating the seed at runtime guarantees there will be a different random sequence on every execution. This operation has no inputs or attributes, and outputs an unsigned integer tensor with a single value.
Public Functions
-
inline std::string name() const#
-
inline std::string name() const#
-
struct random_uniform#
- #include <migraphx/op/random_uniform.hpp>
random_uniform populates the passed shape with random numbers, in a uniform distribution. Range for floating-point data types is (0, 1); for integer types it is [0, <max value for the type>]
-
struct reduce_all : public migraphx::internal::op::reduce_op<reduce_all>#
- #include <migraphx/op/reduce_all.hpp>
-
struct reduce_any : public migraphx::internal::op::reduce_op<reduce_any>#
- #include <migraphx/op/reduce_any.hpp>
-
struct reduce_max : public migraphx::internal::op::reduce_op<reduce_max>#
- #include <migraphx/op/reduce_max.hpp>
-
struct reduce_mean : public migraphx::internal::op::reduce_op<reduce_mean>#
- #include <migraphx/op/reduce_mean.hpp>
-
struct reduce_min : public migraphx::internal::op::reduce_op<reduce_min>#
- #include <migraphx/op/reduce_min.hpp>
-
template<class Derived>
struct reduce_op : public migraphx::internal::op::op_name<Derived># - #include <migraphx/op/reduce_op.hpp>
Public Functions
-
inline value attributes() const#
-
inline shape collapse_reduced_axes(const shape &original_shape, const std::vector<int64_t> &reduce_axes) const#
-
inline shape normalize_compute_shape(std::vector<shape> inputs) const#
returns a shape in which the axis or axes named for reduction by this op are set, to size 1.
- Parameters:
inputs – list of input shapes
- Returns:
shape
-
template<class T>
inline void tune_dims(const std::vector<int64_t> &tuned_axes, const std::vector<T> &in_lens, std::vector<T> &out_lens) const#
-
template<class T>
inline void reduce(const tensor_view<T> &input, const shape &batch_shape, const std::vector<int64_t> &tuned_axes, const std::vector<std::size_t> &out_idx, tensor_view<T> &output) const#
-
inline argument reduce(const shape &computed_shape, const std::vector<int64_t> &reduce_axes, argument &data_arg) const#
-
inline auto init() const#
-
inline auto input() const#
-
inline reduce_op()#
-
inline reduce_op(std::vector<int64_t> ax)#
Public Members
-
std::vector<std::int64_t> axes = {}#
-
inline value attributes() const#
-
struct reduce_prod : public migraphx::internal::op::reduce_op<reduce_prod>#
- #include <migraphx/op/reduce_prod.hpp>
-
struct reduce_sum : public migraphx::internal::op::reduce_op<reduce_sum>#
- #include <migraphx/op/reduce_sum.hpp>
-
struct reshape#
- #include <migraphx/op/reshape.hpp>
1 input version: reshape(input_data) this.dims = output_dims Makes a copy of input_data to the output shape.
2 input version: reshape(input_data, output_buffer) this.dims = unset Copies input_data to output_buffer; output_buffer already has the output shape. This version will not fail gracefully if the input shape and output_buffer shape are incompatible. There’s a throw that will catch when the number of elements do not match at runtime. This version should only be used for dynamic reshapes (output dimensions only known at runtime). If output_buffer has a static shape during compile/parse, you can use the 1 input version.
Public Functions
-
inline std::string name() const#
Public Members
-
std::vector<int64_t> dims#
-
inline std::string name() const#
-
struct reshape_lazy#
- #include <migraphx/op/reshape_lazy.hpp>
Public Members
-
std::vector<int64_t> dims#
Public Static Functions
-
template<class Iterator>
static inline auto compute_end_dim(Iterator start, Iterator last, std::size_t dim)#
-
template<class OptionalPair>
static inline OptionalPair try_merge_pairs(OptionalPair p2, OptionalPair p1)#
-
template<class DimIterator, class StrideIterator>
static inline optional<std::size_t> merge_strides(DimIterator dim_start, DimIterator dim_last, StrideIterator stride_start, StrideIterator stride_last)#
-
template<class DimIterator, class StrideIterator>
static inline auto can_strides_merge(DimIterator dim_start, DimIterator dim_last, StrideIterator stride_start, StrideIterator stride_last)#
-
std::vector<int64_t> dims#
-
struct resize#
- #include <migraphx/op/resize.hpp>
The Resize operation mirrors the Onnx Resize operation with some differences. Currently, only Nearest mode is supported. “Axes” and “ROI” attributes not recognized.
Accepts either one or two runtime inputs. Input 0 - data to be resized Input 1 - sizes or scales. If data type is uint64, Input 1 is interpreted as output sizes; otherwise as scaling factors.
If the second input is not used, either a “sizes” or “scales” attribute must be provided.
Public Functions
-
inline std::string name() const#
-
inline std::string name() const#
-
struct rnn_last_cell_output#
- #include <migraphx/op/rnn_last_cell_output.hpp>
-
struct rnn_last_hs_output#
- #include <migraphx/op/rnn_last_hs_output.hpp>
-
struct rnn_var_sl_last_output#
- #include <migraphx/op/rnn_var_sl_last_output.hpp>
Public Functions
-
inline std::string name() const#
Public Members
-
rnn_direction direction = rnn_direction::forward#
-
inline std::string name() const#
-
struct rnn_var_sl_shift_output#
- #include <migraphx/op/rnn_variable_seq_lens.hpp>
Public Functions
-
inline std::string name() const#
Public Members
-
std::string output_name = "hidden_states"#
-
rnn_direction direction = rnn_direction::forward#
-
inline std::string name() const#
-
struct rnn_var_sl_shift_sequence#
- #include <migraphx/op/rnn_variable_seq_lens.hpp>
-
struct roialign#
- #include <migraphx/op/roialign.hpp>
Public Functions
-
inline std::string name() const#
-
inline auto calc_pos_weight(const std::array<std::size_t, 2> &dims, const shape &comp_s, const std::array<float, 2> &roi_start, const std::array<float, 2> &bin_size, const std::array<std::size_t, 2> &bin_grid_size) const#
-
template<class T, class Op>
inline std::tuple<double, int64_t> calc_pooling(const T &data, const std::array<std::size_t, 2> &bin_grid_size, const std::vector<pos_weight> &pos_weights, int64_t index, Op op) const#
Public Members
-
std::string coord_trans_mode = "half_pixel"#
-
pooling_mode mode = {pooling_mode::average}#
-
int64_t output_height = 1#
-
int64_t output_width = 1#
-
int64_t sampling_ratio = 0#
-
float spatial_scale = 1.0f#
-
struct avg_pool#
- #include <migraphx/op/roialign.hpp>
-
struct max_pool#
- #include <migraphx/op/roialign.hpp>
-
struct pos_weight#
- #include <migraphx/op/roialign.hpp>
-
inline std::string name() const#
-
struct rsqrt : public migraphx::internal::op::unary<rsqrt>#
- #include <migraphx/op/rsqrt.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct run_on_target#
- #include <migraphx/op/run_on_target.hpp>
Public Functions
-
inline std::string name() const#
Public Members
-
std::size_t target_id = 0#
-
inline std::string name() const#
-
struct scalar#
- #include <migraphx/op/scalar.hpp>
Public Functions
-
inline std::string name() const#
Public Members
-
std::vector<std::size_t> scalar_bcast_lens#
-
inline std::string name() const#
-
struct scan_slice : public migraphx::internal::op::op_name<scan_slice>#
- #include <migraphx/op/scan_slice.hpp>
Public Functions
-
inline value attributes() const#
-
inline value attributes() const#
-
struct scatter_add : public migraphx::internal::op::scatter_op<scatter_add>#
- #include <migraphx/op/scatter_add.hpp>
Public Functions
-
inline auto reduction() const#
-
inline auto reduction() const#
-
struct scatter_max : public migraphx::internal::op::scatter_op<scatter_max>#
- #include <migraphx/op/scatter_max.hpp>
Public Functions
-
inline auto reduction() const#
-
inline auto reduction() const#
-
struct scatter_min : public migraphx::internal::op::scatter_op<scatter_min>#
- #include <migraphx/op/scatter_min.hpp>
Public Functions
-
inline auto reduction() const#
-
inline auto reduction() const#
-
struct scatter_mul : public migraphx::internal::op::scatter_op<scatter_mul>#
- #include <migraphx/op/scatter_mul.hpp>
Public Functions
-
inline auto reduction() const#
-
inline auto reduction() const#
-
struct scatter_none : public migraphx::internal::op::scatter_op<scatter_none>#
- #include <migraphx/op/scatter_none.hpp>
Public Functions
-
inline auto reduction() const#
-
inline auto reduction() const#
-
template<typename Derived>
struct scatter_op : public migraphx::internal::op::op_name<Derived># - #include <migraphx/op/scatter_op.hpp>
Public Functions
-
inline value attributes() const#
-
template<class TensorView0, class TensorView1>
inline void scatter_reduce_iterate(TensorView0 indices, TensorView1 output, TensorView1 update) const#
-
inline value attributes() const#
-
struct scatternd_add : public migraphx::internal::op::scatternd_op<scatternd_add>#
- #include <migraphx/op/scatternd_add.hpp>
-
struct scatternd_max : public migraphx::internal::op::scatternd_op<scatternd_max>#
- #include <migraphx/op/scatternd_max.hpp>
-
struct scatternd_min : public migraphx::internal::op::scatternd_op<scatternd_min>#
- #include <migraphx/op/scatternd_min.hpp>
-
struct scatternd_mul : public migraphx::internal::op::scatternd_op<scatternd_mul>#
- #include <migraphx/op/scatternd_mul.hpp>
-
struct scatternd_none : public migraphx::internal::op::scatternd_op<scatternd_none>#
- #include <migraphx/op/scatternd_none.hpp>
-
template<class Derived>
struct scatternd_op : public migraphx::internal::op::op_name<Derived># - #include <migraphx/op/scatternd_op.hpp>
N-dimensional Scatter operations. This struct is parent class to ops which differ in what formula is used to reduce (combine old and new values of) the scattered value. It was originally based on Onnx ScatterND operation (see onnx/onnx) and is also similar to Numpy numpy.add.at().
- Template Parameters:
Derived – a template parameter in the CRTP inheritance idiom, represents one of the child operations.
-
struct select_module#
- #include <migraphx/op/select_module.hpp>
Public Functions
-
inline std::string name() const#
-
inline std::vector<std::string> get_input_parameter_names(module_ref mod) const#
-
inline std::vector<std::string> get_output_parameter_names(module_ref mod) const#
-
inline std::string name() const#
-
struct sin : public migraphx::internal::op::unary<sin>#
- #include <migraphx/op/sin.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct sinh : public migraphx::internal::op::unary<sinh>#
- #include <migraphx/op/sinh.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct slice#
- #include <migraphx/op/slice.hpp>
Slice operator that accepts variable axes, starts and ends. All of
starts
,ends
, andaxes
must be supplied by either their attribute or an input (but not both).Valid calls: slice(input); axes, starts, ends set slice(input, starts); axes, ends set slice(input, ends); starts, axes set slice(input, axes); starts, ends set slice(input, starts, ends); axes set slice(input, starts, axes); ends set slice(input, ends, axes); starts set slice(input, start, ends, axes); none set
Attributes: axes: constant axes to slice over (optional) starts: constant slice starting indices (optional) ends: constant slice ending indices (optional)
Parameters: data: the input tensor to slice (dynamic or static shape) input_starts: starting indices of slice (optional, static shape) input_ends: ending indices of slice (optional, static shape) input_axes: axes to slice over (optional, static shape)
Public Functions
-
inline value attributes() const#
Ensure that attribute axes is within limits. Will attempt to normalize starts and ends; but will use the dynamic_dimension.max values for dynamic shapes. This makes it so you have to renormalize for non-fixed dynamic_dimensions.
-
inline std::string name() const#
-
template<class A, class B>
inline std::vector<std::size_t> lens_calc(const std::vector<std::size_t> &lengths, A in_starts, A in_ends, B in_axes) const# Computes the slice output shape dimensions for given starts, ends,and axes. Templated to also handle tensor views. Possibly different type between [in_starts, in_ends] and [in_axes] if in_axes is this object’s axes attribute. Assumes in_starts and in_ends are normalized; in_axes are valid.
-
inline std::array<bool, 3> get_set_attributes() const#
Get the attributes that are non-empty.
-
inline shape compute_two_or_more(std::vector<shape> inputs) const#
Helper function for normalize_compute_shape()
-
inline auto compute_offset(const shape &s) const#
Calculates the starting offset for the sliced tensor. Used in compute when only data input and all other information are in the attributes.
- Parameters:
s – static input shape
-
template<class T>
inline auto compute_offset(const shape &s, const T &input_starts, const T &ax_vec) const# Calculates the starting offset for the sliced tensor (for aliasing). Used for 2-4 inputs to `slice.
- Parameters:
s – static input shape
input_starts – starting indices of slice
ax_vec – axes to slice on
-
inline std::unordered_map<std::string, std::vector<int64_t>> normalize_starts_ends_axes(shape input_shape, const optional<std::vector<int64_t>> &input_starts, const optional<std::vector<int64_t>> &input_ends, const optional<std::vector<int64_t>> &input_axes) const#
If given, normalize the inputs. Otherwise get from operator attributes. Return the values in a map.
Parameters input_shape: static shape of the input input_starts: optional input_ends: optional input_ends: optional
Public Members
-
std::vector<int64_t> axes = {}#
-
std::vector<int64_t> starts = {}#
-
std::vector<int64_t> ends = {}#
Public Static Attributes
-
static constexpr std::array<bool, 3> all_set = {true, true, true}#
Named arrays for the set attribute possibilities.
-
static constexpr std::array<bool, 3> ends_axes = {false, true, true}#
-
static constexpr std::array<bool, 3> starts_axes = {true, false, true}#
-
static constexpr std::array<bool, 3> starts_ends = {true, true, false}#
-
static constexpr std::array<bool, 3> axes_only = {false, false, true}#
-
static constexpr std::array<bool, 3> ends_only = {false, true, false}#
-
static constexpr std::array<bool, 3> starts_only = {true, false, false}#
-
static constexpr std::array<bool, 3> none_set = {false, false, false}#
-
inline value attributes() const#
-
struct softmax#
- #include <migraphx/op/softmax.hpp>
Public Functions
-
inline value attributes() const#
-
inline std::string name() const#
-
inline auto output() const#
Public Members
-
int64_t axis = 1#
-
inline value attributes() const#
-
struct sqrt : public migraphx::internal::op::unary<sqrt>#
- #include <migraphx/op/sqrt.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct step#
- #include <migraphx/op/step.hpp>
-
struct tan : public migraphx::internal::op::unary<tan>#
- #include <migraphx/op/tan.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct tanh : public migraphx::internal::op::unary<tanh>#
- #include <migraphx/op/tanh.hpp>
Public Functions
-
inline auto apply() const#
-
inline auto apply() const#
-
struct topk#
- #include <migraphx/op/topk.hpp>
-
struct transpose#
- #include <migraphx/op/transpose.hpp>
Public Functions
-
inline std::string name() const#
Public Members
-
std::vector<int64_t> dims#
-
inline std::string name() const#
-
template<class Derived>
struct unary : public migraphx::internal::op::op_name<Derived># - #include <migraphx/op/unary.hpp>
-
struct unary_not : public migraphx::internal::op::unary<unary_not>#
- #include <migraphx/op/unary_not.hpp>
-
struct undefined#
- #include <migraphx/op/undefined.hpp>
-
struct unknown#
- #include <migraphx/op/unknown.hpp>
Public Functions
-
inline std::string name() const#
Public Members
-
std::string op#
-
inline std::string name() const#
-
struct unsqueeze#
- #include <migraphx/op/unsqueeze.hpp>
Adds dimensions to a tensor based on the axes attribute.
axes
are based on the number of output shape dimensions and should not contain duplicates.steps
are for modifying dimensions added to the middle of the original shape. Each step must be a factor of the original dimension. ex: unsqueeze(shape = [3, 4, 10], axes = [2, 4, 5], steps = [2]) -> shape = [3, 4, 2, 5, 1, 1] Dynamic shape version does not handlesteps
.
-
struct where#
- #include <migraphx/op/where.hpp>
-
struct zero#
- #include <migraphx/op/reduce_op.hpp>
-
enum class normalize_attribute#