# Program

## instruction

struct migraphx::internal::instruction

  Public Functions

  inline instruction()
  instruction( operation o, shape r, std::vector< instruction_ref > args)
  instruction( operation o, shape r, std::vector< instruction_ref > args, std::vector<module_ref> modules)
  instruction( literal l)
  void replace( operation o)
  void recompute_shape()
  void clear_arguments()
  bool valid( instruction_ref start, bool check_order = false) const
  bool valid() const
  shape get_shape() const
  const literal &get_literal() const
  const operation &get_operator() const
  std::string name() const
  const std::vector< instruction_ref > &inputs() const
  const std::vector<module_ref> &module_inputs() const
  const std::vector< instruction_ref > &outputs() const
  void add_output( instruction_ref ins)
  template<class T>
  inline void remove_output(const T &ins)
  bool can_eval() const
  argument eval(bool check_eval = true) const
  void finalize(context &ctx)
  void set_normalized(bool value = true)
  bool is_normalized() const
  bool need_normalization() const
  operation normalized_operator() const
  void debug_print() const

  Public Static Functions

  static void replace_refs( instruction_ref ins, const std::unordered_map< instruction_ref , instruction_ref > &map_insts, const std::unordered_map<module_ref, module_ref> &map_mods)
  static void backreference( instruction_ref ref)
  static void replace_argument( instruction_ref ins, instruction_ref old, instruction_ref new_ins)
  static void replace_mod_argument( instruction_ref ins, module_ref old, module_ref new_mod)
  static void replace( instruction_ref ins, operation o, const shape &r, std::vector< instruction_ref > args)
  static void replace( instruction_ref ins, operation o, const shape &r, std::vector< instruction_ref > args, std::vector<module_ref> module_args)
  static instruction_ref get_output_alias( instruction_ref ins, bool shallow = false)
  static void print(std::ostream &os, instruction_ref ins, const std::unordered_map< instruction_ref , std::string> &names)

  Friends

  friend friend bool operator== (const instruction &i, instruction_ref ref)
  friend friend bool operator== (const instruction &x, const instruction &y)
  friend friend bool operator!= (const instruction &x, const instruction &y)
  friend friend bool operator== (instruction_ref ref, const instruction &i)
  friend friend bool operator!= (const instruction &i, instruction_ref ref)
  friend friend bool operator!= (instruction_ref ref, const instruction &i)

## instruction_ref

type migraphx::internal::instruction_ref

  References an instruction in the program.

## program

struct migraphx::internal::program

  Stores the instruction stream.

  Public Functions

  program()
  program( program &&) noexcept
  program(const program &)
  program &operator=( program )
  ~program() noexcept
  std::vector<std::string> get_parameter_names() const
  shape get_parameter_shape(std::string name) const
  instruction_ref get_parameter(std::string name) const
  std::unordered_map<std::string, shape > get_parameter_shapes() const
  std::vector< argument > eval(parameter_map params) const
  std::size_t size() const
  std::vector< shape > get_output_shapes() const
  context &get_context() const
  instruction_ref validate() const
  void compile(const target &t, compile_options options = compile_options{})
  bool is_compiled() const
  void finalize()
  void perf_report(std::ostream &os, std::size_t n, parameter_map params, std::size_t batch = 1) const
  void mark(const parameter_map &params, marker &&m)
  value to_value() const
  void from_value(const value &v)
  void debug_print() const
  void debug_print( instruction_ref ins) const
  void print(std::unordered_map< instruction_ref , std::string> &names, const std::function<void( instruction_ref , std::unordered_map< instruction_ref , std::string>)> &print_func) const
  void print_graph(std::ostream &os, bool brief = false) const
  void print_cpp(std::ostream &os) const
  void dry_run(parameter_map params) const
  void annotate(std::ostream &os, const std::function<void( instruction_ref )> &a) const
  program &sort()
  module *create_module(const std::string &name)
  module *get_module(const std::string &name)
  const module *get_module(const std::string &name) const
  module *get_main_module()
  const module *get_main_module() const
  std::vector<const module*> get_modules() const
  std::vector<module*> get_modules()
  void remove_module(const std::string &name)
  void remove_unused_modules()

  Friends

  friend friend std::ostream & operator<< (std::ostream &os, const program &p)
  friend friend bool operator== (const program &x, const program &y)
  inline friend friend bool operator!= (const program &x, const program &y)

## parse_onnx

program migraphx::internal::parse_onnx(const std::string &name, const onnx_options & = onnx_options {})

  Create a program from an onnx file.

## parse_tf

program migraphx::internal::parse_tf(const std::string &name, const tf_options &options = tf_options {})

  Create a program from a tf pb file (default is nhwc format)

## onnx_options

struct migraphx::internal::onnx_options

  struct to pass in onnx options to parser

  Public Members

  std::size_t default_dim_value = 1

    default batch size to use (if not specified in onnx file)

  std::unordered_map<std::string, std::vector<std::size_t>> map_input_dims = {}

    Explicitly specify the dims of an input.

  bool skip_unknown_operators = false

    Continue parsing onnx file if an unknown operator is found.

  bool print_program_on_error = false

    Print program if an error occurs.

  int64_t max_loop_iterations = 10

    Max iter num for the loop operator.

## tf_options

struct migraphx::internal::tf_options

  struct to pass in tf options to parser

  Public Members

  bool is_nhwc = false
  unsigned int batch_size = 1
  std::unordered_map<std::string, std::vector<std::size_t>> map_input_dims = {}

    Explicitly specify the dims of an input.

  std::vector<std::string> output_node_names = {}