Skip to content

reshape output performance improve advice #44

@YeWenxuan64

Description

@YeWenxuan64

you can store the output shape to aviod a function calling

  def __init__(self, 巴拉巴拉什么的):
     self.outputshape_list = self.getOutputShapes()
     self.output_num = len(outputshape_list )

  def Inference(self, input, perf_profile = PerfProfile.DEFAULT, graphIndex = 0):
      output = self.m_context.Inference(input, perf_profile, graphIndex)
      
      for i in range(self.output_num):
          output[i].reshape(outputshape_list[i]) # although it reshapes the outputs but numpy.reshape returns a view

      return output

although it reshapes the outputs but numpy.reshape returns a view, not a C-continuous array, may cause so problem in downstream processing.(但其实大多数处理还是要再reshape一次,所以C不C连续都没什么问题)
so please reshape the outputs in C/C++ level, (pybind is suitable for connecting C/C++ to numpy)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions