docstr: Write the C++ type definitions file (defines.h)
  
  Args:
      model (ModelGraph): the hls4ml model.
docstr_tok: ["Write","the","C++","type","definitions","file","(","defines.h",")","Args",":","model","(","ModelGraph",")",":","the","hls4ml","model","."]
code: def write_defines(self, model):
      """Write the C++ type definitions file (defines.h)
  
      Args:
          model (ModelGraph): the hls4ml model.
      """
      filedir = os.path.dirname(os.path.abspath(__file__))
      f = open(
          os.path.join(
              filedir, "../templates/vivado/firmware/defines.h"
          )
      )
      fout = open(
          f"{model.config.get_output_dir()}/firmware/defines.h", "w"
      )
  
      for line in f.readlines():
          # Insert numbers
          if "// hls-fpga-machine-learning insert numbers" in line:
              newline = line
  
              defines_list = []
              for layer in model.get_layers():
                  defines = ""
                  for k, v in layer.get_output_variable().get_shape():
                      defines += f"#define {k} {v}\n"
  
                  defines_list.append(defines)
  
              newline += "".join(defines_list)
  
          elif (
              "// hls-fpga-machine-learning insert layer-precision"
              in line
          ):
              newline = line
              all_precision = OrderedDict()
              for layer in model.get_layers():
                  layer_precision = layer.get_layer_precision()
                  for type_name, type_var in layer_precision.items():
                      # Ensure that layer's types doesn't override existing types
                      # This can happen in case of InplaceVariable types
                      if type_name not in all_precision:
                          all_precision[type_name] = type_var
              for used_type in all_precision.values():
                  newline += used_type.definition_cpp()
  
          else:
              newline = line
          fout.write(newline)
      f.close()
      fout.close()
  
imports: import glob
  import os
  import tarfile
  from collections import OrderedDict
  from shutil import copyfile, copytree, rmtree
  import numpy
  import yaml
  from hls4ml.writer.writers import Writer
label_desc: Use image node_id 6 for calling the VivadoWriter obj's underlying member method code with example usage: obj.write_defines(model) without return types