Python Reference#
2023-06-14
6 min read time
shape#
- class migraphx.shape(type, lens, strides=None)#
Describes the shape of a tensor. This includes size, layout, and data type/
- migraphx.standard()#
Returns true if the shape is a standard shape. That is, the shape is both packed and not transposed.
- Return type:
argument#
- class migraphx.argument(data)#
Construct an argument from a python buffer. This can include numpy arrays.
target#
- class migraphx.target#
This represents the compiliation target.
program#
- class migraphx.program#
Represents the computation graph to be compiled and run.
- migraphx.get_parameter_shapes()#
Get the shapes of all the input parameters in the program.
- migraphx.compile(t, offload_copy=True, fast_math=True)#
Compiles the program for the target and optimizes it.
- Parameters:
t (target) – This is the target to compile the program for.
offload_copy (bool) – For targets with offloaded memory(such as the gpu), this will insert instructions during compilation to copy the input parameters to the offloaded memory and to copy the final result from the offloaded memory back to main memory.
fast_math (bool) – Optimize math functions to use faster approximate versions. There may be slight accuracy degredation when enabled.
- migraphx.run(params)#
Run the program.
- migraphx.quantize_fp16(prog, ins_names=['all'])#
Quantize the program to use fp16.
- migraphx.quantize_int8(prog, t, calibration=[], ins_names=['dot', 'convolution'])#
Quantize the program to use int8.
parse_onnx#
- migraphx.parse_onnx(filename, default_dim_value=1, map_input_dims={}, skip_unknown_operators=false, print_program_on_error=false)#
Load and parse an onnx file.
- Parameters:
filename (str) – Path to file.
default_dim_value (str) – default batch size to use (if not specified in onnx file).
map_input_dims (str) – Explicitly specify the dims of an input.
skip_unknown_operators (str) – Continue parsing onnx file if an unknown operator is found.
print_program_on_error (str) – Print program if an error occurs.
- Return type: