C++ API reference#
2024-09-30
19 min read time
shape#
-
enum migraphx_shape_datatype_t#
An enum to represent the different data type inputs.
Values:
-
enumerator migraphx_shape_tuple_type#
-
enumerator migraphx_shape_bool_type#
-
enumerator migraphx_shape_half_type#
-
enumerator migraphx_shape_float_type#
-
enumerator migraphx_shape_double_type#
-
enumerator migraphx_shape_uint8_type#
-
enumerator migraphx_shape_int8_type#
-
enumerator migraphx_shape_uint16_type#
-
enumerator migraphx_shape_int16_type#
-
enumerator migraphx_shape_int32_type#
-
enumerator migraphx_shape_int64_type#
-
enumerator migraphx_shape_uint32_type#
-
enumerator migraphx_shape_uint64_type#
-
enumerator migraphx_shape_fp8e4m3fnuz_type#
-
enumerator migraphx_shape_fp8e4m3fn_type#
-
enumerator migraphx_shape_fp8e5m2_type#
-
enumerator migraphx_shape_tuple_type#
-
template<class Lens, class Strides>
struct shape : public migraphx::handle_base<>, public migraphx::equality_comparable<shape<Lens, Strides>># Describe shape of tensor.
A shape consists of a data type, lengths of multi-dimension tensor, and strides
Public Functions
-
inline shape()#
-
inline shape(const migraphx_shape *p)#
-
template<class HandleType, class Lifetime, class = typename std::enable_if<std::is_convertible<HandleType*, handle_type*>{}>::type>
inline shape(HandleType *p, Lifetime lifetime)#
-
inline shape(migraphx_shape_datatype_t type)#
Construct a scalar shape.
-
inline shape(migraphx_shape_datatype_t type, std::vector<size_t> plengths)#
Construct a shape with its type and lengths. The strides are automatically computed assumming a packed layout.
-
inline shape(migraphx_shape_datatype_t t, std::initializer_list<std::size_t> d)#
-
inline shape(migraphx_shape_datatype_t type, std::vector<size_t> plengths, std::vector<size_t> pstrides)#
-
inline shape(migraphx_shape_datatype_t type, const dynamic_dimensions &dyn_dims)#
-
inline std::vector<size_t> lengths() const#
-
inline std::vector<size_t> strides() const
-
inline dynamic_dimensions dyn_dims() const#
Get the dynamic dimensions of the shape.
-
inline migraphx_shape_datatype_t type() const#
-
inline size_t elements() const#
-
inline size_t bytes() const#
-
inline bool standard() const#
-
inline bool dynamic() const#
Is the shape dynamic.
-
inline size_t index(size_t i) const#
-
constexpr shape() = default
-
inline constexpr auto elements() const
-
inline constexpr auto element_space() const#
-
inline constexpr auto packed() const#
-
inline constexpr auto broadcasted() const#
-
inline constexpr auto transposed() const#
-
inline constexpr auto skips() const#
-
inline constexpr auto standard() const
-
inline constexpr index_int index(index_array x) const#
-
inline constexpr index_int index(index_int i) const#
-
inline constexpr index_int compute_index(index_int i) const#
-
inline constexpr index_array multi(index_int idx) const#
Convert single index into a multi-index.
-
inline constexpr index_int single(index_array idx) const#
Convert multi-index into a single index.
-
inline shape()#
argument#
-
struct argument : public migraphx::handle_base<>#
Arguments to be passed to an migraphx arguments.
An
argument
represents a raw buffer of data with a shape.Public Functions
-
inline argument()#
-
template<class HandleType, class Lifetime, class = typename std::enable_if<std::is_convertible<HandleType*, handle_type*>{}>::type>
inline argument(HandleType *p, Lifetime lifetime)#
-
inline argument(const migraphx_argument *p)#
-
inline char *data() const#
Public Static Functions
-
inline argument()#
target#
-
struct target : public migraphx::handle_base<>#
A target for compilation.
Public Functions
-
inline target()#
-
template<class HandleType, class Lifetime, class = typename std::enable_if<std::is_convertible<HandleType*, handle_type*>{}>::type>
inline target(HandleType *p, Lifetime lifetime)#
-
inline target(const char *name)#
Construct a target from its name.
-
inline target()#
program#
-
struct program_parameter_shapes : public migraphx::handle_base<>#
Public Functions
-
inline program_parameter_shapes()#
-
template<class HandleType, class Lifetime, class = typename std::enable_if<std::is_convertible<HandleType*, handle_type*>{}>::type>
inline program_parameter_shapes(HandleType *p, Lifetime lifetime)#
-
inline size_t size() const#
-
inline std::vector<const char*> names() const#
-
inline program_parameter_shapes()#
-
struct program_parameters : public migraphx::handle_base<>#
A class to construct the inputs parameters for a program.
Public Functions
-
template<class HandleType, class Lifetime, class = typename std::enable_if<std::is_convertible<HandleType*, handle_type*>{}>::type>
inline program_parameters(HandleType *p, Lifetime lifetime)#
-
inline program_parameters(migraphx_program_parameters *p)#
-
inline program_parameters()#
-
template<class HandleType, class Lifetime, class = typename std::enable_if<std::is_convertible<HandleType*, handle_type*>{}>::type>
-
struct program : public migraphx::handle_base<>#
A program represents the all computation graphs to be compiled and executed.
Public Functions
-
inline program()#
-
template<class HandleType, class Lifetime, class = typename std::enable_if<std::is_convertible<HandleType*, handle_type*>{}>::type>
inline program(HandleType *p, Lifetime lifetime)#
-
inline void compile(const target &ptarget, const compile_options &poptions) const#
Compile the program for a specific target to be ran on.
-
inline void compile(const target &ptarget) const#
Compile the program for a specific target to be ran on.
-
inline program_parameter_shapes get_parameter_shapes() const#
Return the shapes for the input parameters.
-
inline shapes get_output_shapes() const#
Get the shapes of all the outputs returned by this program.
-
inline arguments eval(const program_parameters &pparams) const#
Run the program using the inputs passed in.
-
template<class Stream>
inline arguments run_async(const program_parameters &pparams, Stream *s) const# Overloaded to allow for execution_environment input.
-
inline void print() const#
-
call &migraphx_program_get_main_module()#
-
inline context experimental_get_context()#
- call & migraphx_program_create_module (), name.data()
Public Members
- return module = {p_modu, this->share_handle()}
-
inline program()#
quantize#
-
struct quantize_op_names : public migraphx::handle_base<>#
Public Functions
-
inline quantize_op_names()#
-
template<class HandleType, class Lifetime, class = typename std::enable_if<std::is_convertible<HandleType*, handle_type*>{}>::type>
inline quantize_op_names(HandleType *p, Lifetime lifetime)#
-
inline void add(const std::string &name)#
-
inline quantize_op_names()#
-
inline void migraphx::quantize_fp16(const program &prog, const quantize_op_names &names)#
Quantize program to use fp16.
-
struct quantize_int8_options : public migraphx::handle_base<>#
Options to be passed when quantizing for int8.
Public Functions
-
inline quantize_int8_options()#
-
template<class HandleType, class Lifetime, class = typename std::enable_if<std::is_convertible<HandleType*, handle_type*>{}>::type>
inline quantize_int8_options(HandleType *p, Lifetime lifetime)#
-
inline void add_op_name(const std::string &name)#
Add an operator that should be quantized.
-
inline void add_calibration_data(const program_parameters &pp)#
Add calibrartion data to be used for quantizing.
-
inline quantize_int8_options()#
parse_onnx#
-
struct onnx_options : public migraphx::handle_base<>#
Options for parsing onnx options.
Public Functions
-
inline onnx_options()#
-
template<class HandleType, class Lifetime, class = typename std::enable_if<std::is_convertible<HandleType*, handle_type*>{}>::type>
inline onnx_options(HandleType *p, Lifetime lifetime)#
-
inline void set_input_parameter_shape(const std::string &name, std::vector<std::size_t> dim)#
Make onnx parser treat an inputs with a certain dimensions.
-
inline void set_dyn_input_parameter_shape(const std::string &name, const dynamic_dimensions &dyn_dims)#
-
inline void set_default_dim_value(unsigned int value)#
When there is a dimension parameter, then use this default value.
-
inline void set_default_dyn_dim_value(const dynamic_dimension &dd)#
-
inline void set_default_loop_iterations(int64_t value)#
Set default max iteration number for the loop operator.
-
inline void set_limit_loop_iterations(int64_t value)#
Set max iteration limit for the loop operator.
-
inline void set_external_data_path(const std::string &external_data_path)#
Set absolute path for external data files.
-
inline onnx_options()#
-
inline program migraphx::parse_onnx(const char *filename)#
Parse an onnx file into a migraphx program.
-
inline program migraphx::parse_onnx(const char *filename, const migraphx::onnx_options &options)#
Parse an onnx file into a migraphx program.
-
inline program migraphx::parse_onnx_buffer(const std::string &buffer)#
Parse a buffer of memory as an onnx file.
-
inline program migraphx::parse_onnx_buffer(const std::string &buffer, const migraphx::onnx_options &options)#
Parse a buffer of memory as an onnx file.
-
inline program migraphx::parse_onnx_buffer(const void *data, size_t size)#
Parse a buffer of memory as an onnx file.
-
inline program migraphx::parse_onnx_buffer(const void *data, size_t size, const migraphx::onnx_options &options)#
Parse a buffer of memory as an onnx file.
load#
-
struct file_options : public migraphx::handle_base<>#
Public Functions
-
template<class HandleType, class Lifetime, class = typename std::enable_if<std::is_convertible<HandleType*, handle_type*>{}>::type>
inline file_options(HandleType *p, Lifetime lifetime)#
-
inline file_options()#
-
inline void set_file_format(const char *format)#
-
template<class HandleType, class Lifetime, class = typename std::enable_if<std::is_convertible<HandleType*, handle_type*>{}>::type>
-
inline program migraphx::load(const char *filename, const file_options &options)#
Load a saved migraphx program from a file.
save#
-
inline void migraphx::save(const program &p, const char *filename, const file_options &options)#
Save a program to a file.