def common_pool_extender(op: Node): for attr in ['strides', 'pads_begin', 'pads_end', 'kernel', 'dilations']: Extender.attr_to_list(op, attr) op['stride'] = int64_array([1, 1] + op.strides) op['window'] = int64_array([1, 1] + op.kernel) op['kernel_spatial'] = op.kernel op['output_spatial_shape'] = None if op.has_valid('dilations'): op['dilation'] = int64_array([1, 1] + op.dilations) if op.has_valid('index_element_type'): op['index_element_type'] = destination_type_to_np_data_type( op.index_element_type) op['batch_dims'] = int64_array([0]), op['channel_dims'] = int64_array([1]), op['pool_method'] = 'max' if op.type is 'MaxPool' else 'avg' dim = len(op.pads_begin) assert dim in (1, 2, 3), '{}D {} not supported! Node name: {}'.format( dim, op.soft_get('type'), op.soft_get('name', op.id)) pad = [[0, 0], [0, 0]] pad.extend([[op.pads_begin[i], op.pads_end[i]] for i in range(dim)]) op['pad'] = int64_array(pad) op['spatial_dims'] = [i + 2 for i in range(dim)] if op.has_valid('rounding_type') and op.rounding_type == 'ceil': op['pooling_convention'] = 'full'
def extend(op: Node): assert op.has_valid( 'element_type' ), 'Parameter node {} has missed element_type attr!'.format(op.name) op['data_type'] = destination_type_to_np_data_type(op.element_type) if op.shape == '': op.shape = int64_array([]) else: Extender.attr_to_list(op, 'shape') if -1 in op.shape: op.shape = shape_array([ d if d != -1 else dynamic_dimension_value for d in op.shape ])
def extend(op: Node): assert op.has_valid( 'element_type' ), 'Parameter node {} has missed element_type attr!'.format(op.name) op['data_type'] = destination_type_to_np_data_type(op.element_type) if op.shape == '': op.shape = int64_array([]) else: Extender.attr_to_list(op, 'shape') for i, dim in enumerate(op.shape): if dim == -1 or (isinstance(dim, str) and ".." in dim): op.shape[i] = -1 op.shape = shape_array( [d if d != -1 else dynamic_dimension_value for d in op.shape])
def extend(op: Node): assert op.has_valid( 'element_type' ), 'Parameter node {} has missed element_type attr!'.format(op.name) op['data_type'] = destination_type_to_np_data_type(op.element_type) if op.shape == '': op.shape = int64_array([]) else: Extender.attr_to_list(op, 'shape') shape = op.shape.copy() has_shapes_with_boundaries = False for i, dim in enumerate(op.shape): if dim == -1 or (isinstance(dim, str) and ".." in dim): shape[i] = -1 if ".." in dim: has_shapes_with_boundaries = True shape = shape_array([ d if d not in [-1, '?'] else dynamic_dimension_value for d in shape ]) if has_shapes_with_boundaries: shape_list = [] for i, dim in enumerate(op.shape): if not isinstance(dim, str): shape_list.append(dim) else: shape_list.append(parse_dimension(dim)) # This value is used only for serialization of partial shapes with boundaries # for Parameter node. # 'user_shape' is not used in shape inference, as propagation of partial shapes with boundaries # is not implemented in MO. op['user_shape'] = tuple(shape_list) # If 'user_shape' is not set, 'shape' attribute is used for serialization. # 'shape' is also used for shape inference. op.shape = shape
def extend(op: Node): if op.has_valid('output_type'): op['output_type'] = destination_type_to_np_data_type( op.output_type)
def extend(op: Node): op['output_type'] = destination_type_to_np_data_type(op.output_type)
def extend(op: Node): if op.get_opset() != "extension": op['output_type'] = destination_type_to_np_data_type( op.output_type)
def __read_old_api_map_element_type(attr, layer_type): version = int(attr.attrib['version']) element_type = destination_type_to_np_data_type(attr.attrib['value']) old_api_map = OldAPIMapElementType(version=version) old_api_map.set_legacy_type(element_type) return {('old_api_map_element_type', version): old_api_map}
def extend(op: Node): op['dst_type'] = destination_type_to_np_data_type(op.destination_type) # CompressQuantizeWeights generates IR with constant sub-graph, that should not be ConstFolded: # Const(u8) -> Convert(to fp) -> (some eltwise operations) -> FakeQuantize if op.in_node().in_node().soft_get('type') == 'Const': op['stop_value_propagation'] = True
def extend(op: Node): if op.out_port(0).disconnected(): op['remove_values_output'] = True if op.has_valid('index_element_type'): op['index_element_type'] = destination_type_to_np_data_type( op.index_element_type)
def extend(op: Node): if op.has_valid('classes_index_type'): op['classes_index_type'] = destination_type_to_np_data_type(op.classes_index_type) if op.has_valid('sequence_length_type'): op['sequence_length_type'] = destination_type_to_np_data_type(op.sequence_length_type)