docstr: Buffer allocation in the accelerator's memory.
  
  Args:
      X_shape (list): Input buffer shape.
      y_shape (list): Output buffer shape.
      dtype (dtype, optional): The data type of the elements of the input/output tensors. Must be an instance of
          numpy dtype. Defaults to np.float32.
  
          It should be set depending on the interface of the accelerator; if it uses 'float'
          data type for the 'data' AXI-Stream field, 'np.float32' dtype must be used. Instead if it uses
          'ap_fixed<A,B>', 'np.intA' is the correct dtype to use. Note that A cannot any integer value, but it can
          assume power of 2 values, i.e., {..., 8, 16, 32, ...}. Check `numpy` documentation for more information.
          In this case the encoding/decoding has to be computed by the host machine. For example for
          'ap_fixed<16,6>' type the following 2 functions are the correct one to use for encode/decode
          'float' -> 'ap_fixed<16,6>'::
  
              def encode(xi):
                  return np.int16(round(xi * 2**10)) # note 2**10 = 2**(A-B)
              def decode(yi):
                  return yi * 2**-10
              encode_v = np.vectorize(encode) # to apply them element-wise
              decode_v = np.vectorize(decode)
  
      trg_in (optional): Input buffer target memory. By default the v++ command set it to HBM[0] for
          alveo-u50. Defaults to None.
      trg_out (optional): Output buffer target memory. By default the v++ command set it to HBM[0] for
          alveo-u50. Defaults to None.
docstr_tok: ["Buffer","allocation","in","the","accelerator","'s","memory",".","Args",":","X_shape","(","list",")",":","Input","buffer","shape",".","y_shape","(","list",")",":","Output","buffer","shape",".","dtype","(","dtype",",","optional",")",":","The","data","type","of","the","elements","of","the","input\/output","tensors",".","Must","be","an","instance","of","numpy","dtype",".","Defaults","to","np.float32",".","It","should","be","set","depending","on","the","interface","of","the","accelerator",";","if","it","uses","'float'","data","type","for","the","'data","'","AXI-Stream","field",",","'np.float32","'","dtype","must","be","used",".","Instead","if","it","uses","'ap_fixed","<","A",",","B",">","'",",","'np.intA","'","is","the","correct","dtype","to","use",".","Note","that","A","can","not","any","integer","value",",","but","it","can","assume","power","of","2","values",",","i.e.",",","{","...",",","8",",","16",",","32",",","...","}",".","Check","`","numpy","`","documentation","for","more","information",".","In","this","case","the","encoding\/decoding","has","to","be","computed","by","the","host","machine",".","For","example","for","'ap_fixed","<","16,6",">","'","type","the","following","2","functions","are","the","correct","one","to","use","for","encode\/decode","'float","'","-",">","'ap_fixed","<","16,6",">","'",":",":","def","encode","(","xi",")",":","return","np.int16","(","round","(","xi","*","2","*","*","10",")",")","#","note","2","*","*","10","=","2","*","*","(","A-B",")","def","decode","(","yi",")",":","return","yi","*","2","*","*","-10","encode_v","=","np.vectorize","(","encode",")","#","to","apply","them","element-wise","decode_v","=","np.vectorize","(","decode",")","trg_in","(","optional",")",":","Input","buffer","target","memory",".","By","default","the","v++","command","set","it","to","HBM","[","0","]","for","alveo-u50",".","Defaults","to","None",".","trg_out","(","optional",")",":","Output","buffer","target","memory",".","By","default","the","v++","command","set","it","to","HBM","[","0","]","for","alveo-u50",".","Defaults","to","None","."]
code: def allocate_mem(
      self,
      X_shape,
      y_shape,
      dtype=np.float32,
      trg_in=None,
      trg_out=None,
  ):
      """Buffer allocation in the accelerator's memory.
  
      Args:
          X_shape (list): Input buffer shape.
          y_shape (list): Output buffer shape.
          dtype (dtype, optional): The data type of the elements of the input/output tensors. Must be an instance of
              numpy dtype. Defaults to np.float32.
  
              It should be set depending on the interface of the accelerator; if it uses 'float'
              data type for the 'data' AXI-Stream field, 'np.float32' dtype must be used. Instead if it uses
              'ap_fixed<A,B>', 'np.intA' is the correct dtype to use. Note that A cannot any integer value, but it can
              assume power of 2 values, i.e., {..., 8, 16, 32, ...}. Check `numpy` documentation for more information.
              In this case the encoding/decoding has to be computed by the host machine. For example for
              'ap_fixed<16,6>' type the following 2 functions are the correct one to use for encode/decode
              'float' -> 'ap_fixed<16,6>'::
  
                  def encode(xi):
                      return np.int16(round(xi * 2**10)) # note 2**10 = 2**(A-B)
                  def decode(yi):
                      return yi * 2**-10
                  encode_v = np.vectorize(encode) # to apply them element-wise
                  decode_v = np.vectorize(decode)
  
          trg_in (optional): Input buffer target memory. By default the v++ command set it to HBM[0] for
              alveo-u50. Defaults to None.
          trg_out (optional): Output buffer target memory. By default the v++ command set it to HBM[0] for
              alveo-u50. Defaults to None.
      """
      self.input_buffer = allocate(
          shape=X_shape, dtype=dtype, target=trg_in
      )
      self.output_buffer = allocate(
          shape=y_shape, dtype=dtype, target=trg_out
      )
  
file_path: hls4ml/hls4ml/templates/vivado_accelerator/alveo/python_drivers/axi_stream_driver.py
imports: from datetime import datetime
  import numpy
  from pynq import Overlay, allocate
label_desc: Use image node_id 2 for calling the NeuralNetworkOverlay obj's underlying member method code with example usage: obj.allocate_mem(X_shape, y_shape, dtype, trg_in, trg_out) without return types