code: def unary_elementwise_compute(
      ifm: te.Tensor,
      lut: te.Tensor,
      operator_type: str,
      ifm_scale: float,
      ifm_zero_point: int,
      ofm_scale: float,
      ofm_zero_point: int,
      ofm_channels: int,
      activation: str,
      clip_min: int,
      clip_max: int,
      rounding_mode: str,
      ifm_layout: str,
      ofm_layout: str,
  ) -> te.Tensor:
      """A compute operator representing the capabilities of unary_elementwise for the NPU.
  
      Parameters
      ----------
      ifm : te.Tensor
          The Input Feature Map tensor (IFM).
      lut : te.Tensor
          The look-up table values to use if activation = "LUT".
      operator_type: str
          The type of the unary elementwise operator.
              "ABS"
              "CLZ"
      ifm_scale : float
          The quantization scale for the Input Feature Map tensor.
      ifm_zero_point : int
          The quantization zero point for the Input Feature Map tensor.
      ofm_scale : float
          The quantization scale for the Output Feature Map tensor.
      ofm_zero_point : int
          The quantization zero point for the Output Feature Map tensor.
      ofm_channels : int
          The number of OFM channels.
      activation : str
          The activation function to use.
              "NONE" - no activation function.
              "CLIP" - clip the output between clip_min and clip_max.
              "TANH" - tanh activation function.
              "SIGMOID" - sigmoid activation function.
              "LUT" - use a look-up table to perform the activation function.
      clip_min : int
          The minimum clipping value if activation = "CLIP".
      clip_max : int
          The maximum clipping value if activation = "CLIP".
      rounding_mode : str
          The rounding mode to apply to the Output Feature Map tensor.
              "TFL" - Tensorflow Lite rounding scheme.
              "TRUNCATE" - Truncate towards zero.
              "NATURAL" - Round to nearest value, with x.5 rounded up towards +infinity.
      ifm_layout : str, optional
          The layout of the Input Feature Map tensor. Can be "NHWC" or "NHCWB16".
      ofm_layout : str, optional
          The layout of the Output Feature Map tensor. Can be "NHWC" or "NHCWB16".
  
      Returns
      -------
      te.Tensor
          The OFM tensor.
  
      """
      assert ifm.shape[0] == 1
      assert ifm_layout in {"NHWC", "NHCWB16"}
      assert ofm_layout in {"NHWC", "NHCWB16"}
  
      # Changing the ifm and ofm scale to conform with that expected by Vela API
      if ofm_scale != 0:
          ofm_scale = ifm_scale / ofm_scale
      ifm_scale = 1.0
  
      # Compute operation for the IFM DMA pipeline
      dmaed_ifm = dma_ifm_compute(
          ifm,
          ifm_layout,
          ifm_zero_point,
          ifm_scale,
          ofm_channels,
          (0, 0, 0, 0),
      )
  
      # Unary elementwise compute operation
      ofm_height = dmaed_ifm.shape[1]
      ofm_width = dmaed_ifm.shape[2]
  
      unary_elementwise_attrs = {
          "op": "ethosu_unary_elementwise",
          "operator_type": operator_type,
          "activation": activation,
          "clip_min": clip_min,
          "clip_max": clip_max,
          "rounding_mode": rounding_mode,
      }
  
      def clz_imp(inp):
          # Assuming that it's a 32 bit int
          return 32 - te.log2(inp)
  
      operators = {"ABS": te.abs, "CLZ": clz_imp}
  
      unary_elementwise = te.compute(
          (1, ofm_height, ofm_width, ofm_channels),
          lambda nn, hh, ww, cc: operators[operator_type](
              dmaed_ifm(nn, hh, ww, cc).astype(ifm.dtype)
          ),
          name="ethosu_unary_elementwise",
          attrs=unary_elementwise_attrs,
      )
  
      nhwc_to_nhcwb16, nhcwb16_to_nhwc = get_layout_transform_matrices(
          int(ofm_channels)
      )
  
      ifm_matrix = [
          [1, 0, 0, 0, 0],
          [0, 1, 0, 0, 0],
          [0, 0, 1, 0, 0],
          [0, 0, 0, 1, 0],
          [0, 0, 0, 0, 1],
      ]
      if ofm_layout == "NHCWB16":
          ifm_matrix = np.matmul(ifm_matrix, nhcwb16_to_nhwc).tolist()
      if ifm_layout == "NHCWB16":
          ifm_matrix = np.matmul(nhwc_to_nhcwb16, ifm_matrix).tolist()
  
      ifm_propagator = Propagator(
          ifm_matrix,
          [0, 0, 0, 0] if ifm_layout == "NHWC" else [0, 0, 0, 0, 0],
      )
      propagator_attrs = {"ifm_propagator": ifm_propagator}
  
      # Compute operation for the OFM DMA pipeline
      return dma_ofm_compute(
          unary_elementwise,
          ofm_layout,
          ofm_zero_point,
          ofm_scale,
          ofm_channels,
          attrs=propagator_attrs,
      )
  
imports: import numpy
  from tvm import te
  from tvm.contrib.ethosu.cascader import TESubgraph, EthosuPart, Propagator, register_matcher
  from .dma import dma_ofm_compute, dma_ifm_compute
  from .common import get_layout_transform_matrices
label_desc: Use image node_id 1 for calling a global function with example usage: unary_elementwise_compute(ifm, lut, operator_type, ifm_scale, ifm_zero_point, ofm_scale, ofm_zero_point, ofm_channels, activation, clip_min, clip_max, rounding_mode, ifm_layout, ofm_layout) and returns: dma_ofm_compute, unknown