Beispiel #1
0
def test_get_and_set_layout():
    shape = [2, 2]
    parameter_a = ops.parameter(shape, dtype=np.float32, name="A")
    parameter_b = ops.parameter(shape, dtype=np.float32, name="B")

    model = Model(parameter_a + parameter_b, [parameter_a, parameter_b])

    assert layout_helpers.get_layout(model.input(0)) == ov.Layout()
    assert layout_helpers.get_layout(model.input(1)) == ov.Layout()

    layout_helpers.set_layout(model.input(0), ov.Layout("CH"))
    layout_helpers.set_layout(model.input(1), ov.Layout("HW"))

    assert layout_helpers.get_layout(model.input(0)) == ov.Layout("CH")
    assert layout_helpers.get_layout(model.input(1)) == ov.Layout("HW")
Beispiel #2
0
 def get_layout_for_input(self, input, shape=None) -> str:
     input_layout = ''
     if self.model_parameters['input_layouts']:
         input_layout = Layout.from_user_layouts(input.get_names(), self.model_parameters['input_layouts'])
     if not input_layout:
         if not layout_helpers.get_layout(input).empty:
             input_layout = Layout.from_openvino(input)
         else:
             input_layout = Layout.from_shape(shape if shape is not None else input.shape)
     return input_layout
 def from_openvino(input):
     '''
     Create Layout from openvino input
     '''
     return layout_helpers.get_layout(input).to_string().strip('[]').replace(',', '')