C++ Reference

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
struct migraphx::shape : public migraphx::handle_base<>

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)
inline shape(migraphx_shape *p, own)
inline shape(migraphx_shape *p, borrow)
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 type, std::vector<size_t> plengths, std::vector<size_t> pstrides)
inline std::vector<size_t> lengths() const
inline std::vector<size_t> strides() const
inline migraphx_shape_datatype_t type() const
inline size_t bytes() const

Friends

inline friend friend bool operator== (const shape &px, const shape &py)
inline friend friend bool operator!= (const shape &px, const shape &py)

argument

struct migraphx::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()
inline argument(migraphx_argument *p, borrow)
inline argument(migraphx_argument *p, own)
inline argument(const migraphx_argument *p)
inline argument(shape pshape, void *pbuffer)
inline shape get_shape() const
inline char *data() const

Public Static Functions

static inline argument generate(shape ps, size_t pseed = 0)

Generate an argument using random data.

Friends

inline friend friend bool operator== (const argument &px, const argument &py)
inline friend friend bool operator!= (const argument &px, const argument &py)

target

struct migraphx::target : public migraphx::handle_base<>

A target for compilation.

Public Functions

inline target()
inline target(migraphx_target *p, own)
inline target(migraphx_target *p, borrow)
inline target(const char *name)

Construct a target from its name.

program

struct migraphx::program_parameter_shapes : public migraphx::handle_base<>

Public Functions

inline program_parameter_shapes()
inline program_parameter_shapes(migraphx_program_parameter_shapes *p, own)
inline program_parameter_shapes(migraphx_program_parameter_shapes *p, borrow)
inline size_t size() const
inline shape operator[](const char *pname) const
inline std::vector<const char*> names() const
struct migraphx::program_parameters : public migraphx::handle_base<>

A class to construct the inputs parameters for a program.

Public Functions

inline program_parameters(migraphx_program_parameters *p, own)
inline program_parameters(migraphx_program_parameters *p, borrow)
inline program_parameters(migraphx_program_parameters *p)
inline program_parameters()
inline program_parameters(std::initializer_list<std::pair<std::string, argument>> l)

Construct the parameters from initializer_list.

inline void add(const char *pname, const argument &pargument) const

Add a new parameter.

struct migraphx_compile_options

Public Functions

template<class ...Ts>
inline migraphx_compile_options(Ts&&... xs)

Public Members

migraphx::compile_options object
struct migraphx::program : public migraphx::handle_base<>

A program represents the all computation graphs to be compiled and executed.

Public Functions

inline program()
inline program(migraphx_program *p, own)
inline program(migraphx_program *p, borrow)
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.

inline void print() const
inline program sort()
inline module get_main_module()

Friends

inline friend friend bool operator== (const program &px, const program &py)
inline friend friend bool operator!= (const program &px, const program &py)

quantize

struct migraphx::quantize_op_names : public migraphx::handle_base<>

Public Functions

inline quantize_op_names()
inline quantize_op_names(migraphx_quantize_op_names *p, own)
inline void add(const std::string &name)
inline void migraphx::quantize_fp16(const program &prog)

Quantize program to use fp16.

inline void migraphx::quantize_fp16(const program &prog, const quantize_op_names &names)

Quantize program to use fp16.

struct migraphx::quantize_int8_options : public migraphx::handle_base<>

Options to be passed when quantizing for int8.

Public Functions

inline quantize_int8_options()
inline quantize_int8_options(migraphx_quantize_int8_options *p, own)
inline quantize_int8_options(migraphx_quantize_int8_options *p, borrow)
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.

Public Members

std::vector<parameter_map> calibration = {}
std::vector<std::string> op_names = {}
inline void migraphx::quantize_int8(const program &prog, const target &ptarget, const quantize_int8_options &options)

Quantize program to use int8.

parse_onnx

struct migraphx::onnx_options : public migraphx::handle_base<>

Options for parsing onnx options.

Public Functions

inline onnx_options()
inline onnx_options(migraphx_onnx_options *p, own)
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_default_dim_value(unsigned int value)

When there is a dimension parameter, then use this default value.

inline void set_default_loop_iterations(int64_t value)

Set default max iteration number for the loop operator.

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 migraphx_file_options

Public Functions

template<class ...Ts>
inline migraphx_file_options(Ts&&... xs)

Public Members

migraphx::file_options object
inline program migraphx::load(const char *filename)

Load a saved migraphx program from a file.

Warning

doxygenfunction: Unable to resolve function “migraphx::load” with arguments (const char*, migraphx_file_options) in doxygen xml output for project “proj” from directory: /code/AMDMIGraphX/build/doc/doxygen/xml. Potential matches:

- program load(const char *filename)
- program load(const char *filename, const file_options &options)

save

inline void migraphx::save(const program &p, const char *filename)

Save a program to a file.

Warning

doxygenfunction: Unable to resolve function “migraphx::save” with arguments (const program&, const char*, migraphx_file_options) in doxygen xml output for project “proj” from directory: /code/AMDMIGraphX/build/doc/doxygen/xml. Potential matches:

- void save(const program &p, const char *filename)
- void save(const program &p, const char *filename, const file_options &options)