From c93c3b75179f59761cee3207b7a65d278603ef7f Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Wed, 23 May 2018 16:41:25 +0530 Subject: [PATCH 01/52] add/fix voc dataset options --- lib/datasets/dataset_catalog.py | 8 ++++++++ tools/test_net.py | 3 +++ tools/train_net.py | 3 +++ tools/train_net_step.py | 3 +++ 4 files changed, 17 insertions(+) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index 18cef3ec..c3eb55eb 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -193,6 +193,14 @@ ANN_FN: _DATA_DIR + '/coco/annotations/image_info_test2017.json' }, + 'voc_2007_train': { + IM_DIR: + _DATA_DIR + '/VOC2007/JPEGImages', + ANN_FN: + _DATA_DIR + '/VOC2007/annotations/voc_2007_train.json', + DEVKIT_DIR: + _DATA_DIR + '/VOC2007/VOCdevkit2007' + }, 'voc_2007_trainval': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', diff --git a/tools/test_net.py b/tools/test_net.py index 23ca0fbd..e0f66216 100644 --- a/tools/test_net.py +++ b/tools/test_net.py @@ -93,6 +93,9 @@ def parse_args(): elif args.dataset == "keypoints_coco2017": cfg.TEST.DATASETS = ('keypoints_coco_2017_val',) cfg.MODEL.NUM_CLASSES = 2 + elif args.dataset == "voc2007": + cfg.TEST.DATASETS = ('voc_2007_test',) + cfg.MODEL.NUM_CLASSES = 21 else: # For subprocess call assert cfg.TEST.DATASETS, 'cfg.TEST.DATASETS shouldn\'t be empty' assert_and_infer_cfg() diff --git a/tools/train_net.py b/tools/train_net.py index 499ba39f..106ad7d7 100644 --- a/tools/train_net.py +++ b/tools/train_net.py @@ -157,6 +157,9 @@ def main(): elif args.dataset == "keypoints_coco2017": cfg.TRAIN.DATASETS = ('keypoints_coco_2017_train',) cfg.MODEL.NUM_CLASSES = 2 + elif args.dataset == "voc2007": + cfg.TRAIN.DATASETS = ('voc_2007_train',) + cfg.MODEL.NUM_CLASSES = 21 else: raise ValueError("Unexpected args.dataset: {}".format(args.dataset)) diff --git a/tools/train_net_step.py b/tools/train_net_step.py index 2966b25c..4fc5dd4e 100644 --- a/tools/train_net_step.py +++ b/tools/train_net_step.py @@ -156,6 +156,9 @@ def main(): elif args.dataset == "keypoints_coco2017": cfg.TRAIN.DATASETS = ('keypoints_coco_2017_train',) cfg.MODEL.NUM_CLASSES = 2 + elif args.dataset == "voc2007": + cfg.TRAIN.DATASETS = ('voc_2007_train',) + cfg.MODEL.NUM_CLASSES = 21 else: raise ValueError("Unexpected args.dataset: {}".format(args.dataset)) From b16090fa4e4c4e777bb2ee9ce9451ac0a0f718bf Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 10:10:38 +0530 Subject: [PATCH 02/52] add xml2json converter file --- tools/pascal_voc_xml2json.py | 172 +++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 tools/pascal_voc_xml2json.py diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py new file mode 100644 index 00000000..65137b0b --- /dev/null +++ b/tools/pascal_voc_xml2json.py @@ -0,0 +1,172 @@ +import xml.etree.ElementTree as ET +import os +import json + +coco = dict() +coco['images'] = [] +coco['type'] = 'instances' +coco['annotations'] = [] +coco['categories'] = [] + +category_set = dict() +image_set = set() + +category_item_id = 0 +image_id = 20180000000 +annotation_id = 0 + +def addCatItem(name): + global category_item_id + category_item = dict() + category_item['supercategory'] = 'none' + category_item_id += 1 + category_item['id'] = category_item_id + category_item['name'] = name + coco['categories'].append(category_item) + category_set[name] = category_item_id + return category_item_id + +def addImgItem(file_name, size): + global image_id + if file_name is None: + raise Exception('Could not find filename tag in xml file.') + if size['width'] is None: + raise Exception('Could not find width tag in xml file.') + if size['height'] is None: + raise Exception('Could not find height tag in xml file.') + image_id += 1 + image_item = dict() + image_item['id'] = image_id + image_item['file_name'] = file_name + image_item['width'] = size['width'] + image_item['height'] = size['height'] + coco['images'].append(image_item) + image_set.add(file_name) + return image_id + +def addAnnoItem(object_name, image_id, category_id, bbox): + global annotation_id + annotation_item = dict() + annotation_item['segmentation'] = [] + seg = [] + #bbox[] is x,y,w,h + #left_top + seg.append(bbox[0]) + seg.append(bbox[1]) + #left_bottom + seg.append(bbox[0]) + seg.append(bbox[1] + bbox[3]) + #right_bottom + seg.append(bbox[0] + bbox[2]) + seg.append(bbox[1] + bbox[3]) + #right_top + seg.append(bbox[0] + bbox[2]) + seg.append(bbox[1]) + + annotation_item['segmentation'].append(seg) + + annotation_item['area'] = bbox[2] * bbox[3] + annotation_item['iscrowd'] = 0 + annotation_item['ignore'] = 0 + annotation_item['image_id'] = image_id + annotation_item['bbox'] = bbox + annotation_item['category_id'] = category_id + annotation_id += 1 + annotation_item['id'] = annotation_id + coco['annotations'].append(annotation_item) + +def parseXmlFiles(xml_path): + for f in os.listdir(xml_path): + if not f.endswith('.xml'): + continue + + bndbox = dict() + size = dict() + current_image_id = None + current_category_id = None + file_name = None + size['width'] = None + size['height'] = None + size['depth'] = None + + xml_file = os.path.join(xml_path, f) + print(xml_file) + + tree = ET.parse(xml_file) + root = tree.getroot() + if root.tag != 'annotation': + raise Exception('pascal voc xml root element should be annotation, rather than {}'.format(root.tag)) + + #elem is , , , + for elem in root: + current_parent = elem.tag + current_sub = None + object_name = None + + if elem.tag == 'folder': + continue + + if elem.tag == 'filename': + file_name = elem.text + if file_name in category_set: + raise Exception('file_name duplicated') + + #add img item only after parse tag + elif current_image_id is None and file_name is not None and size['width'] is not None: + if file_name not in image_set: + current_image_id = addImgItem(file_name, size) + print('add image with {} and {}'.format(file_name, size)) + else: + raise Exception('duplicated image: {}'.format(file_name)) + #subelem is , , , , + for subelem in elem: + bndbox ['xmin'] = None + bndbox ['xmax'] = None + bndbox ['ymin'] = None + bndbox ['ymax'] = None + + current_sub = subelem.tag + if current_parent == 'object' and subelem.tag == 'name': + object_name = subelem.text + if object_name not in category_set: + current_category_id = addCatItem(object_name) + else: + current_category_id = category_set[object_name] + + elif current_parent == 'size': + if size[subelem.tag] is not None: + raise Exception('xml structure broken at size tag.') + size[subelem.tag] = int(subelem.text) + + #option is , , , , when subelem is + for option in subelem: + if current_sub == 'bndbox': + if bndbox[option.tag] is not None: + raise Exception('xml structure corrupted at bndbox tag.') + bndbox[option.tag] = int(option.text) + + #only after parse the tag + if bndbox['xmin'] is not None: + if object_name is None: + raise Exception('xml structure broken at bndbox tag') + if current_image_id is None: + raise Exception('xml structure broken at bndbox tag') + if current_category_id is None: + raise Exception('xml structure broken at bndbox tag') + bbox = [] + #x + bbox.append(bndbox['xmin']) + #y + bbox.append(bndbox['ymin']) + #w + bbox.append(bndbox['xmax'] - bndbox['xmin']) + #h + bbox.append(bndbox['ymax'] - bndbox['ymin']) + print('add annotation with {},{},{},{}'.format(object_name, current_image_id, current_category_id, bbox)) + addAnnoItem(object_name, current_image_id, current_category_id, bbox ) + +if __name__ == '__main__': + xml_path = 'Annotations' + json_file = 'instances.json' + parseXmlFiles(xml_path) + json.dump(coco, open(json_file, 'w')) \ No newline at end of file From f366622d2e0fd69dddd1cc9b363d97032d64f68e Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 11:47:07 +0530 Subject: [PATCH 03/52] add voc_xml2json++ file --- tools/pascal_voc_xml2json.py | 121 ++++++++++++++++++++++------------- 1 file changed, 75 insertions(+), 46 deletions(-) diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py index 65137b0b..58008c5c 100644 --- a/tools/pascal_voc_xml2json.py +++ b/tools/pascal_voc_xml2json.py @@ -2,18 +2,6 @@ import os import json -coco = dict() -coco['images'] = [] -coco['type'] = 'instances' -coco['annotations'] = [] -coco['categories'] = [] - -category_set = dict() -image_set = set() - -category_item_id = 0 -image_id = 20180000000 -annotation_id = 0 def addCatItem(name): global category_item_id @@ -26,6 +14,7 @@ def addCatItem(name): category_set[name] = category_item_id return category_item_id + def addImgItem(file_name, size): global image_id if file_name is None: @@ -44,22 +33,23 @@ def addImgItem(file_name, size): image_set.add(file_name) return image_id + def addAnnoItem(object_name, image_id, category_id, bbox): global annotation_id annotation_item = dict() annotation_item['segmentation'] = [] seg = [] - #bbox[] is x,y,w,h - #left_top + # bbox[] is x,y,w,h + # left_top seg.append(bbox[0]) seg.append(bbox[1]) - #left_bottom + # left_bottom seg.append(bbox[0]) seg.append(bbox[1] + bbox[3]) - #right_bottom + # right_bottom seg.append(bbox[0] + bbox[2]) seg.append(bbox[1] + bbox[3]) - #right_top + # right_top seg.append(bbox[0] + bbox[2]) seg.append(bbox[1]) @@ -73,13 +63,14 @@ def addAnnoItem(object_name, image_id, category_id, bbox): annotation_item['category_id'] = category_id annotation_id += 1 annotation_item['id'] = annotation_id - coco['annotations'].append(annotation_item) + return annotation_item + -def parseXmlFiles(xml_path): +def parseXmlFiles(xml_path, file_list): for f in os.listdir(xml_path): - if not f.endswith('.xml'): + if (not f.endswith('.xml')) and (not any(f in fl for fl in file_list)): continue - + bndbox = dict() size = dict() current_image_id = None @@ -95,36 +86,38 @@ def parseXmlFiles(xml_path): tree = ET.parse(xml_file) root = tree.getroot() if root.tag != 'annotation': - raise Exception('pascal voc xml root element should be annotation, rather than {}'.format(root.tag)) + raise Exception( + 'pascal voc xml root element should be annotation, rather than {}'. + format(root.tag)) - #elem is , , , + # elem is , , , for elem in root: current_parent = elem.tag current_sub = None object_name = None - + if elem.tag == 'folder': continue - + if elem.tag == 'filename': file_name = elem.text if file_name in category_set: raise Exception('file_name duplicated') - - #add img item only after parse tag + + # add img item only after parse tag elif current_image_id is None and file_name is not None and size['width'] is not None: if file_name not in image_set: current_image_id = addImgItem(file_name, size) print('add image with {} and {}'.format(file_name, size)) else: - raise Exception('duplicated image: {}'.format(file_name)) - #subelem is , , , , + raise Exception('duplicated image: {}'.format(file_name)) + # subelem is , , , , for subelem in elem: - bndbox ['xmin'] = None - bndbox ['xmax'] = None - bndbox ['ymin'] = None - bndbox ['ymax'] = None - + bndbox['xmin'] = None + bndbox['xmax'] = None + bndbox['ymin'] = None + bndbox['ymax'] = None + current_sub = subelem.tag if current_parent == 'object' and subelem.tag == 'name': object_name = subelem.text @@ -138,14 +131,15 @@ def parseXmlFiles(xml_path): raise Exception('xml structure broken at size tag.') size[subelem.tag] = int(subelem.text) - #option is , , , , when subelem is + # option is , , , , when subelem is for option in subelem: if current_sub == 'bndbox': if bndbox[option.tag] is not None: - raise Exception('xml structure corrupted at bndbox tag.') + raise Exception( + 'xml structure corrupted at bndbox tag.') bndbox[option.tag] = int(option.text) - #only after parse the tag + # only after parse the tag if bndbox['xmin'] is not None: if object_name is None: raise Exception('xml structure broken at bndbox tag') @@ -154,19 +148,54 @@ def parseXmlFiles(xml_path): if current_category_id is None: raise Exception('xml structure broken at bndbox tag') bbox = [] - #x + # x bbox.append(bndbox['xmin']) - #y + # y bbox.append(bndbox['ymin']) - #w + # w bbox.append(bndbox['xmax'] - bndbox['xmin']) - #h + # h bbox.append(bndbox['ymax'] - bndbox['ymin']) - print('add annotation with {},{},{},{}'.format(object_name, current_image_id, current_category_id, bbox)) - addAnnoItem(object_name, current_image_id, current_category_id, bbox ) + print('add annotation with {},{},{},{}'.format( + object_name, current_image_id, current_category_id, + bbox)) + return addAnnoItem(object_name, current_image_id, + current_category_id, bbox) + if __name__ == '__main__': + image_sets_path = 'ImageSets/Main' + anno_path = 'annotations' xml_path = 'Annotations' - json_file = 'instances.json' - parseXmlFiles(xml_path) - json.dump(coco, open(json_file, 'w')) \ No newline at end of file + for f in os.listdir(image_sets_path): + if not f.endswith('.txt'): + continue + + coco = dict() + coco['images'] = [] + coco['type'] = 'instances' + coco['annotations'] = [] + coco['categories'] = [] + + category_set = dict() + image_set = set() + + category_item_id = 0 + image_id = 20180000000 + annotation_id = 0 + + image_set_file = os.path.join(image_sets_path, f) + + file_list = [] + with open(image_set_file, 'r') as isf: + lines = isf.readlines() + for line in lines: + file_list.append(line.strip() + '.xml') + + annotation_item = parseXmlFiles(xml_path, file_list) + coco['annotations'].append(annotation_item) + + json_file = f.split('.')[0] + '.json' + json_file_path = os.path.join(anno_path, json_file) + print('Writing to file {0}'.format(json_file_path)) + json.dump(coco, open(json_file_path, 'w')) From e5cbd7552836c1078290d8402c824f1b6c3dd9c9 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 11:53:01 +0530 Subject: [PATCH 04/52] create directory if doesn't exist --- tools/pascal_voc_xml2json.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py index 58008c5c..74d08bf3 100644 --- a/tools/pascal_voc_xml2json.py +++ b/tools/pascal_voc_xml2json.py @@ -167,6 +167,10 @@ def parseXmlFiles(xml_path, file_list): image_sets_path = 'ImageSets/Main' anno_path = 'annotations' xml_path = 'Annotations' + + if os.path.exists(anno_path): + os.makedirs(anno_path) + for f in os.listdir(image_sets_path): if not f.endswith('.txt'): continue From ef379ec960e5954cae203dcfb135f99a21d9847d Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 12:00:30 +0530 Subject: [PATCH 05/52] bug_fix --- tools/pascal_voc_xml2json.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py index 74d08bf3..1436c5cc 100644 --- a/tools/pascal_voc_xml2json.py +++ b/tools/pascal_voc_xml2json.py @@ -63,7 +63,7 @@ def addAnnoItem(object_name, image_id, category_id, bbox): annotation_item['category_id'] = category_id annotation_id += 1 annotation_item['id'] = annotation_id - return annotation_item + coco['annotations'].append(annotation_item) def parseXmlFiles(xml_path, file_list): @@ -159,7 +159,7 @@ def parseXmlFiles(xml_path, file_list): print('add annotation with {},{},{},{}'.format( object_name, current_image_id, current_category_id, bbox)) - return addAnnoItem(object_name, current_image_id, + addAnnoItem(object_name, current_image_id, current_category_id, bbox) @@ -175,7 +175,7 @@ def parseXmlFiles(xml_path, file_list): if not f.endswith('.txt'): continue - coco = dict() + global coco = dict() coco['images'] = [] coco['type'] = 'instances' coco['annotations'] = [] @@ -196,8 +196,7 @@ def parseXmlFiles(xml_path, file_list): for line in lines: file_list.append(line.strip() + '.xml') - annotation_item = parseXmlFiles(xml_path, file_list) - coco['annotations'].append(annotation_item) + parseXmlFiles(xml_path, file_list) json_file = f.split('.')[0] + '.json' json_file_path = os.path.join(anno_path, json_file) From bc59a6384f98f3896cb8d280c0170d4490d1f614 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 12:17:24 +0530 Subject: [PATCH 06/52] minor fix and tested --- tools/pascal_voc_xml2json.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py index 1436c5cc..60c8cd8f 100644 --- a/tools/pascal_voc_xml2json.py +++ b/tools/pascal_voc_xml2json.py @@ -164,18 +164,22 @@ def parseXmlFiles(xml_path, file_list): if __name__ == '__main__': + """ + Change the image_sets_path, anno_path and xml_path as per your + absolute path for this script to work. + """ + + global coco + image_sets_path = 'ImageSets/Main' anno_path = 'annotations' xml_path = 'Annotations' - if os.path.exists(anno_path): - os.makedirs(anno_path) - for f in os.listdir(image_sets_path): if not f.endswith('.txt'): continue - global coco = dict() + coco = dict() coco['images'] = [] coco['type'] = 'instances' coco['annotations'] = [] From c7e7b4ad8d8a2606e49638d2efd215a2e08f1cb2 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 14:14:35 +0530 Subject: [PATCH 07/52] minor modifications --- lib/datasets/dataset_catalog.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index c3eb55eb..859eb74f 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -197,7 +197,7 @@ IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/voc_2007_train.json', + _DATA_DIR + '/VOC2007/annotations/train.json', DEVKIT_DIR: _DATA_DIR + '/VOC2007/VOCdevkit2007' }, @@ -205,7 +205,7 @@ IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/voc_2007_trainval.json', + _DATA_DIR + '/VOC2007/annotations/trainval.json', DEVKIT_DIR: _DATA_DIR + '/VOC2007/VOCdevkit2007' }, @@ -213,7 +213,7 @@ IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/voc_2007_test.json', + _DATA_DIR + '/VOC2007/annotations/test.json', DEVKIT_DIR: _DATA_DIR + '/VOC2007/VOCdevkit2007' }, From 96411f060cc41708771bb1be7c25d3fcc46f6cb4 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 17:42:11 +0530 Subject: [PATCH 08/52] add documentation --- tools/pascal_voc_xml2json.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py index 60c8cd8f..dda7f4de 100644 --- a/tools/pascal_voc_xml2json.py +++ b/tools/pascal_voc_xml2json.py @@ -1,3 +1,12 @@ +""" +THis code is borrowed from @gemfield, the original code can be found here: +https://github.com/CivilNet/Gemfield/blob/master/src/python/pascal_voc_xml2json/pascal_voc_xml2json.py + +This code converts the XMLs annotations to JSON according to the various +splits defined in the ImageSets/Main directory. You may need to provide +absolute path to the relevant variables in the main function below. +""" + import xml.etree.ElementTree as ET import os import json @@ -87,8 +96,8 @@ def parseXmlFiles(xml_path, file_list): root = tree.getroot() if root.tag != 'annotation': raise Exception( - 'pascal voc xml root element should be annotation, rather than {}'. - format(root.tag)) + 'pascal voc xml root element should be annotation,\ + rather than {}'.format(root.tag)) # elem is , , , for elem in root: @@ -131,7 +140,8 @@ def parseXmlFiles(xml_path, file_list): raise Exception('xml structure broken at size tag.') size[subelem.tag] = int(subelem.text) - # option is , , , , when subelem is + # option is , , , , + # when subelem is for option in subelem: if current_sub == 'bndbox': if bndbox[option.tag] is not None: @@ -160,7 +170,7 @@ def parseXmlFiles(xml_path, file_list): object_name, current_image_id, current_category_id, bbox)) addAnnoItem(object_name, current_image_id, - current_category_id, bbox) + current_category_id, bbox) if __name__ == '__main__': From 9c9a510c047a80984331dc6d2a80f924cbbb63fa Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 18:41:32 +0530 Subject: [PATCH 09/52] add support for voc12 and custom dataset --- lib/datasets/dataset_catalog.py | 32 +++++++++++++++----------------- tools/test_net.py | 10 ++++++++++ tools/train_net.py | 13 +++++++++++++ tools/train_net_step.py | 13 +++++++++++++ 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index 859eb74f..322b7b61 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -193,36 +193,34 @@ ANN_FN: _DATA_DIR + '/coco/annotations/image_info_test2017.json' }, - 'voc_2007_train': { - IM_DIR: - _DATA_DIR + '/VOC2007/JPEGImages', - ANN_FN: - _DATA_DIR + '/VOC2007/annotations/train.json', - DEVKIT_DIR: - _DATA_DIR + '/VOC2007/VOCdevkit2007' - }, 'voc_2007_trainval': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/trainval.json', - DEVKIT_DIR: - _DATA_DIR + '/VOC2007/VOCdevkit2007' + _DATA_DIR + '/VOC2007/annotations/trainval.json' }, 'voc_2007_test': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/test.json', - DEVKIT_DIR: - _DATA_DIR + '/VOC2007/VOCdevkit2007' + _DATA_DIR + '/VOC2007/annotations/test.json' }, 'voc_2012_trainval': { IM_DIR: _DATA_DIR + '/VOC2012/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2012/annotations/voc_2012_trainval.json', - DEVKIT_DIR: - _DATA_DIR + '/VOC2012/VOCdevkit2012' + _DATA_DIR + '/VOC2012/annotations/trainval.json' + }, + 'custom_data_train': { + IM_DIR: + _DATA_DIR + '/CustomData/JPEGImages', + ANN_FN: + _DATA_DIR + '/CustomData/annotations/trainval.json' + }, + 'custom_data_test': { + IM_DIR: + _DATA_DIR + '/CustomData/JPEGImages', + ANN_FN: + _DATA_DIR + '/CustomData/annotations/test.json' } } diff --git a/tools/test_net.py b/tools/test_net.py index e0f66216..295cfe4d 100644 --- a/tools/test_net.py +++ b/tools/test_net.py @@ -25,6 +25,10 @@ def parse_args(): parser.add_argument( '--dataset', help='training dataset') + parser.add_argument( + '--num_classes', dest='num_classes', + help='Number of classes in your custom dataset', + default=None, type=int) parser.add_argument( '--cfg', dest='cfg_file', required=True, help='optional config file') @@ -82,6 +86,9 @@ def parse_args(): cfg.VIS = args.vis + if args.dataset == "custom_dataset" and args.num_classes is None: + raise ValueError("Need number of classes in your custom dataset to run!") + if args.cfg_file is not None: merge_cfg_from_file(args.cfg_file) if args.set_cfgs is not None: @@ -96,6 +103,9 @@ def parse_args(): elif args.dataset == "voc2007": cfg.TEST.DATASETS = ('voc_2007_test',) cfg.MODEL.NUM_CLASSES = 21 + elif args.dataset == "custom_dataset": + cfg.TEST.DATASETS = ('custom_data_test',) + cfg.MODEL.NUM_CLASSES = args.num_classes else: # For subprocess call assert cfg.TEST.DATASETS, 'cfg.TEST.DATASETS shouldn\'t be empty' assert_and_infer_cfg() diff --git a/tools/train_net.py b/tools/train_net.py index 106ad7d7..22073759 100644 --- a/tools/train_net.py +++ b/tools/train_net.py @@ -50,6 +50,10 @@ def parse_args(): parser.add_argument( '--dataset', dest='dataset', required=True, help='Dataset to use') + parser.add_argument( + '--num_classes', dest='num_classes', + help='Number of classes in your custom dataset', + default=None, type=int) parser.add_argument( '--cfg', dest='cfg_file', required=True, help='Config file for training (and optionally testing)') @@ -151,6 +155,9 @@ def main(): else: raise ValueError("Need Cuda device to run !") + if args.dataset == "custom_dataset" and args.num_classes is None: + raise ValueError("Need number of classes in your custom dataset to run!") + if args.dataset == "coco2017": cfg.TRAIN.DATASETS = ('coco_2017_train',) cfg.MODEL.NUM_CLASSES = 81 @@ -160,6 +167,12 @@ def main(): elif args.dataset == "voc2007": cfg.TRAIN.DATASETS = ('voc_2007_train',) cfg.MODEL.NUM_CLASSES = 21 + elif args.dataset == "voc2012": + cfg.TRAIN.DATASETS = ('voc_2012_train',) + cfg.MODEL.NUM_CLASSES = 21 + elif args.dataset == "custom_dataset": + cfg.TRAIN.DATASETS = ('custom_data_train',) + cfg.MODEL.NUM_CLASSES = args.num_classes else: raise ValueError("Unexpected args.dataset: {}".format(args.dataset)) diff --git a/tools/train_net_step.py b/tools/train_net_step.py index 4fc5dd4e..03e3cdae 100644 --- a/tools/train_net_step.py +++ b/tools/train_net_step.py @@ -45,6 +45,10 @@ def parse_args(): parser.add_argument( '--dataset', dest='dataset', required=True, help='Dataset to use') + parser.add_argument( + '--num_classes', dest='num_classes', + help='Number of classes in your custom dataset', + default=None, type=int) parser.add_argument( '--cfg', dest='cfg_file', required=True, help='Config file for training (and optionally testing)') @@ -150,6 +154,9 @@ def main(): else: raise ValueError("Need Cuda device to run !") + if args.dataset == "custom_dataset" and args.num_classes is None: + raise ValueError("Need number of classes in your custom dataset to run!") + if args.dataset == "coco2017": cfg.TRAIN.DATASETS = ('coco_2017_train',) cfg.MODEL.NUM_CLASSES = 81 @@ -159,6 +166,12 @@ def main(): elif args.dataset == "voc2007": cfg.TRAIN.DATASETS = ('voc_2007_train',) cfg.MODEL.NUM_CLASSES = 21 + elif args.dataset == "voc2012": + cfg.TRAIN.DATASETS = ('voc_2012_train',) + cfg.MODEL.NUM_CLASSES = 21 + elif args.dataset == "custom_dataset": + cfg.TRAIN.DATASETS = ('custom_data_train',) + cfg.MODEL.NUM_CLASSES = args.num_classes else: raise ValueError("Unexpected args.dataset: {}".format(args.dataset)) From f0be15f06ad1403471f8e271e01e4066eacf5421 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Thu, 24 May 2018 19:08:51 +0530 Subject: [PATCH 10/52] update README.md --- README.md | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9791e5e6..9348dff5 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ mkdir data ├── train2014 ├── train2017 ├── val2014 - ├──val2017 + ├── val2017 ├── ... ``` Download coco mini annotations from [here](https://s3-us-west-2.amazonaws.com/detectron/coco/coco_annotations_minival.tgz). @@ -126,8 +126,35 @@ mkdir data ``` ln -s path/to/coco data/coco ``` + +- **PASCAL VOC 2007 + 12** + Please follow the instructions in [py-faster-rcnn](https://github.com/rbgirshick/py-faster-rcnn#beyond-the-demo-installation-for-training-and-testing-models) to prepare VOC datasets. Actually, you can refer to any others. After downloading the data, creat softlinks in the `data/VOC` folder as folows, + ``` + mkdir -p $DETECTRON/detectron/datasets/data/VOC + ln -s /path/to/VOC/JPEGImages $DETECTRON.PYTORCH/data/VOC/JPEGImages + ln -s /path/to/VOC/json/annotations $DETECTRON.PYTORCH/data/VOC/annotations + ``` + The directory structure of `JPEGImages` and `annotations` should be as follows, + ``` + VOC + ├── annotations + | ├── train.json + │   ├── trainval.json + │   ├── test.json + │   ├── ... + | + └── JPEGImages + ├── .jpg + ├── ... + ├── .jpg + ``` + **NOTE:** The `annotations` folder requires you to have PASCAL VOC annotations in COCO json format, which is available for download [here](https://storage.googleapis.com/coco-dataset/external/PASCAL_VOC.zip). You can also convert the XML annotatinos files to JSON by running the following script, + ``` + python tools/pascal_voc_xml2json.py + ``` + (In order to succesfully run the script above, you need to update the full path to the respective folders in the script). - Recommend to put the images on a SSD for possible better training performance +Recommend to put the images on a SSD for possible better training performance ### Pretrained Model @@ -193,7 +220,11 @@ Use `--bs` to overwrite the default batch size to a proper value that fits into Specify `—-use_tfboard` to log the losses on Tensorboard. -**NOTE**: use `--dataset keypoints_coco2017` when training for keypoint-rcnn. +**NOTE**: + - use `--dataset keypoints_coco2017` when training for keypoint-rcnn. + - use `--dataset voc2007` when training for PASCAL VOC 2007. + - use `--dataset voc2012` when training for PASCAL VOC 2012. + - use `--dataset custom_dataset --num_classes $NUM_CLASSES` when training for your custom dataset. Here, `$NUM_CLASSES` is the number of object classes + 1 (for background class) present in your custom dataset. ### The use of `--iter_size` As in Caffe, update network once (`optimizer.step()`) every `iter_size` iterations (forward + backward). This way to have a larger effective batch size for training. Notice that, step count is only increased after network update. From a3e190813df47955368509b14d6842562be21fbc Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 20:41:58 +0530 Subject: [PATCH 11/52] minor fix --- lib/datasets/dataset_catalog.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index 322b7b61..1aba825f 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -193,6 +193,12 @@ ANN_FN: _DATA_DIR + '/coco/annotations/image_info_test2017.json' }, + 'voc_2007_train': { + IM_DIR: + _DATA_DIR + '/VOC2007/JPEGImages', + ANN_FN: + _DATA_DIR + '/VOC2007/annotations/train.json' + }, 'voc_2007_trainval': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', @@ -205,6 +211,12 @@ ANN_FN: _DATA_DIR + '/VOC2007/annotations/test.json' }, + 'voc_2012_train': { + IM_DIR: + _DATA_DIR + '/VOC2012/JPEGImages', + ANN_FN: + _DATA_DIR + '/VOC2012/annotations/train.json' + }, 'voc_2012_trainval': { IM_DIR: _DATA_DIR + '/VOC2012/JPEGImages', @@ -212,6 +224,12 @@ _DATA_DIR + '/VOC2012/annotations/trainval.json' }, 'custom_data_train': { + IM_DIR: + _DATA_DIR + '/CustomData/JPEGImages', + ANN_FN: + _DATA_DIR + '/CustomData/annotations/train.json' + }, + 'custom_data_trainval': { IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: From 35ce2eae418eca1bc1720418059d835f39fdf8da Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Fri, 25 May 2018 00:30:15 +0530 Subject: [PATCH 12/52] fix json conversion file --- tools/pascal_voc_xml2coco_json.py | 154 +++++++++++++++++++++ tools/pascal_voc_xml2json.py | 218 ------------------------------ 2 files changed, 154 insertions(+), 218 deletions(-) create mode 100644 tools/pascal_voc_xml2coco_json.py delete mode 100644 tools/pascal_voc_xml2json.py diff --git a/tools/pascal_voc_xml2coco_json.py b/tools/pascal_voc_xml2coco_json.py new file mode 100644 index 00000000..a0814a1c --- /dev/null +++ b/tools/pascal_voc_xml2coco_json.py @@ -0,0 +1,154 @@ +#!/usr/bin/python + +# pip install lxml + +import sys +import os +import shutil +import json +import xml.etree.ElementTree as ET + +START_BOUNDING_BOX_ID = 1 +PRE_DEFINE_CATEGORIES = {} + +# If necessary, pre-define category and its id +# PRE_DEFINE_CATEGORIES = {"aeroplane": 1, "bicycle": 2, "bird": 3, "boat": 4, +# "bottle":5, "bus": 6, "car": 7, "cat": 8, "chair": 9, +# "cow": 10, "diningtable": 11, "dog": 12, "horse": 13, +# "motorbike": 14, "person": 15, "pottedplant": 16, +# "sheep": 17, "sofa": 18, "train": 19, "tvmonitor": 20} + + +def get(root, name): + vars = root.findall(name) + return vars + + +def get_and_check(root, name, length): + vars = root.findall(name) + if len(vars) == 0: + raise NotImplementedError('Can not find %s in %s.' % (name, root.tag)) + if length > 0 and len(vars) != length: + raise NotImplementedError( + 'The size of %s is supposed to be %d, but is %d.' % (name, length, + len(vars))) + if length == 1: + vars = vars[0] + return vars + + +def get_filename_as_int(filename): + try: + filename = os.path.splitext(filename)[0] + return int(filename) + except: + raise NotImplementedError('Filename %s is supposed to be an integer.' % + (filename)) + + +def convert(xml_list, xml_dir, json_file): + list_fp = open(xml_list, 'r') + json_dict = { + "images": [], + "type": "instances", + "annotations": [], + "categories": [] + } + categories = PRE_DEFINE_CATEGORIES + bnd_id = START_BOUNDING_BOX_ID + for line in list_fp: + line = line.strip().split(' ')[0].strip() + '.xml' + print("Processing {0}" .format(line), end='\r') + xml_f = os.path.join(xml_dir, line) + tree = ET.parse(xml_f) + root = tree.getroot() + path = get(root, 'path') + if len(path) == 1: + filename = os.path.basename(path[0].text) + elif len(path) == 0: + filename = get_and_check(root, 'filename', 1).text + else: + raise NotImplementedError('%d paths found in %s' % (len(path), + line)) + ## The filename must be a number + image_id = get_filename_as_int(filename) + size = get_and_check(root, 'size', 1) + width = int(get_and_check(size, 'width', 1).text) + height = int(get_and_check(size, 'height', 1).text) + image = { + 'file_name': filename, + 'height': height, + 'width': width, + 'id': image_id + } + json_dict['images'].append(image) + ## Cruuently we do not support segmentation + # segmented = get_and_check(root, 'segmented', 1).text + # assert segmented == '0' + for obj in get(root, 'object'): + category = get_and_check(obj, 'name', 1).text + if category not in categories: + new_id = len(categories) + categories[category] = new_id + category_id = categories[category] + bndbox = get_and_check(obj, 'bndbox', 1) + xmin = int(get_and_check(bndbox, 'xmin', 1).text) - 1 + ymin = int(get_and_check(bndbox, 'ymin', 1).text) - 1 + xmax = int(get_and_check(bndbox, 'xmax', 1).text) + ymax = int(get_and_check(bndbox, 'ymax', 1).text) + assert (xmax > xmin) + assert (ymax > ymin) + o_width = abs(xmax - xmin) + o_height = abs(ymax - ymin) + ann = { + 'area': o_width * o_height, + 'iscrowd': 0, + 'image_id': image_id, + 'bbox': [xmin, ymin, o_width, o_height], + 'category_id': category_id, + 'id': bnd_id, + 'ignore': 0, + 'segmentation': [] + } + json_dict['annotations'].append(ann) + bnd_id = bnd_id + 1 + + for cate, cid in categories.items(): + cat = {'supercategory': 'none', 'id': cid, 'name': cate} + json_dict['categories'].append(cat) + json_fp = open(json_file, 'w') + json_str = json.dumps(json_dict) + json_fp.write(json_str) + json_fp.close() + list_fp.close() + + +if __name__ == '__main__': + if len(sys.argv) <= 1: + print('3 auguments are need.') + print('Usage: python {0} ImageSets_DIR XML_DIR OUTPUT_DIR'.format( + sys.argv[0])) + exit(1) + + imagesets_dir = sys.argv[1] + xml_dir = sys.argv[2] + output_dir = sys.argv[3] + + if not os.path.exists(imagesets_dir) and not os.path.exists(xml_dir): + print('PATH not correct, please enter correct path: {0}, {1}'.format( + imagesets_dir, xml_dir)) + raise ValueError('Incorrect PATH provided') + + if os.path.exists(output_dir): + shutil.rmtree(output_dir) + os.makedirs(output_dir) + + for f in os.listdir(imagesets_dir): + if not f.endswith('.txt'): + continue + + print('==> Processing file {0}'.format(f)) + imagesets_file = os.path.join(imagesets_dir, f) + json_file = f.split('.')[0] + '.json' + output_file = os.path.join(output_dir, json_file) + convert(imagesets_file, xml_dir, output_file) diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py deleted file mode 100644 index dda7f4de..00000000 --- a/tools/pascal_voc_xml2json.py +++ /dev/null @@ -1,218 +0,0 @@ -""" -THis code is borrowed from @gemfield, the original code can be found here: -https://github.com/CivilNet/Gemfield/blob/master/src/python/pascal_voc_xml2json/pascal_voc_xml2json.py - -This code converts the XMLs annotations to JSON according to the various -splits defined in the ImageSets/Main directory. You may need to provide -absolute path to the relevant variables in the main function below. -""" - -import xml.etree.ElementTree as ET -import os -import json - - -def addCatItem(name): - global category_item_id - category_item = dict() - category_item['supercategory'] = 'none' - category_item_id += 1 - category_item['id'] = category_item_id - category_item['name'] = name - coco['categories'].append(category_item) - category_set[name] = category_item_id - return category_item_id - - -def addImgItem(file_name, size): - global image_id - if file_name is None: - raise Exception('Could not find filename tag in xml file.') - if size['width'] is None: - raise Exception('Could not find width tag in xml file.') - if size['height'] is None: - raise Exception('Could not find height tag in xml file.') - image_id += 1 - image_item = dict() - image_item['id'] = image_id - image_item['file_name'] = file_name - image_item['width'] = size['width'] - image_item['height'] = size['height'] - coco['images'].append(image_item) - image_set.add(file_name) - return image_id - - -def addAnnoItem(object_name, image_id, category_id, bbox): - global annotation_id - annotation_item = dict() - annotation_item['segmentation'] = [] - seg = [] - # bbox[] is x,y,w,h - # left_top - seg.append(bbox[0]) - seg.append(bbox[1]) - # left_bottom - seg.append(bbox[0]) - seg.append(bbox[1] + bbox[3]) - # right_bottom - seg.append(bbox[0] + bbox[2]) - seg.append(bbox[1] + bbox[3]) - # right_top - seg.append(bbox[0] + bbox[2]) - seg.append(bbox[1]) - - annotation_item['segmentation'].append(seg) - - annotation_item['area'] = bbox[2] * bbox[3] - annotation_item['iscrowd'] = 0 - annotation_item['ignore'] = 0 - annotation_item['image_id'] = image_id - annotation_item['bbox'] = bbox - annotation_item['category_id'] = category_id - annotation_id += 1 - annotation_item['id'] = annotation_id - coco['annotations'].append(annotation_item) - - -def parseXmlFiles(xml_path, file_list): - for f in os.listdir(xml_path): - if (not f.endswith('.xml')) and (not any(f in fl for fl in file_list)): - continue - - bndbox = dict() - size = dict() - current_image_id = None - current_category_id = None - file_name = None - size['width'] = None - size['height'] = None - size['depth'] = None - - xml_file = os.path.join(xml_path, f) - print(xml_file) - - tree = ET.parse(xml_file) - root = tree.getroot() - if root.tag != 'annotation': - raise Exception( - 'pascal voc xml root element should be annotation,\ - rather than {}'.format(root.tag)) - - # elem is , , , - for elem in root: - current_parent = elem.tag - current_sub = None - object_name = None - - if elem.tag == 'folder': - continue - - if elem.tag == 'filename': - file_name = elem.text - if file_name in category_set: - raise Exception('file_name duplicated') - - # add img item only after parse tag - elif current_image_id is None and file_name is not None and size['width'] is not None: - if file_name not in image_set: - current_image_id = addImgItem(file_name, size) - print('add image with {} and {}'.format(file_name, size)) - else: - raise Exception('duplicated image: {}'.format(file_name)) - # subelem is , , , , - for subelem in elem: - bndbox['xmin'] = None - bndbox['xmax'] = None - bndbox['ymin'] = None - bndbox['ymax'] = None - - current_sub = subelem.tag - if current_parent == 'object' and subelem.tag == 'name': - object_name = subelem.text - if object_name not in category_set: - current_category_id = addCatItem(object_name) - else: - current_category_id = category_set[object_name] - - elif current_parent == 'size': - if size[subelem.tag] is not None: - raise Exception('xml structure broken at size tag.') - size[subelem.tag] = int(subelem.text) - - # option is , , , , - # when subelem is - for option in subelem: - if current_sub == 'bndbox': - if bndbox[option.tag] is not None: - raise Exception( - 'xml structure corrupted at bndbox tag.') - bndbox[option.tag] = int(option.text) - - # only after parse the tag - if bndbox['xmin'] is not None: - if object_name is None: - raise Exception('xml structure broken at bndbox tag') - if current_image_id is None: - raise Exception('xml structure broken at bndbox tag') - if current_category_id is None: - raise Exception('xml structure broken at bndbox tag') - bbox = [] - # x - bbox.append(bndbox['xmin']) - # y - bbox.append(bndbox['ymin']) - # w - bbox.append(bndbox['xmax'] - bndbox['xmin']) - # h - bbox.append(bndbox['ymax'] - bndbox['ymin']) - print('add annotation with {},{},{},{}'.format( - object_name, current_image_id, current_category_id, - bbox)) - addAnnoItem(object_name, current_image_id, - current_category_id, bbox) - - -if __name__ == '__main__': - """ - Change the image_sets_path, anno_path and xml_path as per your - absolute path for this script to work. - """ - - global coco - - image_sets_path = 'ImageSets/Main' - anno_path = 'annotations' - xml_path = 'Annotations' - - for f in os.listdir(image_sets_path): - if not f.endswith('.txt'): - continue - - coco = dict() - coco['images'] = [] - coco['type'] = 'instances' - coco['annotations'] = [] - coco['categories'] = [] - - category_set = dict() - image_set = set() - - category_item_id = 0 - image_id = 20180000000 - annotation_id = 0 - - image_set_file = os.path.join(image_sets_path, f) - - file_list = [] - with open(image_set_file, 'r') as isf: - lines = isf.readlines() - for line in lines: - file_list.append(line.strip() + '.xml') - - parseXmlFiles(xml_path, file_list) - - json_file = f.split('.')[0] + '.json' - json_file_path = os.path.join(anno_path, json_file) - print('Writing to file {0}'.format(json_file_path)) - json.dump(coco, open(json_file_path, 'w')) From 06926369b41cefaac7fa86bde69405a560e40a37 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Fri, 25 May 2018 00:33:14 +0530 Subject: [PATCH 13/52] minor fix --- tools/pascal_voc_xml2coco_json.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pascal_voc_xml2coco_json.py b/tools/pascal_voc_xml2coco_json.py index a0814a1c..22044fd8 100644 --- a/tools/pascal_voc_xml2coco_json.py +++ b/tools/pascal_voc_xml2coco_json.py @@ -125,7 +125,7 @@ def convert(xml_list, xml_dir, json_file): if __name__ == '__main__': if len(sys.argv) <= 1: - print('3 auguments are need.') + print('3 auguments are needed.') print('Usage: python {0} ImageSets_DIR XML_DIR OUTPUT_DIR'.format( sys.argv[0])) exit(1) From d792f6243110aec830a500c5e8c9438948317041 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Fri, 25 May 2018 00:58:52 +0530 Subject: [PATCH 14/52] check segmentation converter --- tools/pascal_voc_xml2coco_json_converter.py | 300 ++++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 tools/pascal_voc_xml2coco_json_converter.py diff --git a/tools/pascal_voc_xml2coco_json_converter.py b/tools/pascal_voc_xml2coco_json_converter.py new file mode 100644 index 00000000..51fb0167 --- /dev/null +++ b/tools/pascal_voc_xml2coco_json_converter.py @@ -0,0 +1,300 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Mar 08 16:01:57 2018 + +Convert VOC dataset into COCO dataset + +@author: wkoa +""" +import os +import sys +import json +import xml.etree.ElementTree as ET +import numpy as np +import cv2 + + +def _isArrayLike(obj): + return hasattr(obj, '__iter__') and hasattr(obj, '__len__') + + +class voc2coco: + def __init__(self, devkit_path=None, year=None): + self.classes = ( + '__background__', # always index 0 + 'aeroplane', + 'bicycle', + 'bird', + 'boat', + 'bottle', + 'bus', + 'car', + 'cat', + 'chair', + 'cow', + 'diningtable', + 'dog', + 'horse', + 'motorbike', + 'person', + 'pottedplant', + 'sheep', + 'sofa', + 'train', + 'tvmonitor') + #self.classes = ('__background__', + # 'bottle','box','brush','cabbage','dolphin', + # 'eggplant','hedgehog','lion','polarbear', + # 'squirrel') + + self.num_classes = len(self.classes) + assert 'VOCdevkit' in devkit_path, 'VOCdevkit path does not exist: {}'.format( + devkit_path) + self.data_path = os.path.join(devkit_path, 'VOC' + year) + self.annotaions_path = os.path.join(self.data_path, 'Annotations') + self.image_set_path = os.path.join(self.data_path, 'ImageSets') + self.year = year + self.categories_to_ids_map = self._get_categories_to_ids_map() + self.categories_msg = self._categories_msg_generator() + + def _load_annotation(self, ids=[]): + """ + Load annotations by ids + :param ids (int array) : get amms for idss + :return image_msg + return annotation_msg + """ + ids = ids if _isArrayLike(ids) else [ids] + image_msg = [] + annotation_msg = [] + annotation_id = 1 + for index in ids: + filename = '{:0>6}'.format(index) + json_file = os.path.join(self.data_path, 'Segmentation_json', + filename + '.json') + #Labelme label file .json + if os.path.exists(json_file): + img_file = os.path.join(self.data_path, 'JPEGImages', + filename + '.jpg') + im = cv2.imread(img_file) + width = im.shape[1] + height = im.shape[0] + seg_data = json.load(open(json_file, 'r')) + assert type(seg_data) == type( + dict()), 'annotation file format {} not supported'.format( + type(seg_data)) + for shape in seg_data['shapes']: + seg_msg = [] + for point in shape['points']: + seg_msg += point + one_ann_msg = { + "segmentation": [seg_msg], + "area": self._area_computer(shape['points']), + "iscrowd": 0, + "image_id": int(index), + "bbox": self._points_to_mbr(shape['points']), + "category_id": + self.categories_to_ids_map[shape['label']], + "id": annotation_id, + "ignore": 0 + } + annotation_msg.append(one_ann_msg) + annotation_id += 1 + #LabelImg label file .xml + else: + xml_file = os.path.join(self.annotaions_path, + filename + '.xml') + tree = ET.parse(xml_file) + size = tree.find('size') + objs = tree.findall('object') + width = size.find('width').text + height = size.find('height').text + for obj in objs: + bndbox = obj.find('bndbox') + [xmin, xmax, ymin, ymax] = [ + int(bndbox.find('xmin').text) - 1, + int(bndbox.find('xmax').text), + int(bndbox.find('ymin').text) - 1, + int(bndbox.find('ymax').text) + ] + if xmin < 0: + xmin = 0 + if ymin < 0: + ymin = 0 + bbox = [xmin, xmax, ymin, ymax] + one_ann_msg = { + "segmentation": + self._bbox_to_mask(bbox), + "area": + self._bbox_area_computer(bbox), + "iscrowd": + 0, + "image_id": + int(index), + "bbox": [xmin, ymin, xmax - xmin, ymax - ymin], + "category_id": + self.categories_to_ids_map[obj.find('name').text], + "id": + annotation_id, + "ignore": + 0 + } + annotation_msg.append(one_ann_msg) + annotation_id += 1 + one_image_msg = { + "file_name": filename + ".jpg", + "height": int(height), + "width": int(width), + "id": int(index) + } + image_msg.append(one_image_msg) + return image_msg, annotation_msg + + def _bbox_to_mask(self, bbox): + """" + Generate mask by bbox + :param bbox e.g. [xmin,xmax,ymin,ymax] + :return mask [points] + """ + assert len(bbox) == 4, 'Wrong bndbox!' + mask = [ + bbox[0], bbox[2], bbox[0], bbox[3], bbox[1], bbox[3], bbox[1], + bbox[2] + ] + return [mask] + + def _bbox_area_computer(self, bbox): + """ + Area computer + """ + width = bbox[1] - bbox[0] + height = bbox[3] - bbox[2] + return width * height + + def _save_json_file(self, filename=None, data=None): + """ + Save result in json + :param filename (str) : name of json file + param data : coco format data + :return + """ + json_path = os.path.join(self.data_path, 'cocoformatJson') + assert filename is not None, 'lack filename' + if os.path.exists(json_path) == False: + os.mkdir(json_path) + if not filename.endswith('.json'): + filename += '.json' + assert type(data) == type( + dict()), 'data format {} not supported'.format(type(data)) + with open(os.path.join(json_path, filename), 'w') as f: + f.write(json.dumps(data)) + + def _get_categories_to_ids_map(self): + """ + Generate categories to ids map + """ + return dict(zip(self.classes, xrange(self.num_classes))) + + def _get_all_indexs(self): + """ + Get all images and annotations indexs + :param + :return ids (str array) + """ + ids = [] + for root, dirs, files in os.walk(self.annotaions_path, topdown=False): + for f in files: + if str(f).endswith('.xml'): + id = int(str(f).strip('.xml')) + ids.append(id) + assert ids is not None, 'There is none xml file in {}'.format( + self.annotaions_path) + return ids + + def _get_indexs_by_image_set(self, image_set=None): + """ + Get images and nnotations indexs in image_set + """ + if image_set is None: + return self._get_all_indexs() + else: + image_set_path = os.path.join(self.image_set_path, 'Main', + image_set + '.txt') + assert os.path.exists( + image_set_path), 'Path does not exist: {}'.format( + image_set_path) + with open(image_set_path) as f: + ids = [x.strip() for x in f.readlines()] + return ids + + def _points_to_mbr(self, points): + """ + Transfer points to min bounding rectangle + :param: points (a list of lists) + :return: [x,y,width,height] + """ + assert _isArrayLike(points), 'Points should be array like!' + x = [point[0] for point in points] + y = [point[1] for point in points] + assert len(x) == len(y), 'Wrong point quantity' + xmin, xmax, ymin, ymax = min(x), max(x), min(y), max(y) + height = ymax - ymin + width = xmax - xmin + return [xmin, ymin, width, height] + + def _categories_msg_generator(self): + categories_msg = [] + for category in self.classes: + if category == '__background__': + continue + one_categories_msg = { + "supercategory": "none", + "id": self.categories_to_ids_map[category], + "name": category + } + categories_msg.append(one_categories_msg) + return categories_msg + + def _area_computer(self, points): + """ + :param: one shape's points (int array array) + :return: shape's area + """ + assert _isArrayLike(points), 'Points should be array like!' + tmp_contour = [] + for point in points: + tmp_contour.append([point]) + contour = np.array(tmp_contour, dtype=np.int32) + area = cv2.contourArea(contour) + return area + + def voc_to_coco_converter(self): + """ + Convert voc dataset to coco dataset + """ + img_sets = ['trainval', 'test'] + + for img_set in img_sets: + ids = self._get_indexs_by_image_set(img_set) + img_msg, ann_msg = self._load_annotation(ids) + result_json = { + "images": img_msg, + "type": "instances", + "annotations": ann_msg, + "categories": self.categories_msg + } + self._save_json_file('voc_' + self.year + '_' + img_set, + result_json) + + +if __name__ == "__main__": + if len(sys.argv) <= 1: + print('2 arguments are needed') + print('Usage: python {0} $VOCdevkitPATH $year'.format(sys.argv[0])) + exit(1) + + devkit_path = sys.argv[1] + year = sys.argv[2] + + converter = voc2coco(devkit_path, year) + converter.voc_to_coco_converter() \ No newline at end of file From 6f75f31db6ff54a0d312ae28015d53e6351de3ce Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Fri, 25 May 2018 01:04:23 +0530 Subject: [PATCH 15/52] updated converter file --- tools/pascal_voc_xml2coco_json.py | 154 -------------------- tools/pascal_voc_xml2coco_json_converter.py | 10 +- 2 files changed, 1 insertion(+), 163 deletions(-) delete mode 100644 tools/pascal_voc_xml2coco_json.py diff --git a/tools/pascal_voc_xml2coco_json.py b/tools/pascal_voc_xml2coco_json.py deleted file mode 100644 index 22044fd8..00000000 --- a/tools/pascal_voc_xml2coco_json.py +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/python - -# pip install lxml - -import sys -import os -import shutil -import json -import xml.etree.ElementTree as ET - -START_BOUNDING_BOX_ID = 1 -PRE_DEFINE_CATEGORIES = {} - -# If necessary, pre-define category and its id -# PRE_DEFINE_CATEGORIES = {"aeroplane": 1, "bicycle": 2, "bird": 3, "boat": 4, -# "bottle":5, "bus": 6, "car": 7, "cat": 8, "chair": 9, -# "cow": 10, "diningtable": 11, "dog": 12, "horse": 13, -# "motorbike": 14, "person": 15, "pottedplant": 16, -# "sheep": 17, "sofa": 18, "train": 19, "tvmonitor": 20} - - -def get(root, name): - vars = root.findall(name) - return vars - - -def get_and_check(root, name, length): - vars = root.findall(name) - if len(vars) == 0: - raise NotImplementedError('Can not find %s in %s.' % (name, root.tag)) - if length > 0 and len(vars) != length: - raise NotImplementedError( - 'The size of %s is supposed to be %d, but is %d.' % (name, length, - len(vars))) - if length == 1: - vars = vars[0] - return vars - - -def get_filename_as_int(filename): - try: - filename = os.path.splitext(filename)[0] - return int(filename) - except: - raise NotImplementedError('Filename %s is supposed to be an integer.' % - (filename)) - - -def convert(xml_list, xml_dir, json_file): - list_fp = open(xml_list, 'r') - json_dict = { - "images": [], - "type": "instances", - "annotations": [], - "categories": [] - } - categories = PRE_DEFINE_CATEGORIES - bnd_id = START_BOUNDING_BOX_ID - for line in list_fp: - line = line.strip().split(' ')[0].strip() + '.xml' - print("Processing {0}" .format(line), end='\r') - xml_f = os.path.join(xml_dir, line) - tree = ET.parse(xml_f) - root = tree.getroot() - path = get(root, 'path') - if len(path) == 1: - filename = os.path.basename(path[0].text) - elif len(path) == 0: - filename = get_and_check(root, 'filename', 1).text - else: - raise NotImplementedError('%d paths found in %s' % (len(path), - line)) - ## The filename must be a number - image_id = get_filename_as_int(filename) - size = get_and_check(root, 'size', 1) - width = int(get_and_check(size, 'width', 1).text) - height = int(get_and_check(size, 'height', 1).text) - image = { - 'file_name': filename, - 'height': height, - 'width': width, - 'id': image_id - } - json_dict['images'].append(image) - ## Cruuently we do not support segmentation - # segmented = get_and_check(root, 'segmented', 1).text - # assert segmented == '0' - for obj in get(root, 'object'): - category = get_and_check(obj, 'name', 1).text - if category not in categories: - new_id = len(categories) - categories[category] = new_id - category_id = categories[category] - bndbox = get_and_check(obj, 'bndbox', 1) - xmin = int(get_and_check(bndbox, 'xmin', 1).text) - 1 - ymin = int(get_and_check(bndbox, 'ymin', 1).text) - 1 - xmax = int(get_and_check(bndbox, 'xmax', 1).text) - ymax = int(get_and_check(bndbox, 'ymax', 1).text) - assert (xmax > xmin) - assert (ymax > ymin) - o_width = abs(xmax - xmin) - o_height = abs(ymax - ymin) - ann = { - 'area': o_width * o_height, - 'iscrowd': 0, - 'image_id': image_id, - 'bbox': [xmin, ymin, o_width, o_height], - 'category_id': category_id, - 'id': bnd_id, - 'ignore': 0, - 'segmentation': [] - } - json_dict['annotations'].append(ann) - bnd_id = bnd_id + 1 - - for cate, cid in categories.items(): - cat = {'supercategory': 'none', 'id': cid, 'name': cate} - json_dict['categories'].append(cat) - json_fp = open(json_file, 'w') - json_str = json.dumps(json_dict) - json_fp.write(json_str) - json_fp.close() - list_fp.close() - - -if __name__ == '__main__': - if len(sys.argv) <= 1: - print('3 auguments are needed.') - print('Usage: python {0} ImageSets_DIR XML_DIR OUTPUT_DIR'.format( - sys.argv[0])) - exit(1) - - imagesets_dir = sys.argv[1] - xml_dir = sys.argv[2] - output_dir = sys.argv[3] - - if not os.path.exists(imagesets_dir) and not os.path.exists(xml_dir): - print('PATH not correct, please enter correct path: {0}, {1}'.format( - imagesets_dir, xml_dir)) - raise ValueError('Incorrect PATH provided') - - if os.path.exists(output_dir): - shutil.rmtree(output_dir) - os.makedirs(output_dir) - - for f in os.listdir(imagesets_dir): - if not f.endswith('.txt'): - continue - - print('==> Processing file {0}'.format(f)) - imagesets_file = os.path.join(imagesets_dir, f) - json_file = f.split('.')[0] + '.json' - output_file = os.path.join(output_dir, json_file) - convert(imagesets_file, xml_dir, output_file) diff --git a/tools/pascal_voc_xml2coco_json_converter.py b/tools/pascal_voc_xml2coco_json_converter.py index 51fb0167..5c1c4fe0 100644 --- a/tools/pascal_voc_xml2coco_json_converter.py +++ b/tools/pascal_voc_xml2coco_json_converter.py @@ -1,11 +1,3 @@ -# -*- coding: utf-8 -*- -""" -Created on Thu Mar 08 16:01:57 2018 - -Convert VOC dataset into COCO dataset - -@author: wkoa -""" import os import sys import json @@ -193,7 +185,7 @@ def _get_categories_to_ids_map(self): """ Generate categories to ids map """ - return dict(zip(self.classes, xrange(self.num_classes))) + return dict(zip(self.classes, range(self.num_classes))) def _get_all_indexs(self): """ From c62962f75d075521146ca2670f992fe7be0da4a4 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Fri, 25 May 2018 01:16:51 +0530 Subject: [PATCH 16/52] formatting --- tools/pascal_voc_xml2coco_json_converter.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tools/pascal_voc_xml2coco_json_converter.py b/tools/pascal_voc_xml2coco_json_converter.py index 5c1c4fe0..dbce7e24 100644 --- a/tools/pascal_voc_xml2coco_json_converter.py +++ b/tools/pascal_voc_xml2coco_json_converter.py @@ -115,21 +115,14 @@ def _load_annotation(self, ids=[]): ymin = 0 bbox = [xmin, xmax, ymin, ymax] one_ann_msg = { - "segmentation": - self._bbox_to_mask(bbox), - "area": - self._bbox_area_computer(bbox), - "iscrowd": - 0, - "image_id": - int(index), + "segmentation": self._bbox_to_mask(bbox), + "area": self._bbox_area_computer(bbox), + "iscrowd": 0, + "image_id": int(index), "bbox": [xmin, ymin, xmax - xmin, ymax - ymin], - "category_id": - self.categories_to_ids_map[obj.find('name').text], - "id": - annotation_id, - "ignore": - 0 + "category_id": self.categories_to_ids_map[obj.find('name').text], + "id": annotation_id, + "ignore": 0 } annotation_msg.append(one_ann_msg) annotation_id += 1 From b439268d8a3f393b49b58dea4ed00403ee0aeb08 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Fri, 25 May 2018 01:26:19 +0530 Subject: [PATCH 17/52] Update README.md --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9348dff5..50e9b756 100644 --- a/README.md +++ b/README.md @@ -150,9 +150,12 @@ mkdir data ``` **NOTE:** The `annotations` folder requires you to have PASCAL VOC annotations in COCO json format, which is available for download [here](https://storage.googleapis.com/coco-dataset/external/PASCAL_VOC.zip). You can also convert the XML annotatinos files to JSON by running the following script, ``` - python tools/pascal_voc_xml2json.py + python tools/pascal_voc_xml2coco_json_converter.py $VOCdevkitPATH $year ``` (In order to succesfully run the script above, you need to update the full path to the respective folders in the script). + +- **Custom Dataset** + Similar to above, create a directory named `CustomDataset` in the `data` folder and add symlinks to the `annotations` directory and `JPEGImages` as shown for Pascal Voc dataset. Recommend to put the images on a SSD for possible better training performance @@ -224,7 +227,7 @@ Specify `—-use_tfboard` to log the losses on Tensorboard. - use `--dataset keypoints_coco2017` when training for keypoint-rcnn. - use `--dataset voc2007` when training for PASCAL VOC 2007. - use `--dataset voc2012` when training for PASCAL VOC 2012. - - use `--dataset custom_dataset --num_classes $NUM_CLASSES` when training for your custom dataset. Here, `$NUM_CLASSES` is the number of object classes + 1 (for background class) present in your custom dataset. + - use `--dataset custom_dataset --num_classes $NUM_CLASSES` when training for your custom dataset. Here, `$NUM_CLASSES` is the number of object classes **+ 1** (for background class) present in your custom dataset. ### The use of `--iter_size` As in Caffe, update network once (`optimizer.step()`) every `iter_size` iterations (forward + backward). This way to have a larger effective batch size for training. Notice that, step count is only increased after network update. From 7ece75bcbf7595f6b5c6a59a26ace3b9bfb83a1c Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Sun, 27 May 2018 11:26:14 +0530 Subject: [PATCH 18/52] fix voc testing code --- lib/datasets/dataset_catalog.py | 20 +++++++++++++++++--- lib/datasets/voc_eval.py | 4 ++-- tools/pascal_voc_xml2coco_json_converter.py | 4 ++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index 1aba825f..5ec6749e 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -197,48 +197,62 @@ IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/train.json' + _DATA_DIR + '/VOC2007/annotations/voc_2007_train.json' }, 'voc_2007_trainval': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/trainval.json' + _DATA_DIR + '/VOC2007/annotations/voc_2007_trainval.json' + DEVKIT_DIR: + _DATA_DIR + '/VOC2007' }, 'voc_2007_test': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/test.json' + _DATA_DIR + '/VOC2007/annotations/voc_2007_test.json' + DEVKIT_DIR: + _DATA_DIR + '/VOC2007' }, 'voc_2012_train': { IM_DIR: _DATA_DIR + '/VOC2012/JPEGImages', ANN_FN: _DATA_DIR + '/VOC2012/annotations/train.json' + DEVKIT_DIR: + _DATA_DIR + '/VOC2007' }, 'voc_2012_trainval': { IM_DIR: _DATA_DIR + '/VOC2012/JPEGImages', ANN_FN: _DATA_DIR + '/VOC2012/annotations/trainval.json' + DEVKIT_DIR: + _DATA_DIR + '/VOC2007' }, 'custom_data_train': { IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: _DATA_DIR + '/CustomData/annotations/train.json' + DEVKIT_DIR: + _DATA_DIR + '/CustomData' }, 'custom_data_trainval': { IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: _DATA_DIR + '/CustomData/annotations/trainval.json' + DEVKIT_DIR: + _DATA_DIR + '/CustomData' }, 'custom_data_test': { IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: _DATA_DIR + '/CustomData/annotations/test.json' + DEVKIT_DIR: + _DATA_DIR + "/CustomData' } } diff --git a/lib/datasets/voc_eval.py b/lib/datasets/voc_eval.py index 2b3a8c04..0f775d23 100644 --- a/lib/datasets/voc_eval.py +++ b/lib/datasets/voc_eval.py @@ -136,11 +136,11 @@ def voc_eval(detpath, i + 1, len(imagenames))) # save logger.info('Saving cached annotations to {:s}'.format(cachefile)) - with open(cachefile, 'w') as f: + with open(cachefile, 'wb') as f: cPickle.dump(recs, f) else: # load - with open(cachefile, 'r') as f: + with open(cachefile, 'rb') as f: recs = cPickle.load(f) # extract gt objects for this class diff --git a/tools/pascal_voc_xml2coco_json_converter.py b/tools/pascal_voc_xml2coco_json_converter.py index dbce7e24..2e59a1cb 100644 --- a/tools/pascal_voc_xml2coco_json_converter.py +++ b/tools/pascal_voc_xml2coco_json_converter.py @@ -257,7 +257,7 @@ def voc_to_coco_converter(self): """ Convert voc dataset to coco dataset """ - img_sets = ['trainval', 'test'] + img_sets = ['train', 'val', 'trainval', 'test'] for img_set in img_sets: ids = self._get_indexs_by_image_set(img_set) @@ -282,4 +282,4 @@ def voc_to_coco_converter(self): year = sys.argv[2] converter = voc2coco(devkit_path, year) - converter.voc_to_coco_converter() \ No newline at end of file + converter.voc_to_coco_converter() From ab76a7de52a995222bb0d6cf71cb6710f82d7152 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Sun, 27 May 2018 11:31:10 +0530 Subject: [PATCH 19/52] minor fix --- lib/datasets/dataset_catalog.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index 5ec6749e..d0f426bc 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -197,13 +197,15 @@ IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/voc_2007_train.json' + _DATA_DIR + '/VOC2007/annotations/voc_2007_train.json', + DEVKIT_DIR: + _DATA_DIR + '/VOC2007' }, 'voc_2007_trainval': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/voc_2007_trainval.json' + _DATA_DIR + '/VOC2007/annotations/voc_2007_trainval.json', DEVKIT_DIR: _DATA_DIR + '/VOC2007' }, @@ -211,7 +213,7 @@ IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/voc_2007_test.json' + _DATA_DIR + '/VOC2007/annotations/voc_2007_test.json', DEVKIT_DIR: _DATA_DIR + '/VOC2007' }, @@ -219,23 +221,23 @@ IM_DIR: _DATA_DIR + '/VOC2012/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2012/annotations/train.json' + _DATA_DIR + '/VOC2012/annotations/train.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2007' + _DATA_DIR + '/VOC2012' }, 'voc_2012_trainval': { IM_DIR: _DATA_DIR + '/VOC2012/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2012/annotations/trainval.json' + _DATA_DIR + '/VOC2012/annotations/trainval.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2007' + _DATA_DIR + '/VOC2012' }, 'custom_data_train': { IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: - _DATA_DIR + '/CustomData/annotations/train.json' + _DATA_DIR + '/CustomData/annotations/train.json', DEVKIT_DIR: _DATA_DIR + '/CustomData' }, @@ -243,7 +245,7 @@ IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: - _DATA_DIR + '/CustomData/annotations/trainval.json' + _DATA_DIR + '/CustomData/annotations/trainval.json', DEVKIT_DIR: _DATA_DIR + '/CustomData' }, @@ -251,8 +253,8 @@ IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: - _DATA_DIR + '/CustomData/annotations/test.json' + _DATA_DIR + '/CustomData/annotations/test.json', DEVKIT_DIR: - _DATA_DIR + "/CustomData' + _DATA_DIR + '/CustomData' } } From 58e0f1889b581e3fb21afd5404c3a48efcb3f6ab Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Sun, 27 May 2018 11:59:48 +0530 Subject: [PATCH 20/52] minor fix --- lib/datasets/dataset_catalog.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index d0f426bc..0a3986e2 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -199,7 +199,7 @@ ANN_FN: _DATA_DIR + '/VOC2007/annotations/voc_2007_train.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2007' + _DATA_DIR + '/VOC2007/VOCdevkit2007' }, 'voc_2007_trainval': { IM_DIR: @@ -207,7 +207,7 @@ ANN_FN: _DATA_DIR + '/VOC2007/annotations/voc_2007_trainval.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2007' + _DATA_DIR + '/VOC2007/VOCdevkit2007' }, 'voc_2007_test': { IM_DIR: @@ -215,7 +215,7 @@ ANN_FN: _DATA_DIR + '/VOC2007/annotations/voc_2007_test.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2007' + _DATA_DIR + '/VOC2007/VOCdevkit2007' }, 'voc_2012_train': { IM_DIR: @@ -223,7 +223,7 @@ ANN_FN: _DATA_DIR + '/VOC2012/annotations/train.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2012' + _DATA_DIR + '/VOC2012/VOCdevkit2012' }, 'voc_2012_trainval': { IM_DIR: @@ -231,7 +231,7 @@ ANN_FN: _DATA_DIR + '/VOC2012/annotations/trainval.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2012' + _DATA_DIR + '/VOC2012/VOCdevkit2012' }, 'custom_data_train': { IM_DIR: @@ -239,7 +239,7 @@ ANN_FN: _DATA_DIR + '/CustomData/annotations/train.json', DEVKIT_DIR: - _DATA_DIR + '/CustomData' + _DATA_DIR + '/CustomData/CustomDataDevkit' }, 'custom_data_trainval': { IM_DIR: @@ -247,7 +247,7 @@ ANN_FN: _DATA_DIR + '/CustomData/annotations/trainval.json', DEVKIT_DIR: - _DATA_DIR + '/CustomData' + _DATA_DIR + '/CustomData/CustomDataDevkit' }, 'custom_data_test': { IM_DIR: @@ -255,6 +255,6 @@ ANN_FN: _DATA_DIR + '/CustomData/annotations/test.json', DEVKIT_DIR: - _DATA_DIR + '/CustomData' + _DATA_DIR + '/CustomData/CustomDataDevkit' } } From 01af0af87e594679ab069692d6b1874bf91375c6 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Sun, 27 May 2018 12:17:09 +0530 Subject: [PATCH 21/52] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 50e9b756..bb1d21ef 100644 --- a/README.md +++ b/README.md @@ -130,9 +130,11 @@ mkdir data - **PASCAL VOC 2007 + 12** Please follow the instructions in [py-faster-rcnn](https://github.com/rbgirshick/py-faster-rcnn#beyond-the-demo-installation-for-training-and-testing-models) to prepare VOC datasets. Actually, you can refer to any others. After downloading the data, creat softlinks in the `data/VOC` folder as folows, ``` + VOCdevkitPATH=/path/to/voc_devkit mkdir -p $DETECTRON/detectron/datasets/data/VOC - ln -s /path/to/VOC/JPEGImages $DETECTRON.PYTORCH/data/VOC/JPEGImages - ln -s /path/to/VOC/json/annotations $DETECTRON.PYTORCH/data/VOC/annotations + ln -s /${VOCdevkitPATH}/VOC/JPEGImages $DETECTRON.PYTORCH/data/VOC/JPEGImages + ln -s /${VOCdevkitPATH}/VOC/json_annotations $DETECTRON.PYTORCH/data/VOC/annotations + ln -s /${VOCdevkitPATH} $DETECTRON.PYTORCH/data/VOC/VOCdevkit ``` The directory structure of `JPEGImages` and `annotations` should be as follows, ``` @@ -155,7 +157,7 @@ mkdir data (In order to succesfully run the script above, you need to update the full path to the respective folders in the script). - **Custom Dataset** - Similar to above, create a directory named `CustomDataset` in the `data` folder and add symlinks to the `annotations` directory and `JPEGImages` as shown for Pascal Voc dataset. + Similar to above, create a directory named `CustomDataset` in the `data` folder and add symlinks to the `annotations` directory and `JPEGImages` as shown for Pascal Voc dataset. You also need to link the custom dataset devkit to `CustomDataDevkit`. Recommend to put the images on a SSD for possible better training performance From 4f74541a7831b11f73dc498d27501f6965ddbfd3 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Wed, 23 May 2018 16:41:25 +0530 Subject: [PATCH 22/52] add/fix voc dataset options --- lib/datasets/dataset_catalog.py | 8 ++++++++ tools/test_net.py | 3 +++ tools/train_net.py | 3 +++ tools/train_net_step.py | 3 +++ 4 files changed, 17 insertions(+) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index 18cef3ec..c3eb55eb 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -193,6 +193,14 @@ ANN_FN: _DATA_DIR + '/coco/annotations/image_info_test2017.json' }, + 'voc_2007_train': { + IM_DIR: + _DATA_DIR + '/VOC2007/JPEGImages', + ANN_FN: + _DATA_DIR + '/VOC2007/annotations/voc_2007_train.json', + DEVKIT_DIR: + _DATA_DIR + '/VOC2007/VOCdevkit2007' + }, 'voc_2007_trainval': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', diff --git a/tools/test_net.py b/tools/test_net.py index 23ca0fbd..e0f66216 100644 --- a/tools/test_net.py +++ b/tools/test_net.py @@ -93,6 +93,9 @@ def parse_args(): elif args.dataset == "keypoints_coco2017": cfg.TEST.DATASETS = ('keypoints_coco_2017_val',) cfg.MODEL.NUM_CLASSES = 2 + elif args.dataset == "voc2007": + cfg.TEST.DATASETS = ('voc_2007_test',) + cfg.MODEL.NUM_CLASSES = 21 else: # For subprocess call assert cfg.TEST.DATASETS, 'cfg.TEST.DATASETS shouldn\'t be empty' assert_and_infer_cfg() diff --git a/tools/train_net.py b/tools/train_net.py index 499ba39f..106ad7d7 100644 --- a/tools/train_net.py +++ b/tools/train_net.py @@ -157,6 +157,9 @@ def main(): elif args.dataset == "keypoints_coco2017": cfg.TRAIN.DATASETS = ('keypoints_coco_2017_train',) cfg.MODEL.NUM_CLASSES = 2 + elif args.dataset == "voc2007": + cfg.TRAIN.DATASETS = ('voc_2007_train',) + cfg.MODEL.NUM_CLASSES = 21 else: raise ValueError("Unexpected args.dataset: {}".format(args.dataset)) diff --git a/tools/train_net_step.py b/tools/train_net_step.py index 10c8c367..edfd10f8 100644 --- a/tools/train_net_step.py +++ b/tools/train_net_step.py @@ -156,6 +156,9 @@ def main(): elif args.dataset == "keypoints_coco2017": cfg.TRAIN.DATASETS = ('keypoints_coco_2017_train',) cfg.MODEL.NUM_CLASSES = 2 + elif args.dataset == "voc2007": + cfg.TRAIN.DATASETS = ('voc_2007_train',) + cfg.MODEL.NUM_CLASSES = 21 else: raise ValueError("Unexpected args.dataset: {}".format(args.dataset)) From 8e028b60db638f17e4a0db4bdb4950d39b3258e8 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 10:10:38 +0530 Subject: [PATCH 23/52] add xml2json converter file --- tools/pascal_voc_xml2json.py | 172 +++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 tools/pascal_voc_xml2json.py diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py new file mode 100644 index 00000000..65137b0b --- /dev/null +++ b/tools/pascal_voc_xml2json.py @@ -0,0 +1,172 @@ +import xml.etree.ElementTree as ET +import os +import json + +coco = dict() +coco['images'] = [] +coco['type'] = 'instances' +coco['annotations'] = [] +coco['categories'] = [] + +category_set = dict() +image_set = set() + +category_item_id = 0 +image_id = 20180000000 +annotation_id = 0 + +def addCatItem(name): + global category_item_id + category_item = dict() + category_item['supercategory'] = 'none' + category_item_id += 1 + category_item['id'] = category_item_id + category_item['name'] = name + coco['categories'].append(category_item) + category_set[name] = category_item_id + return category_item_id + +def addImgItem(file_name, size): + global image_id + if file_name is None: + raise Exception('Could not find filename tag in xml file.') + if size['width'] is None: + raise Exception('Could not find width tag in xml file.') + if size['height'] is None: + raise Exception('Could not find height tag in xml file.') + image_id += 1 + image_item = dict() + image_item['id'] = image_id + image_item['file_name'] = file_name + image_item['width'] = size['width'] + image_item['height'] = size['height'] + coco['images'].append(image_item) + image_set.add(file_name) + return image_id + +def addAnnoItem(object_name, image_id, category_id, bbox): + global annotation_id + annotation_item = dict() + annotation_item['segmentation'] = [] + seg = [] + #bbox[] is x,y,w,h + #left_top + seg.append(bbox[0]) + seg.append(bbox[1]) + #left_bottom + seg.append(bbox[0]) + seg.append(bbox[1] + bbox[3]) + #right_bottom + seg.append(bbox[0] + bbox[2]) + seg.append(bbox[1] + bbox[3]) + #right_top + seg.append(bbox[0] + bbox[2]) + seg.append(bbox[1]) + + annotation_item['segmentation'].append(seg) + + annotation_item['area'] = bbox[2] * bbox[3] + annotation_item['iscrowd'] = 0 + annotation_item['ignore'] = 0 + annotation_item['image_id'] = image_id + annotation_item['bbox'] = bbox + annotation_item['category_id'] = category_id + annotation_id += 1 + annotation_item['id'] = annotation_id + coco['annotations'].append(annotation_item) + +def parseXmlFiles(xml_path): + for f in os.listdir(xml_path): + if not f.endswith('.xml'): + continue + + bndbox = dict() + size = dict() + current_image_id = None + current_category_id = None + file_name = None + size['width'] = None + size['height'] = None + size['depth'] = None + + xml_file = os.path.join(xml_path, f) + print(xml_file) + + tree = ET.parse(xml_file) + root = tree.getroot() + if root.tag != 'annotation': + raise Exception('pascal voc xml root element should be annotation, rather than {}'.format(root.tag)) + + #elem is , , , + for elem in root: + current_parent = elem.tag + current_sub = None + object_name = None + + if elem.tag == 'folder': + continue + + if elem.tag == 'filename': + file_name = elem.text + if file_name in category_set: + raise Exception('file_name duplicated') + + #add img item only after parse tag + elif current_image_id is None and file_name is not None and size['width'] is not None: + if file_name not in image_set: + current_image_id = addImgItem(file_name, size) + print('add image with {} and {}'.format(file_name, size)) + else: + raise Exception('duplicated image: {}'.format(file_name)) + #subelem is , , , , + for subelem in elem: + bndbox ['xmin'] = None + bndbox ['xmax'] = None + bndbox ['ymin'] = None + bndbox ['ymax'] = None + + current_sub = subelem.tag + if current_parent == 'object' and subelem.tag == 'name': + object_name = subelem.text + if object_name not in category_set: + current_category_id = addCatItem(object_name) + else: + current_category_id = category_set[object_name] + + elif current_parent == 'size': + if size[subelem.tag] is not None: + raise Exception('xml structure broken at size tag.') + size[subelem.tag] = int(subelem.text) + + #option is , , , , when subelem is + for option in subelem: + if current_sub == 'bndbox': + if bndbox[option.tag] is not None: + raise Exception('xml structure corrupted at bndbox tag.') + bndbox[option.tag] = int(option.text) + + #only after parse the tag + if bndbox['xmin'] is not None: + if object_name is None: + raise Exception('xml structure broken at bndbox tag') + if current_image_id is None: + raise Exception('xml structure broken at bndbox tag') + if current_category_id is None: + raise Exception('xml structure broken at bndbox tag') + bbox = [] + #x + bbox.append(bndbox['xmin']) + #y + bbox.append(bndbox['ymin']) + #w + bbox.append(bndbox['xmax'] - bndbox['xmin']) + #h + bbox.append(bndbox['ymax'] - bndbox['ymin']) + print('add annotation with {},{},{},{}'.format(object_name, current_image_id, current_category_id, bbox)) + addAnnoItem(object_name, current_image_id, current_category_id, bbox ) + +if __name__ == '__main__': + xml_path = 'Annotations' + json_file = 'instances.json' + parseXmlFiles(xml_path) + json.dump(coco, open(json_file, 'w')) \ No newline at end of file From 5902b41229c3beda27a2745c097cbd03153cfbc1 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 11:47:07 +0530 Subject: [PATCH 24/52] add voc_xml2json++ file --- tools/pascal_voc_xml2json.py | 121 ++++++++++++++++++++++------------- 1 file changed, 75 insertions(+), 46 deletions(-) diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py index 65137b0b..58008c5c 100644 --- a/tools/pascal_voc_xml2json.py +++ b/tools/pascal_voc_xml2json.py @@ -2,18 +2,6 @@ import os import json -coco = dict() -coco['images'] = [] -coco['type'] = 'instances' -coco['annotations'] = [] -coco['categories'] = [] - -category_set = dict() -image_set = set() - -category_item_id = 0 -image_id = 20180000000 -annotation_id = 0 def addCatItem(name): global category_item_id @@ -26,6 +14,7 @@ def addCatItem(name): category_set[name] = category_item_id return category_item_id + def addImgItem(file_name, size): global image_id if file_name is None: @@ -44,22 +33,23 @@ def addImgItem(file_name, size): image_set.add(file_name) return image_id + def addAnnoItem(object_name, image_id, category_id, bbox): global annotation_id annotation_item = dict() annotation_item['segmentation'] = [] seg = [] - #bbox[] is x,y,w,h - #left_top + # bbox[] is x,y,w,h + # left_top seg.append(bbox[0]) seg.append(bbox[1]) - #left_bottom + # left_bottom seg.append(bbox[0]) seg.append(bbox[1] + bbox[3]) - #right_bottom + # right_bottom seg.append(bbox[0] + bbox[2]) seg.append(bbox[1] + bbox[3]) - #right_top + # right_top seg.append(bbox[0] + bbox[2]) seg.append(bbox[1]) @@ -73,13 +63,14 @@ def addAnnoItem(object_name, image_id, category_id, bbox): annotation_item['category_id'] = category_id annotation_id += 1 annotation_item['id'] = annotation_id - coco['annotations'].append(annotation_item) + return annotation_item + -def parseXmlFiles(xml_path): +def parseXmlFiles(xml_path, file_list): for f in os.listdir(xml_path): - if not f.endswith('.xml'): + if (not f.endswith('.xml')) and (not any(f in fl for fl in file_list)): continue - + bndbox = dict() size = dict() current_image_id = None @@ -95,36 +86,38 @@ def parseXmlFiles(xml_path): tree = ET.parse(xml_file) root = tree.getroot() if root.tag != 'annotation': - raise Exception('pascal voc xml root element should be annotation, rather than {}'.format(root.tag)) + raise Exception( + 'pascal voc xml root element should be annotation, rather than {}'. + format(root.tag)) - #elem is , , , + # elem is , , , for elem in root: current_parent = elem.tag current_sub = None object_name = None - + if elem.tag == 'folder': continue - + if elem.tag == 'filename': file_name = elem.text if file_name in category_set: raise Exception('file_name duplicated') - - #add img item only after parse tag + + # add img item only after parse tag elif current_image_id is None and file_name is not None and size['width'] is not None: if file_name not in image_set: current_image_id = addImgItem(file_name, size) print('add image with {} and {}'.format(file_name, size)) else: - raise Exception('duplicated image: {}'.format(file_name)) - #subelem is , , , , + raise Exception('duplicated image: {}'.format(file_name)) + # subelem is , , , , for subelem in elem: - bndbox ['xmin'] = None - bndbox ['xmax'] = None - bndbox ['ymin'] = None - bndbox ['ymax'] = None - + bndbox['xmin'] = None + bndbox['xmax'] = None + bndbox['ymin'] = None + bndbox['ymax'] = None + current_sub = subelem.tag if current_parent == 'object' and subelem.tag == 'name': object_name = subelem.text @@ -138,14 +131,15 @@ def parseXmlFiles(xml_path): raise Exception('xml structure broken at size tag.') size[subelem.tag] = int(subelem.text) - #option is , , , , when subelem is + # option is , , , , when subelem is for option in subelem: if current_sub == 'bndbox': if bndbox[option.tag] is not None: - raise Exception('xml structure corrupted at bndbox tag.') + raise Exception( + 'xml structure corrupted at bndbox tag.') bndbox[option.tag] = int(option.text) - #only after parse the tag + # only after parse the tag if bndbox['xmin'] is not None: if object_name is None: raise Exception('xml structure broken at bndbox tag') @@ -154,19 +148,54 @@ def parseXmlFiles(xml_path): if current_category_id is None: raise Exception('xml structure broken at bndbox tag') bbox = [] - #x + # x bbox.append(bndbox['xmin']) - #y + # y bbox.append(bndbox['ymin']) - #w + # w bbox.append(bndbox['xmax'] - bndbox['xmin']) - #h + # h bbox.append(bndbox['ymax'] - bndbox['ymin']) - print('add annotation with {},{},{},{}'.format(object_name, current_image_id, current_category_id, bbox)) - addAnnoItem(object_name, current_image_id, current_category_id, bbox ) + print('add annotation with {},{},{},{}'.format( + object_name, current_image_id, current_category_id, + bbox)) + return addAnnoItem(object_name, current_image_id, + current_category_id, bbox) + if __name__ == '__main__': + image_sets_path = 'ImageSets/Main' + anno_path = 'annotations' xml_path = 'Annotations' - json_file = 'instances.json' - parseXmlFiles(xml_path) - json.dump(coco, open(json_file, 'w')) \ No newline at end of file + for f in os.listdir(image_sets_path): + if not f.endswith('.txt'): + continue + + coco = dict() + coco['images'] = [] + coco['type'] = 'instances' + coco['annotations'] = [] + coco['categories'] = [] + + category_set = dict() + image_set = set() + + category_item_id = 0 + image_id = 20180000000 + annotation_id = 0 + + image_set_file = os.path.join(image_sets_path, f) + + file_list = [] + with open(image_set_file, 'r') as isf: + lines = isf.readlines() + for line in lines: + file_list.append(line.strip() + '.xml') + + annotation_item = parseXmlFiles(xml_path, file_list) + coco['annotations'].append(annotation_item) + + json_file = f.split('.')[0] + '.json' + json_file_path = os.path.join(anno_path, json_file) + print('Writing to file {0}'.format(json_file_path)) + json.dump(coco, open(json_file_path, 'w')) From 2d135cbc5bf7ed9dbc119b26715327e942314399 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 11:53:01 +0530 Subject: [PATCH 25/52] create directory if doesn't exist --- tools/pascal_voc_xml2json.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py index 58008c5c..74d08bf3 100644 --- a/tools/pascal_voc_xml2json.py +++ b/tools/pascal_voc_xml2json.py @@ -167,6 +167,10 @@ def parseXmlFiles(xml_path, file_list): image_sets_path = 'ImageSets/Main' anno_path = 'annotations' xml_path = 'Annotations' + + if os.path.exists(anno_path): + os.makedirs(anno_path) + for f in os.listdir(image_sets_path): if not f.endswith('.txt'): continue From fb94d36bb9474dc9198dcf9edd8e3791e4fb94cc Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 12:00:30 +0530 Subject: [PATCH 26/52] bug_fix --- tools/pascal_voc_xml2json.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py index 74d08bf3..1436c5cc 100644 --- a/tools/pascal_voc_xml2json.py +++ b/tools/pascal_voc_xml2json.py @@ -63,7 +63,7 @@ def addAnnoItem(object_name, image_id, category_id, bbox): annotation_item['category_id'] = category_id annotation_id += 1 annotation_item['id'] = annotation_id - return annotation_item + coco['annotations'].append(annotation_item) def parseXmlFiles(xml_path, file_list): @@ -159,7 +159,7 @@ def parseXmlFiles(xml_path, file_list): print('add annotation with {},{},{},{}'.format( object_name, current_image_id, current_category_id, bbox)) - return addAnnoItem(object_name, current_image_id, + addAnnoItem(object_name, current_image_id, current_category_id, bbox) @@ -175,7 +175,7 @@ def parseXmlFiles(xml_path, file_list): if not f.endswith('.txt'): continue - coco = dict() + global coco = dict() coco['images'] = [] coco['type'] = 'instances' coco['annotations'] = [] @@ -196,8 +196,7 @@ def parseXmlFiles(xml_path, file_list): for line in lines: file_list.append(line.strip() + '.xml') - annotation_item = parseXmlFiles(xml_path, file_list) - coco['annotations'].append(annotation_item) + parseXmlFiles(xml_path, file_list) json_file = f.split('.')[0] + '.json' json_file_path = os.path.join(anno_path, json_file) From 8f904cb5fbb31ca965284855ed0989f980c895f2 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 12:17:24 +0530 Subject: [PATCH 27/52] minor fix and tested --- tools/pascal_voc_xml2json.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py index 1436c5cc..60c8cd8f 100644 --- a/tools/pascal_voc_xml2json.py +++ b/tools/pascal_voc_xml2json.py @@ -164,18 +164,22 @@ def parseXmlFiles(xml_path, file_list): if __name__ == '__main__': + """ + Change the image_sets_path, anno_path and xml_path as per your + absolute path for this script to work. + """ + + global coco + image_sets_path = 'ImageSets/Main' anno_path = 'annotations' xml_path = 'Annotations' - if os.path.exists(anno_path): - os.makedirs(anno_path) - for f in os.listdir(image_sets_path): if not f.endswith('.txt'): continue - global coco = dict() + coco = dict() coco['images'] = [] coco['type'] = 'instances' coco['annotations'] = [] From 04fcdee6a73a03d52815ecf8175b63a8a5a5f949 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 14:14:35 +0530 Subject: [PATCH 28/52] minor modifications --- lib/datasets/dataset_catalog.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index c3eb55eb..859eb74f 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -197,7 +197,7 @@ IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/voc_2007_train.json', + _DATA_DIR + '/VOC2007/annotations/train.json', DEVKIT_DIR: _DATA_DIR + '/VOC2007/VOCdevkit2007' }, @@ -205,7 +205,7 @@ IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/voc_2007_trainval.json', + _DATA_DIR + '/VOC2007/annotations/trainval.json', DEVKIT_DIR: _DATA_DIR + '/VOC2007/VOCdevkit2007' }, @@ -213,7 +213,7 @@ IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/voc_2007_test.json', + _DATA_DIR + '/VOC2007/annotations/test.json', DEVKIT_DIR: _DATA_DIR + '/VOC2007/VOCdevkit2007' }, From d7a042f4d9b6dcac44c9b3abc8afafe361053a93 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 17:42:11 +0530 Subject: [PATCH 29/52] add documentation --- tools/pascal_voc_xml2json.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py index 60c8cd8f..dda7f4de 100644 --- a/tools/pascal_voc_xml2json.py +++ b/tools/pascal_voc_xml2json.py @@ -1,3 +1,12 @@ +""" +THis code is borrowed from @gemfield, the original code can be found here: +https://github.com/CivilNet/Gemfield/blob/master/src/python/pascal_voc_xml2json/pascal_voc_xml2json.py + +This code converts the XMLs annotations to JSON according to the various +splits defined in the ImageSets/Main directory. You may need to provide +absolute path to the relevant variables in the main function below. +""" + import xml.etree.ElementTree as ET import os import json @@ -87,8 +96,8 @@ def parseXmlFiles(xml_path, file_list): root = tree.getroot() if root.tag != 'annotation': raise Exception( - 'pascal voc xml root element should be annotation, rather than {}'. - format(root.tag)) + 'pascal voc xml root element should be annotation,\ + rather than {}'.format(root.tag)) # elem is , , , for elem in root: @@ -131,7 +140,8 @@ def parseXmlFiles(xml_path, file_list): raise Exception('xml structure broken at size tag.') size[subelem.tag] = int(subelem.text) - # option is , , , , when subelem is + # option is , , , , + # when subelem is for option in subelem: if current_sub == 'bndbox': if bndbox[option.tag] is not None: @@ -160,7 +170,7 @@ def parseXmlFiles(xml_path, file_list): object_name, current_image_id, current_category_id, bbox)) addAnnoItem(object_name, current_image_id, - current_category_id, bbox) + current_category_id, bbox) if __name__ == '__main__': From 7b9d9c7d5e457e6c131276d172307a194af6b527 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 18:41:32 +0530 Subject: [PATCH 30/52] add support for voc12 and custom dataset --- lib/datasets/dataset_catalog.py | 32 +++++++++++++++----------------- tools/test_net.py | 10 ++++++++++ tools/train_net.py | 13 +++++++++++++ tools/train_net_step.py | 13 +++++++++++++ 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index 859eb74f..322b7b61 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -193,36 +193,34 @@ ANN_FN: _DATA_DIR + '/coco/annotations/image_info_test2017.json' }, - 'voc_2007_train': { - IM_DIR: - _DATA_DIR + '/VOC2007/JPEGImages', - ANN_FN: - _DATA_DIR + '/VOC2007/annotations/train.json', - DEVKIT_DIR: - _DATA_DIR + '/VOC2007/VOCdevkit2007' - }, 'voc_2007_trainval': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/trainval.json', - DEVKIT_DIR: - _DATA_DIR + '/VOC2007/VOCdevkit2007' + _DATA_DIR + '/VOC2007/annotations/trainval.json' }, 'voc_2007_test': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/test.json', - DEVKIT_DIR: - _DATA_DIR + '/VOC2007/VOCdevkit2007' + _DATA_DIR + '/VOC2007/annotations/test.json' }, 'voc_2012_trainval': { IM_DIR: _DATA_DIR + '/VOC2012/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2012/annotations/voc_2012_trainval.json', - DEVKIT_DIR: - _DATA_DIR + '/VOC2012/VOCdevkit2012' + _DATA_DIR + '/VOC2012/annotations/trainval.json' + }, + 'custom_data_train': { + IM_DIR: + _DATA_DIR + '/CustomData/JPEGImages', + ANN_FN: + _DATA_DIR + '/CustomData/annotations/trainval.json' + }, + 'custom_data_test': { + IM_DIR: + _DATA_DIR + '/CustomData/JPEGImages', + ANN_FN: + _DATA_DIR + '/CustomData/annotations/test.json' } } diff --git a/tools/test_net.py b/tools/test_net.py index e0f66216..295cfe4d 100644 --- a/tools/test_net.py +++ b/tools/test_net.py @@ -25,6 +25,10 @@ def parse_args(): parser.add_argument( '--dataset', help='training dataset') + parser.add_argument( + '--num_classes', dest='num_classes', + help='Number of classes in your custom dataset', + default=None, type=int) parser.add_argument( '--cfg', dest='cfg_file', required=True, help='optional config file') @@ -82,6 +86,9 @@ def parse_args(): cfg.VIS = args.vis + if args.dataset == "custom_dataset" and args.num_classes is None: + raise ValueError("Need number of classes in your custom dataset to run!") + if args.cfg_file is not None: merge_cfg_from_file(args.cfg_file) if args.set_cfgs is not None: @@ -96,6 +103,9 @@ def parse_args(): elif args.dataset == "voc2007": cfg.TEST.DATASETS = ('voc_2007_test',) cfg.MODEL.NUM_CLASSES = 21 + elif args.dataset == "custom_dataset": + cfg.TEST.DATASETS = ('custom_data_test',) + cfg.MODEL.NUM_CLASSES = args.num_classes else: # For subprocess call assert cfg.TEST.DATASETS, 'cfg.TEST.DATASETS shouldn\'t be empty' assert_and_infer_cfg() diff --git a/tools/train_net.py b/tools/train_net.py index 106ad7d7..22073759 100644 --- a/tools/train_net.py +++ b/tools/train_net.py @@ -50,6 +50,10 @@ def parse_args(): parser.add_argument( '--dataset', dest='dataset', required=True, help='Dataset to use') + parser.add_argument( + '--num_classes', dest='num_classes', + help='Number of classes in your custom dataset', + default=None, type=int) parser.add_argument( '--cfg', dest='cfg_file', required=True, help='Config file for training (and optionally testing)') @@ -151,6 +155,9 @@ def main(): else: raise ValueError("Need Cuda device to run !") + if args.dataset == "custom_dataset" and args.num_classes is None: + raise ValueError("Need number of classes in your custom dataset to run!") + if args.dataset == "coco2017": cfg.TRAIN.DATASETS = ('coco_2017_train',) cfg.MODEL.NUM_CLASSES = 81 @@ -160,6 +167,12 @@ def main(): elif args.dataset == "voc2007": cfg.TRAIN.DATASETS = ('voc_2007_train',) cfg.MODEL.NUM_CLASSES = 21 + elif args.dataset == "voc2012": + cfg.TRAIN.DATASETS = ('voc_2012_train',) + cfg.MODEL.NUM_CLASSES = 21 + elif args.dataset == "custom_dataset": + cfg.TRAIN.DATASETS = ('custom_data_train',) + cfg.MODEL.NUM_CLASSES = args.num_classes else: raise ValueError("Unexpected args.dataset: {}".format(args.dataset)) diff --git a/tools/train_net_step.py b/tools/train_net_step.py index edfd10f8..09839c93 100644 --- a/tools/train_net_step.py +++ b/tools/train_net_step.py @@ -45,6 +45,10 @@ def parse_args(): parser.add_argument( '--dataset', dest='dataset', required=True, help='Dataset to use') + parser.add_argument( + '--num_classes', dest='num_classes', + help='Number of classes in your custom dataset', + default=None, type=int) parser.add_argument( '--cfg', dest='cfg_file', required=True, help='Config file for training (and optionally testing)') @@ -150,6 +154,9 @@ def main(): else: raise ValueError("Need Cuda device to run !") + if args.dataset == "custom_dataset" and args.num_classes is None: + raise ValueError("Need number of classes in your custom dataset to run!") + if args.dataset == "coco2017": cfg.TRAIN.DATASETS = ('coco_2017_train',) cfg.MODEL.NUM_CLASSES = 81 @@ -159,6 +166,12 @@ def main(): elif args.dataset == "voc2007": cfg.TRAIN.DATASETS = ('voc_2007_train',) cfg.MODEL.NUM_CLASSES = 21 + elif args.dataset == "voc2012": + cfg.TRAIN.DATASETS = ('voc_2012_train',) + cfg.MODEL.NUM_CLASSES = 21 + elif args.dataset == "custom_dataset": + cfg.TRAIN.DATASETS = ('custom_data_train',) + cfg.MODEL.NUM_CLASSES = args.num_classes else: raise ValueError("Unexpected args.dataset: {}".format(args.dataset)) From 48b0fe7d70b5f956568ef5f865421ce40b3ca60c Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Thu, 24 May 2018 19:08:51 +0530 Subject: [PATCH 31/52] update README.md --- README.md | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a2b4a5e4..24063ff7 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ mkdir data ├── train2014 ├── train2017 ├── val2014 - ├──val2017 + ├── val2017 ├── ... ``` Download coco mini annotations from [here](https://s3-us-west-2.amazonaws.com/detectron/coco/coco_annotations_minival.tgz). @@ -127,8 +127,35 @@ mkdir data ``` ln -s path/to/coco data/coco ``` + +- **PASCAL VOC 2007 + 12** + Please follow the instructions in [py-faster-rcnn](https://github.com/rbgirshick/py-faster-rcnn#beyond-the-demo-installation-for-training-and-testing-models) to prepare VOC datasets. Actually, you can refer to any others. After downloading the data, creat softlinks in the `data/VOC` folder as folows, + ``` + mkdir -p $DETECTRON/detectron/datasets/data/VOC + ln -s /path/to/VOC/JPEGImages $DETECTRON.PYTORCH/data/VOC/JPEGImages + ln -s /path/to/VOC/json/annotations $DETECTRON.PYTORCH/data/VOC/annotations + ``` + The directory structure of `JPEGImages` and `annotations` should be as follows, + ``` + VOC + ├── annotations + | ├── train.json + │   ├── trainval.json + │   ├── test.json + │   ├── ... + | + └── JPEGImages + ├── .jpg + ├── ... + ├── .jpg + ``` + **NOTE:** The `annotations` folder requires you to have PASCAL VOC annotations in COCO json format, which is available for download [here](https://storage.googleapis.com/coco-dataset/external/PASCAL_VOC.zip). You can also convert the XML annotatinos files to JSON by running the following script, + ``` + python tools/pascal_voc_xml2json.py + ``` + (In order to succesfully run the script above, you need to update the full path to the respective folders in the script). - Recommend to put the images on a SSD for possible better training performance +Recommend to put the images on a SSD for possible better training performance ### Pretrained Model @@ -200,7 +227,11 @@ Use `--bs` to overwrite the default batch size to a proper value that fits into Specify `—-use_tfboard` to log the losses on Tensorboard. -**NOTE**: use `--dataset keypoints_coco2017` when training for keypoint-rcnn. +**NOTE**: + - use `--dataset keypoints_coco2017` when training for keypoint-rcnn. + - use `--dataset voc2007` when training for PASCAL VOC 2007. + - use `--dataset voc2012` when training for PASCAL VOC 2012. + - use `--dataset custom_dataset --num_classes $NUM_CLASSES` when training for your custom dataset. Here, `$NUM_CLASSES` is the number of object classes + 1 (for background class) present in your custom dataset. ### The use of `--iter_size` As in Caffe, update network once (`optimizer.step()`) every `iter_size` iterations (forward + backward). This way to have a larger effective batch size for training. Notice that, step count is only increased after network update. From 14cd533a8c7ae3ef6b4f75f023f1b3baf3c3af63 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 24 May 2018 20:41:58 +0530 Subject: [PATCH 32/52] minor fix --- lib/datasets/dataset_catalog.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index 322b7b61..1aba825f 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -193,6 +193,12 @@ ANN_FN: _DATA_DIR + '/coco/annotations/image_info_test2017.json' }, + 'voc_2007_train': { + IM_DIR: + _DATA_DIR + '/VOC2007/JPEGImages', + ANN_FN: + _DATA_DIR + '/VOC2007/annotations/train.json' + }, 'voc_2007_trainval': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', @@ -205,6 +211,12 @@ ANN_FN: _DATA_DIR + '/VOC2007/annotations/test.json' }, + 'voc_2012_train': { + IM_DIR: + _DATA_DIR + '/VOC2012/JPEGImages', + ANN_FN: + _DATA_DIR + '/VOC2012/annotations/train.json' + }, 'voc_2012_trainval': { IM_DIR: _DATA_DIR + '/VOC2012/JPEGImages', @@ -212,6 +224,12 @@ _DATA_DIR + '/VOC2012/annotations/trainval.json' }, 'custom_data_train': { + IM_DIR: + _DATA_DIR + '/CustomData/JPEGImages', + ANN_FN: + _DATA_DIR + '/CustomData/annotations/train.json' + }, + 'custom_data_trainval': { IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: From 86f54d4e69bf0fa29f9f9d86fe5474b291601baf Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Fri, 25 May 2018 00:30:15 +0530 Subject: [PATCH 33/52] fix json conversion file --- tools/pascal_voc_xml2coco_json.py | 154 +++++++++++++++++++++ tools/pascal_voc_xml2json.py | 218 ------------------------------ 2 files changed, 154 insertions(+), 218 deletions(-) create mode 100644 tools/pascal_voc_xml2coco_json.py delete mode 100644 tools/pascal_voc_xml2json.py diff --git a/tools/pascal_voc_xml2coco_json.py b/tools/pascal_voc_xml2coco_json.py new file mode 100644 index 00000000..a0814a1c --- /dev/null +++ b/tools/pascal_voc_xml2coco_json.py @@ -0,0 +1,154 @@ +#!/usr/bin/python + +# pip install lxml + +import sys +import os +import shutil +import json +import xml.etree.ElementTree as ET + +START_BOUNDING_BOX_ID = 1 +PRE_DEFINE_CATEGORIES = {} + +# If necessary, pre-define category and its id +# PRE_DEFINE_CATEGORIES = {"aeroplane": 1, "bicycle": 2, "bird": 3, "boat": 4, +# "bottle":5, "bus": 6, "car": 7, "cat": 8, "chair": 9, +# "cow": 10, "diningtable": 11, "dog": 12, "horse": 13, +# "motorbike": 14, "person": 15, "pottedplant": 16, +# "sheep": 17, "sofa": 18, "train": 19, "tvmonitor": 20} + + +def get(root, name): + vars = root.findall(name) + return vars + + +def get_and_check(root, name, length): + vars = root.findall(name) + if len(vars) == 0: + raise NotImplementedError('Can not find %s in %s.' % (name, root.tag)) + if length > 0 and len(vars) != length: + raise NotImplementedError( + 'The size of %s is supposed to be %d, but is %d.' % (name, length, + len(vars))) + if length == 1: + vars = vars[0] + return vars + + +def get_filename_as_int(filename): + try: + filename = os.path.splitext(filename)[0] + return int(filename) + except: + raise NotImplementedError('Filename %s is supposed to be an integer.' % + (filename)) + + +def convert(xml_list, xml_dir, json_file): + list_fp = open(xml_list, 'r') + json_dict = { + "images": [], + "type": "instances", + "annotations": [], + "categories": [] + } + categories = PRE_DEFINE_CATEGORIES + bnd_id = START_BOUNDING_BOX_ID + for line in list_fp: + line = line.strip().split(' ')[0].strip() + '.xml' + print("Processing {0}" .format(line), end='\r') + xml_f = os.path.join(xml_dir, line) + tree = ET.parse(xml_f) + root = tree.getroot() + path = get(root, 'path') + if len(path) == 1: + filename = os.path.basename(path[0].text) + elif len(path) == 0: + filename = get_and_check(root, 'filename', 1).text + else: + raise NotImplementedError('%d paths found in %s' % (len(path), + line)) + ## The filename must be a number + image_id = get_filename_as_int(filename) + size = get_and_check(root, 'size', 1) + width = int(get_and_check(size, 'width', 1).text) + height = int(get_and_check(size, 'height', 1).text) + image = { + 'file_name': filename, + 'height': height, + 'width': width, + 'id': image_id + } + json_dict['images'].append(image) + ## Cruuently we do not support segmentation + # segmented = get_and_check(root, 'segmented', 1).text + # assert segmented == '0' + for obj in get(root, 'object'): + category = get_and_check(obj, 'name', 1).text + if category not in categories: + new_id = len(categories) + categories[category] = new_id + category_id = categories[category] + bndbox = get_and_check(obj, 'bndbox', 1) + xmin = int(get_and_check(bndbox, 'xmin', 1).text) - 1 + ymin = int(get_and_check(bndbox, 'ymin', 1).text) - 1 + xmax = int(get_and_check(bndbox, 'xmax', 1).text) + ymax = int(get_and_check(bndbox, 'ymax', 1).text) + assert (xmax > xmin) + assert (ymax > ymin) + o_width = abs(xmax - xmin) + o_height = abs(ymax - ymin) + ann = { + 'area': o_width * o_height, + 'iscrowd': 0, + 'image_id': image_id, + 'bbox': [xmin, ymin, o_width, o_height], + 'category_id': category_id, + 'id': bnd_id, + 'ignore': 0, + 'segmentation': [] + } + json_dict['annotations'].append(ann) + bnd_id = bnd_id + 1 + + for cate, cid in categories.items(): + cat = {'supercategory': 'none', 'id': cid, 'name': cate} + json_dict['categories'].append(cat) + json_fp = open(json_file, 'w') + json_str = json.dumps(json_dict) + json_fp.write(json_str) + json_fp.close() + list_fp.close() + + +if __name__ == '__main__': + if len(sys.argv) <= 1: + print('3 auguments are need.') + print('Usage: python {0} ImageSets_DIR XML_DIR OUTPUT_DIR'.format( + sys.argv[0])) + exit(1) + + imagesets_dir = sys.argv[1] + xml_dir = sys.argv[2] + output_dir = sys.argv[3] + + if not os.path.exists(imagesets_dir) and not os.path.exists(xml_dir): + print('PATH not correct, please enter correct path: {0}, {1}'.format( + imagesets_dir, xml_dir)) + raise ValueError('Incorrect PATH provided') + + if os.path.exists(output_dir): + shutil.rmtree(output_dir) + os.makedirs(output_dir) + + for f in os.listdir(imagesets_dir): + if not f.endswith('.txt'): + continue + + print('==> Processing file {0}'.format(f)) + imagesets_file = os.path.join(imagesets_dir, f) + json_file = f.split('.')[0] + '.json' + output_file = os.path.join(output_dir, json_file) + convert(imagesets_file, xml_dir, output_file) diff --git a/tools/pascal_voc_xml2json.py b/tools/pascal_voc_xml2json.py deleted file mode 100644 index dda7f4de..00000000 --- a/tools/pascal_voc_xml2json.py +++ /dev/null @@ -1,218 +0,0 @@ -""" -THis code is borrowed from @gemfield, the original code can be found here: -https://github.com/CivilNet/Gemfield/blob/master/src/python/pascal_voc_xml2json/pascal_voc_xml2json.py - -This code converts the XMLs annotations to JSON according to the various -splits defined in the ImageSets/Main directory. You may need to provide -absolute path to the relevant variables in the main function below. -""" - -import xml.etree.ElementTree as ET -import os -import json - - -def addCatItem(name): - global category_item_id - category_item = dict() - category_item['supercategory'] = 'none' - category_item_id += 1 - category_item['id'] = category_item_id - category_item['name'] = name - coco['categories'].append(category_item) - category_set[name] = category_item_id - return category_item_id - - -def addImgItem(file_name, size): - global image_id - if file_name is None: - raise Exception('Could not find filename tag in xml file.') - if size['width'] is None: - raise Exception('Could not find width tag in xml file.') - if size['height'] is None: - raise Exception('Could not find height tag in xml file.') - image_id += 1 - image_item = dict() - image_item['id'] = image_id - image_item['file_name'] = file_name - image_item['width'] = size['width'] - image_item['height'] = size['height'] - coco['images'].append(image_item) - image_set.add(file_name) - return image_id - - -def addAnnoItem(object_name, image_id, category_id, bbox): - global annotation_id - annotation_item = dict() - annotation_item['segmentation'] = [] - seg = [] - # bbox[] is x,y,w,h - # left_top - seg.append(bbox[0]) - seg.append(bbox[1]) - # left_bottom - seg.append(bbox[0]) - seg.append(bbox[1] + bbox[3]) - # right_bottom - seg.append(bbox[0] + bbox[2]) - seg.append(bbox[1] + bbox[3]) - # right_top - seg.append(bbox[0] + bbox[2]) - seg.append(bbox[1]) - - annotation_item['segmentation'].append(seg) - - annotation_item['area'] = bbox[2] * bbox[3] - annotation_item['iscrowd'] = 0 - annotation_item['ignore'] = 0 - annotation_item['image_id'] = image_id - annotation_item['bbox'] = bbox - annotation_item['category_id'] = category_id - annotation_id += 1 - annotation_item['id'] = annotation_id - coco['annotations'].append(annotation_item) - - -def parseXmlFiles(xml_path, file_list): - for f in os.listdir(xml_path): - if (not f.endswith('.xml')) and (not any(f in fl for fl in file_list)): - continue - - bndbox = dict() - size = dict() - current_image_id = None - current_category_id = None - file_name = None - size['width'] = None - size['height'] = None - size['depth'] = None - - xml_file = os.path.join(xml_path, f) - print(xml_file) - - tree = ET.parse(xml_file) - root = tree.getroot() - if root.tag != 'annotation': - raise Exception( - 'pascal voc xml root element should be annotation,\ - rather than {}'.format(root.tag)) - - # elem is , , , - for elem in root: - current_parent = elem.tag - current_sub = None - object_name = None - - if elem.tag == 'folder': - continue - - if elem.tag == 'filename': - file_name = elem.text - if file_name in category_set: - raise Exception('file_name duplicated') - - # add img item only after parse tag - elif current_image_id is None and file_name is not None and size['width'] is not None: - if file_name not in image_set: - current_image_id = addImgItem(file_name, size) - print('add image with {} and {}'.format(file_name, size)) - else: - raise Exception('duplicated image: {}'.format(file_name)) - # subelem is , , , , - for subelem in elem: - bndbox['xmin'] = None - bndbox['xmax'] = None - bndbox['ymin'] = None - bndbox['ymax'] = None - - current_sub = subelem.tag - if current_parent == 'object' and subelem.tag == 'name': - object_name = subelem.text - if object_name not in category_set: - current_category_id = addCatItem(object_name) - else: - current_category_id = category_set[object_name] - - elif current_parent == 'size': - if size[subelem.tag] is not None: - raise Exception('xml structure broken at size tag.') - size[subelem.tag] = int(subelem.text) - - # option is , , , , - # when subelem is - for option in subelem: - if current_sub == 'bndbox': - if bndbox[option.tag] is not None: - raise Exception( - 'xml structure corrupted at bndbox tag.') - bndbox[option.tag] = int(option.text) - - # only after parse the tag - if bndbox['xmin'] is not None: - if object_name is None: - raise Exception('xml structure broken at bndbox tag') - if current_image_id is None: - raise Exception('xml structure broken at bndbox tag') - if current_category_id is None: - raise Exception('xml structure broken at bndbox tag') - bbox = [] - # x - bbox.append(bndbox['xmin']) - # y - bbox.append(bndbox['ymin']) - # w - bbox.append(bndbox['xmax'] - bndbox['xmin']) - # h - bbox.append(bndbox['ymax'] - bndbox['ymin']) - print('add annotation with {},{},{},{}'.format( - object_name, current_image_id, current_category_id, - bbox)) - addAnnoItem(object_name, current_image_id, - current_category_id, bbox) - - -if __name__ == '__main__': - """ - Change the image_sets_path, anno_path and xml_path as per your - absolute path for this script to work. - """ - - global coco - - image_sets_path = 'ImageSets/Main' - anno_path = 'annotations' - xml_path = 'Annotations' - - for f in os.listdir(image_sets_path): - if not f.endswith('.txt'): - continue - - coco = dict() - coco['images'] = [] - coco['type'] = 'instances' - coco['annotations'] = [] - coco['categories'] = [] - - category_set = dict() - image_set = set() - - category_item_id = 0 - image_id = 20180000000 - annotation_id = 0 - - image_set_file = os.path.join(image_sets_path, f) - - file_list = [] - with open(image_set_file, 'r') as isf: - lines = isf.readlines() - for line in lines: - file_list.append(line.strip() + '.xml') - - parseXmlFiles(xml_path, file_list) - - json_file = f.split('.')[0] + '.json' - json_file_path = os.path.join(anno_path, json_file) - print('Writing to file {0}'.format(json_file_path)) - json.dump(coco, open(json_file_path, 'w')) From 8822517a62cad2d5864d705e459fed4303590960 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Fri, 25 May 2018 00:33:14 +0530 Subject: [PATCH 34/52] minor fix --- tools/pascal_voc_xml2coco_json.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pascal_voc_xml2coco_json.py b/tools/pascal_voc_xml2coco_json.py index a0814a1c..22044fd8 100644 --- a/tools/pascal_voc_xml2coco_json.py +++ b/tools/pascal_voc_xml2coco_json.py @@ -125,7 +125,7 @@ def convert(xml_list, xml_dir, json_file): if __name__ == '__main__': if len(sys.argv) <= 1: - print('3 auguments are need.') + print('3 auguments are needed.') print('Usage: python {0} ImageSets_DIR XML_DIR OUTPUT_DIR'.format( sys.argv[0])) exit(1) From 80322f229d94626c37a423a74b654ab7910beca7 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Fri, 25 May 2018 00:58:52 +0530 Subject: [PATCH 35/52] check segmentation converter --- tools/pascal_voc_xml2coco_json_converter.py | 300 ++++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 tools/pascal_voc_xml2coco_json_converter.py diff --git a/tools/pascal_voc_xml2coco_json_converter.py b/tools/pascal_voc_xml2coco_json_converter.py new file mode 100644 index 00000000..51fb0167 --- /dev/null +++ b/tools/pascal_voc_xml2coco_json_converter.py @@ -0,0 +1,300 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Mar 08 16:01:57 2018 + +Convert VOC dataset into COCO dataset + +@author: wkoa +""" +import os +import sys +import json +import xml.etree.ElementTree as ET +import numpy as np +import cv2 + + +def _isArrayLike(obj): + return hasattr(obj, '__iter__') and hasattr(obj, '__len__') + + +class voc2coco: + def __init__(self, devkit_path=None, year=None): + self.classes = ( + '__background__', # always index 0 + 'aeroplane', + 'bicycle', + 'bird', + 'boat', + 'bottle', + 'bus', + 'car', + 'cat', + 'chair', + 'cow', + 'diningtable', + 'dog', + 'horse', + 'motorbike', + 'person', + 'pottedplant', + 'sheep', + 'sofa', + 'train', + 'tvmonitor') + #self.classes = ('__background__', + # 'bottle','box','brush','cabbage','dolphin', + # 'eggplant','hedgehog','lion','polarbear', + # 'squirrel') + + self.num_classes = len(self.classes) + assert 'VOCdevkit' in devkit_path, 'VOCdevkit path does not exist: {}'.format( + devkit_path) + self.data_path = os.path.join(devkit_path, 'VOC' + year) + self.annotaions_path = os.path.join(self.data_path, 'Annotations') + self.image_set_path = os.path.join(self.data_path, 'ImageSets') + self.year = year + self.categories_to_ids_map = self._get_categories_to_ids_map() + self.categories_msg = self._categories_msg_generator() + + def _load_annotation(self, ids=[]): + """ + Load annotations by ids + :param ids (int array) : get amms for idss + :return image_msg + return annotation_msg + """ + ids = ids if _isArrayLike(ids) else [ids] + image_msg = [] + annotation_msg = [] + annotation_id = 1 + for index in ids: + filename = '{:0>6}'.format(index) + json_file = os.path.join(self.data_path, 'Segmentation_json', + filename + '.json') + #Labelme label file .json + if os.path.exists(json_file): + img_file = os.path.join(self.data_path, 'JPEGImages', + filename + '.jpg') + im = cv2.imread(img_file) + width = im.shape[1] + height = im.shape[0] + seg_data = json.load(open(json_file, 'r')) + assert type(seg_data) == type( + dict()), 'annotation file format {} not supported'.format( + type(seg_data)) + for shape in seg_data['shapes']: + seg_msg = [] + for point in shape['points']: + seg_msg += point + one_ann_msg = { + "segmentation": [seg_msg], + "area": self._area_computer(shape['points']), + "iscrowd": 0, + "image_id": int(index), + "bbox": self._points_to_mbr(shape['points']), + "category_id": + self.categories_to_ids_map[shape['label']], + "id": annotation_id, + "ignore": 0 + } + annotation_msg.append(one_ann_msg) + annotation_id += 1 + #LabelImg label file .xml + else: + xml_file = os.path.join(self.annotaions_path, + filename + '.xml') + tree = ET.parse(xml_file) + size = tree.find('size') + objs = tree.findall('object') + width = size.find('width').text + height = size.find('height').text + for obj in objs: + bndbox = obj.find('bndbox') + [xmin, xmax, ymin, ymax] = [ + int(bndbox.find('xmin').text) - 1, + int(bndbox.find('xmax').text), + int(bndbox.find('ymin').text) - 1, + int(bndbox.find('ymax').text) + ] + if xmin < 0: + xmin = 0 + if ymin < 0: + ymin = 0 + bbox = [xmin, xmax, ymin, ymax] + one_ann_msg = { + "segmentation": + self._bbox_to_mask(bbox), + "area": + self._bbox_area_computer(bbox), + "iscrowd": + 0, + "image_id": + int(index), + "bbox": [xmin, ymin, xmax - xmin, ymax - ymin], + "category_id": + self.categories_to_ids_map[obj.find('name').text], + "id": + annotation_id, + "ignore": + 0 + } + annotation_msg.append(one_ann_msg) + annotation_id += 1 + one_image_msg = { + "file_name": filename + ".jpg", + "height": int(height), + "width": int(width), + "id": int(index) + } + image_msg.append(one_image_msg) + return image_msg, annotation_msg + + def _bbox_to_mask(self, bbox): + """" + Generate mask by bbox + :param bbox e.g. [xmin,xmax,ymin,ymax] + :return mask [points] + """ + assert len(bbox) == 4, 'Wrong bndbox!' + mask = [ + bbox[0], bbox[2], bbox[0], bbox[3], bbox[1], bbox[3], bbox[1], + bbox[2] + ] + return [mask] + + def _bbox_area_computer(self, bbox): + """ + Area computer + """ + width = bbox[1] - bbox[0] + height = bbox[3] - bbox[2] + return width * height + + def _save_json_file(self, filename=None, data=None): + """ + Save result in json + :param filename (str) : name of json file + param data : coco format data + :return + """ + json_path = os.path.join(self.data_path, 'cocoformatJson') + assert filename is not None, 'lack filename' + if os.path.exists(json_path) == False: + os.mkdir(json_path) + if not filename.endswith('.json'): + filename += '.json' + assert type(data) == type( + dict()), 'data format {} not supported'.format(type(data)) + with open(os.path.join(json_path, filename), 'w') as f: + f.write(json.dumps(data)) + + def _get_categories_to_ids_map(self): + """ + Generate categories to ids map + """ + return dict(zip(self.classes, xrange(self.num_classes))) + + def _get_all_indexs(self): + """ + Get all images and annotations indexs + :param + :return ids (str array) + """ + ids = [] + for root, dirs, files in os.walk(self.annotaions_path, topdown=False): + for f in files: + if str(f).endswith('.xml'): + id = int(str(f).strip('.xml')) + ids.append(id) + assert ids is not None, 'There is none xml file in {}'.format( + self.annotaions_path) + return ids + + def _get_indexs_by_image_set(self, image_set=None): + """ + Get images and nnotations indexs in image_set + """ + if image_set is None: + return self._get_all_indexs() + else: + image_set_path = os.path.join(self.image_set_path, 'Main', + image_set + '.txt') + assert os.path.exists( + image_set_path), 'Path does not exist: {}'.format( + image_set_path) + with open(image_set_path) as f: + ids = [x.strip() for x in f.readlines()] + return ids + + def _points_to_mbr(self, points): + """ + Transfer points to min bounding rectangle + :param: points (a list of lists) + :return: [x,y,width,height] + """ + assert _isArrayLike(points), 'Points should be array like!' + x = [point[0] for point in points] + y = [point[1] for point in points] + assert len(x) == len(y), 'Wrong point quantity' + xmin, xmax, ymin, ymax = min(x), max(x), min(y), max(y) + height = ymax - ymin + width = xmax - xmin + return [xmin, ymin, width, height] + + def _categories_msg_generator(self): + categories_msg = [] + for category in self.classes: + if category == '__background__': + continue + one_categories_msg = { + "supercategory": "none", + "id": self.categories_to_ids_map[category], + "name": category + } + categories_msg.append(one_categories_msg) + return categories_msg + + def _area_computer(self, points): + """ + :param: one shape's points (int array array) + :return: shape's area + """ + assert _isArrayLike(points), 'Points should be array like!' + tmp_contour = [] + for point in points: + tmp_contour.append([point]) + contour = np.array(tmp_contour, dtype=np.int32) + area = cv2.contourArea(contour) + return area + + def voc_to_coco_converter(self): + """ + Convert voc dataset to coco dataset + """ + img_sets = ['trainval', 'test'] + + for img_set in img_sets: + ids = self._get_indexs_by_image_set(img_set) + img_msg, ann_msg = self._load_annotation(ids) + result_json = { + "images": img_msg, + "type": "instances", + "annotations": ann_msg, + "categories": self.categories_msg + } + self._save_json_file('voc_' + self.year + '_' + img_set, + result_json) + + +if __name__ == "__main__": + if len(sys.argv) <= 1: + print('2 arguments are needed') + print('Usage: python {0} $VOCdevkitPATH $year'.format(sys.argv[0])) + exit(1) + + devkit_path = sys.argv[1] + year = sys.argv[2] + + converter = voc2coco(devkit_path, year) + converter.voc_to_coco_converter() \ No newline at end of file From b140a02a87124df7e0d151048148dbd4e0e78f05 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Fri, 25 May 2018 01:04:23 +0530 Subject: [PATCH 36/52] updated converter file --- tools/pascal_voc_xml2coco_json.py | 154 -------------------- tools/pascal_voc_xml2coco_json_converter.py | 10 +- 2 files changed, 1 insertion(+), 163 deletions(-) delete mode 100644 tools/pascal_voc_xml2coco_json.py diff --git a/tools/pascal_voc_xml2coco_json.py b/tools/pascal_voc_xml2coco_json.py deleted file mode 100644 index 22044fd8..00000000 --- a/tools/pascal_voc_xml2coco_json.py +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/python - -# pip install lxml - -import sys -import os -import shutil -import json -import xml.etree.ElementTree as ET - -START_BOUNDING_BOX_ID = 1 -PRE_DEFINE_CATEGORIES = {} - -# If necessary, pre-define category and its id -# PRE_DEFINE_CATEGORIES = {"aeroplane": 1, "bicycle": 2, "bird": 3, "boat": 4, -# "bottle":5, "bus": 6, "car": 7, "cat": 8, "chair": 9, -# "cow": 10, "diningtable": 11, "dog": 12, "horse": 13, -# "motorbike": 14, "person": 15, "pottedplant": 16, -# "sheep": 17, "sofa": 18, "train": 19, "tvmonitor": 20} - - -def get(root, name): - vars = root.findall(name) - return vars - - -def get_and_check(root, name, length): - vars = root.findall(name) - if len(vars) == 0: - raise NotImplementedError('Can not find %s in %s.' % (name, root.tag)) - if length > 0 and len(vars) != length: - raise NotImplementedError( - 'The size of %s is supposed to be %d, but is %d.' % (name, length, - len(vars))) - if length == 1: - vars = vars[0] - return vars - - -def get_filename_as_int(filename): - try: - filename = os.path.splitext(filename)[0] - return int(filename) - except: - raise NotImplementedError('Filename %s is supposed to be an integer.' % - (filename)) - - -def convert(xml_list, xml_dir, json_file): - list_fp = open(xml_list, 'r') - json_dict = { - "images": [], - "type": "instances", - "annotations": [], - "categories": [] - } - categories = PRE_DEFINE_CATEGORIES - bnd_id = START_BOUNDING_BOX_ID - for line in list_fp: - line = line.strip().split(' ')[0].strip() + '.xml' - print("Processing {0}" .format(line), end='\r') - xml_f = os.path.join(xml_dir, line) - tree = ET.parse(xml_f) - root = tree.getroot() - path = get(root, 'path') - if len(path) == 1: - filename = os.path.basename(path[0].text) - elif len(path) == 0: - filename = get_and_check(root, 'filename', 1).text - else: - raise NotImplementedError('%d paths found in %s' % (len(path), - line)) - ## The filename must be a number - image_id = get_filename_as_int(filename) - size = get_and_check(root, 'size', 1) - width = int(get_and_check(size, 'width', 1).text) - height = int(get_and_check(size, 'height', 1).text) - image = { - 'file_name': filename, - 'height': height, - 'width': width, - 'id': image_id - } - json_dict['images'].append(image) - ## Cruuently we do not support segmentation - # segmented = get_and_check(root, 'segmented', 1).text - # assert segmented == '0' - for obj in get(root, 'object'): - category = get_and_check(obj, 'name', 1).text - if category not in categories: - new_id = len(categories) - categories[category] = new_id - category_id = categories[category] - bndbox = get_and_check(obj, 'bndbox', 1) - xmin = int(get_and_check(bndbox, 'xmin', 1).text) - 1 - ymin = int(get_and_check(bndbox, 'ymin', 1).text) - 1 - xmax = int(get_and_check(bndbox, 'xmax', 1).text) - ymax = int(get_and_check(bndbox, 'ymax', 1).text) - assert (xmax > xmin) - assert (ymax > ymin) - o_width = abs(xmax - xmin) - o_height = abs(ymax - ymin) - ann = { - 'area': o_width * o_height, - 'iscrowd': 0, - 'image_id': image_id, - 'bbox': [xmin, ymin, o_width, o_height], - 'category_id': category_id, - 'id': bnd_id, - 'ignore': 0, - 'segmentation': [] - } - json_dict['annotations'].append(ann) - bnd_id = bnd_id + 1 - - for cate, cid in categories.items(): - cat = {'supercategory': 'none', 'id': cid, 'name': cate} - json_dict['categories'].append(cat) - json_fp = open(json_file, 'w') - json_str = json.dumps(json_dict) - json_fp.write(json_str) - json_fp.close() - list_fp.close() - - -if __name__ == '__main__': - if len(sys.argv) <= 1: - print('3 auguments are needed.') - print('Usage: python {0} ImageSets_DIR XML_DIR OUTPUT_DIR'.format( - sys.argv[0])) - exit(1) - - imagesets_dir = sys.argv[1] - xml_dir = sys.argv[2] - output_dir = sys.argv[3] - - if not os.path.exists(imagesets_dir) and not os.path.exists(xml_dir): - print('PATH not correct, please enter correct path: {0}, {1}'.format( - imagesets_dir, xml_dir)) - raise ValueError('Incorrect PATH provided') - - if os.path.exists(output_dir): - shutil.rmtree(output_dir) - os.makedirs(output_dir) - - for f in os.listdir(imagesets_dir): - if not f.endswith('.txt'): - continue - - print('==> Processing file {0}'.format(f)) - imagesets_file = os.path.join(imagesets_dir, f) - json_file = f.split('.')[0] + '.json' - output_file = os.path.join(output_dir, json_file) - convert(imagesets_file, xml_dir, output_file) diff --git a/tools/pascal_voc_xml2coco_json_converter.py b/tools/pascal_voc_xml2coco_json_converter.py index 51fb0167..5c1c4fe0 100644 --- a/tools/pascal_voc_xml2coco_json_converter.py +++ b/tools/pascal_voc_xml2coco_json_converter.py @@ -1,11 +1,3 @@ -# -*- coding: utf-8 -*- -""" -Created on Thu Mar 08 16:01:57 2018 - -Convert VOC dataset into COCO dataset - -@author: wkoa -""" import os import sys import json @@ -193,7 +185,7 @@ def _get_categories_to_ids_map(self): """ Generate categories to ids map """ - return dict(zip(self.classes, xrange(self.num_classes))) + return dict(zip(self.classes, range(self.num_classes))) def _get_all_indexs(self): """ From a0ad2d22bde6bed0424c0bdd61487aa6593d8939 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Fri, 25 May 2018 01:16:51 +0530 Subject: [PATCH 37/52] formatting --- tools/pascal_voc_xml2coco_json_converter.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tools/pascal_voc_xml2coco_json_converter.py b/tools/pascal_voc_xml2coco_json_converter.py index 5c1c4fe0..dbce7e24 100644 --- a/tools/pascal_voc_xml2coco_json_converter.py +++ b/tools/pascal_voc_xml2coco_json_converter.py @@ -115,21 +115,14 @@ def _load_annotation(self, ids=[]): ymin = 0 bbox = [xmin, xmax, ymin, ymax] one_ann_msg = { - "segmentation": - self._bbox_to_mask(bbox), - "area": - self._bbox_area_computer(bbox), - "iscrowd": - 0, - "image_id": - int(index), + "segmentation": self._bbox_to_mask(bbox), + "area": self._bbox_area_computer(bbox), + "iscrowd": 0, + "image_id": int(index), "bbox": [xmin, ymin, xmax - xmin, ymax - ymin], - "category_id": - self.categories_to_ids_map[obj.find('name').text], - "id": - annotation_id, - "ignore": - 0 + "category_id": self.categories_to_ids_map[obj.find('name').text], + "id": annotation_id, + "ignore": 0 } annotation_msg.append(one_ann_msg) annotation_id += 1 From 8c9e9460a8d2c3ba80da7d5a14a56750c317fc58 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Fri, 25 May 2018 01:26:19 +0530 Subject: [PATCH 38/52] Update README.md --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 24063ff7..21051f61 100644 --- a/README.md +++ b/README.md @@ -151,9 +151,12 @@ mkdir data ``` **NOTE:** The `annotations` folder requires you to have PASCAL VOC annotations in COCO json format, which is available for download [here](https://storage.googleapis.com/coco-dataset/external/PASCAL_VOC.zip). You can also convert the XML annotatinos files to JSON by running the following script, ``` - python tools/pascal_voc_xml2json.py + python tools/pascal_voc_xml2coco_json_converter.py $VOCdevkitPATH $year ``` (In order to succesfully run the script above, you need to update the full path to the respective folders in the script). + +- **Custom Dataset** + Similar to above, create a directory named `CustomDataset` in the `data` folder and add symlinks to the `annotations` directory and `JPEGImages` as shown for Pascal Voc dataset. Recommend to put the images on a SSD for possible better training performance @@ -231,7 +234,7 @@ Specify `—-use_tfboard` to log the losses on Tensorboard. - use `--dataset keypoints_coco2017` when training for keypoint-rcnn. - use `--dataset voc2007` when training for PASCAL VOC 2007. - use `--dataset voc2012` when training for PASCAL VOC 2012. - - use `--dataset custom_dataset --num_classes $NUM_CLASSES` when training for your custom dataset. Here, `$NUM_CLASSES` is the number of object classes + 1 (for background class) present in your custom dataset. + - use `--dataset custom_dataset --num_classes $NUM_CLASSES` when training for your custom dataset. Here, `$NUM_CLASSES` is the number of object classes **+ 1** (for background class) present in your custom dataset. ### The use of `--iter_size` As in Caffe, update network once (`optimizer.step()`) every `iter_size` iterations (forward + backward). This way to have a larger effective batch size for training. Notice that, step count is only increased after network update. From fc9823cb81d463f28ba12a6824ebc103f4160f6a Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Sun, 27 May 2018 11:26:14 +0530 Subject: [PATCH 39/52] fix voc testing code --- lib/datasets/dataset_catalog.py | 20 +++++++++++++++++--- lib/datasets/voc_eval.py | 4 ++-- tools/pascal_voc_xml2coco_json_converter.py | 4 ++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index 1aba825f..5ec6749e 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -197,48 +197,62 @@ IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/train.json' + _DATA_DIR + '/VOC2007/annotations/voc_2007_train.json' }, 'voc_2007_trainval': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/trainval.json' + _DATA_DIR + '/VOC2007/annotations/voc_2007_trainval.json' + DEVKIT_DIR: + _DATA_DIR + '/VOC2007' }, 'voc_2007_test': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/test.json' + _DATA_DIR + '/VOC2007/annotations/voc_2007_test.json' + DEVKIT_DIR: + _DATA_DIR + '/VOC2007' }, 'voc_2012_train': { IM_DIR: _DATA_DIR + '/VOC2012/JPEGImages', ANN_FN: _DATA_DIR + '/VOC2012/annotations/train.json' + DEVKIT_DIR: + _DATA_DIR + '/VOC2007' }, 'voc_2012_trainval': { IM_DIR: _DATA_DIR + '/VOC2012/JPEGImages', ANN_FN: _DATA_DIR + '/VOC2012/annotations/trainval.json' + DEVKIT_DIR: + _DATA_DIR + '/VOC2007' }, 'custom_data_train': { IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: _DATA_DIR + '/CustomData/annotations/train.json' + DEVKIT_DIR: + _DATA_DIR + '/CustomData' }, 'custom_data_trainval': { IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: _DATA_DIR + '/CustomData/annotations/trainval.json' + DEVKIT_DIR: + _DATA_DIR + '/CustomData' }, 'custom_data_test': { IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: _DATA_DIR + '/CustomData/annotations/test.json' + DEVKIT_DIR: + _DATA_DIR + "/CustomData' } } diff --git a/lib/datasets/voc_eval.py b/lib/datasets/voc_eval.py index 2b3a8c04..0f775d23 100644 --- a/lib/datasets/voc_eval.py +++ b/lib/datasets/voc_eval.py @@ -136,11 +136,11 @@ def voc_eval(detpath, i + 1, len(imagenames))) # save logger.info('Saving cached annotations to {:s}'.format(cachefile)) - with open(cachefile, 'w') as f: + with open(cachefile, 'wb') as f: cPickle.dump(recs, f) else: # load - with open(cachefile, 'r') as f: + with open(cachefile, 'rb') as f: recs = cPickle.load(f) # extract gt objects for this class diff --git a/tools/pascal_voc_xml2coco_json_converter.py b/tools/pascal_voc_xml2coco_json_converter.py index dbce7e24..2e59a1cb 100644 --- a/tools/pascal_voc_xml2coco_json_converter.py +++ b/tools/pascal_voc_xml2coco_json_converter.py @@ -257,7 +257,7 @@ def voc_to_coco_converter(self): """ Convert voc dataset to coco dataset """ - img_sets = ['trainval', 'test'] + img_sets = ['train', 'val', 'trainval', 'test'] for img_set in img_sets: ids = self._get_indexs_by_image_set(img_set) @@ -282,4 +282,4 @@ def voc_to_coco_converter(self): year = sys.argv[2] converter = voc2coco(devkit_path, year) - converter.voc_to_coco_converter() \ No newline at end of file + converter.voc_to_coco_converter() From 95dc2a57a24eeae3dd0bf2434d1397996b6c9446 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Sun, 27 May 2018 11:31:10 +0530 Subject: [PATCH 40/52] minor fix --- lib/datasets/dataset_catalog.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index 5ec6749e..d0f426bc 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -197,13 +197,15 @@ IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/voc_2007_train.json' + _DATA_DIR + '/VOC2007/annotations/voc_2007_train.json', + DEVKIT_DIR: + _DATA_DIR + '/VOC2007' }, 'voc_2007_trainval': { IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/voc_2007_trainval.json' + _DATA_DIR + '/VOC2007/annotations/voc_2007_trainval.json', DEVKIT_DIR: _DATA_DIR + '/VOC2007' }, @@ -211,7 +213,7 @@ IM_DIR: _DATA_DIR + '/VOC2007/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2007/annotations/voc_2007_test.json' + _DATA_DIR + '/VOC2007/annotations/voc_2007_test.json', DEVKIT_DIR: _DATA_DIR + '/VOC2007' }, @@ -219,23 +221,23 @@ IM_DIR: _DATA_DIR + '/VOC2012/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2012/annotations/train.json' + _DATA_DIR + '/VOC2012/annotations/train.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2007' + _DATA_DIR + '/VOC2012' }, 'voc_2012_trainval': { IM_DIR: _DATA_DIR + '/VOC2012/JPEGImages', ANN_FN: - _DATA_DIR + '/VOC2012/annotations/trainval.json' + _DATA_DIR + '/VOC2012/annotations/trainval.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2007' + _DATA_DIR + '/VOC2012' }, 'custom_data_train': { IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: - _DATA_DIR + '/CustomData/annotations/train.json' + _DATA_DIR + '/CustomData/annotations/train.json', DEVKIT_DIR: _DATA_DIR + '/CustomData' }, @@ -243,7 +245,7 @@ IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: - _DATA_DIR + '/CustomData/annotations/trainval.json' + _DATA_DIR + '/CustomData/annotations/trainval.json', DEVKIT_DIR: _DATA_DIR + '/CustomData' }, @@ -251,8 +253,8 @@ IM_DIR: _DATA_DIR + '/CustomData/JPEGImages', ANN_FN: - _DATA_DIR + '/CustomData/annotations/test.json' + _DATA_DIR + '/CustomData/annotations/test.json', DEVKIT_DIR: - _DATA_DIR + "/CustomData' + _DATA_DIR + '/CustomData' } } From 06e2c31e661e7e59402a28cc4d0c1ce1f83fad04 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Sun, 27 May 2018 11:59:48 +0530 Subject: [PATCH 41/52] minor fix --- lib/datasets/dataset_catalog.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/datasets/dataset_catalog.py b/lib/datasets/dataset_catalog.py index d0f426bc..0a3986e2 100644 --- a/lib/datasets/dataset_catalog.py +++ b/lib/datasets/dataset_catalog.py @@ -199,7 +199,7 @@ ANN_FN: _DATA_DIR + '/VOC2007/annotations/voc_2007_train.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2007' + _DATA_DIR + '/VOC2007/VOCdevkit2007' }, 'voc_2007_trainval': { IM_DIR: @@ -207,7 +207,7 @@ ANN_FN: _DATA_DIR + '/VOC2007/annotations/voc_2007_trainval.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2007' + _DATA_DIR + '/VOC2007/VOCdevkit2007' }, 'voc_2007_test': { IM_DIR: @@ -215,7 +215,7 @@ ANN_FN: _DATA_DIR + '/VOC2007/annotations/voc_2007_test.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2007' + _DATA_DIR + '/VOC2007/VOCdevkit2007' }, 'voc_2012_train': { IM_DIR: @@ -223,7 +223,7 @@ ANN_FN: _DATA_DIR + '/VOC2012/annotations/train.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2012' + _DATA_DIR + '/VOC2012/VOCdevkit2012' }, 'voc_2012_trainval': { IM_DIR: @@ -231,7 +231,7 @@ ANN_FN: _DATA_DIR + '/VOC2012/annotations/trainval.json', DEVKIT_DIR: - _DATA_DIR + '/VOC2012' + _DATA_DIR + '/VOC2012/VOCdevkit2012' }, 'custom_data_train': { IM_DIR: @@ -239,7 +239,7 @@ ANN_FN: _DATA_DIR + '/CustomData/annotations/train.json', DEVKIT_DIR: - _DATA_DIR + '/CustomData' + _DATA_DIR + '/CustomData/CustomDataDevkit' }, 'custom_data_trainval': { IM_DIR: @@ -247,7 +247,7 @@ ANN_FN: _DATA_DIR + '/CustomData/annotations/trainval.json', DEVKIT_DIR: - _DATA_DIR + '/CustomData' + _DATA_DIR + '/CustomData/CustomDataDevkit' }, 'custom_data_test': { IM_DIR: @@ -255,6 +255,6 @@ ANN_FN: _DATA_DIR + '/CustomData/annotations/test.json', DEVKIT_DIR: - _DATA_DIR + '/CustomData' + _DATA_DIR + '/CustomData/CustomDataDevkit' } } From 62868a8422e4efc7fe8e379f3be4be42acdc9703 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Sun, 27 May 2018 12:17:09 +0530 Subject: [PATCH 42/52] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 21051f61..eda4796d 100644 --- a/README.md +++ b/README.md @@ -131,9 +131,11 @@ mkdir data - **PASCAL VOC 2007 + 12** Please follow the instructions in [py-faster-rcnn](https://github.com/rbgirshick/py-faster-rcnn#beyond-the-demo-installation-for-training-and-testing-models) to prepare VOC datasets. Actually, you can refer to any others. After downloading the data, creat softlinks in the `data/VOC` folder as folows, ``` + VOCdevkitPATH=/path/to/voc_devkit mkdir -p $DETECTRON/detectron/datasets/data/VOC - ln -s /path/to/VOC/JPEGImages $DETECTRON.PYTORCH/data/VOC/JPEGImages - ln -s /path/to/VOC/json/annotations $DETECTRON.PYTORCH/data/VOC/annotations + ln -s /${VOCdevkitPATH}/VOC/JPEGImages $DETECTRON.PYTORCH/data/VOC/JPEGImages + ln -s /${VOCdevkitPATH}/VOC/json_annotations $DETECTRON.PYTORCH/data/VOC/annotations + ln -s /${VOCdevkitPATH} $DETECTRON.PYTORCH/data/VOC/VOCdevkit ``` The directory structure of `JPEGImages` and `annotations` should be as follows, ``` @@ -156,7 +158,7 @@ mkdir data (In order to succesfully run the script above, you need to update the full path to the respective folders in the script). - **Custom Dataset** - Similar to above, create a directory named `CustomDataset` in the `data` folder and add symlinks to the `annotations` directory and `JPEGImages` as shown for Pascal Voc dataset. + Similar to above, create a directory named `CustomDataset` in the `data` folder and add symlinks to the `annotations` directory and `JPEGImages` as shown for Pascal Voc dataset. You also need to link the custom dataset devkit to `CustomDataDevkit`. Recommend to put the images on a SSD for possible better training performance From eab1bb51c323a1e15b6b286bf9070f06eb00a7e3 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Wed, 14 Nov 2018 19:36:25 +0530 Subject: [PATCH 43/52] Fixed bug for 1 indexed VOC format --- tools/pascal_voc_xml2coco_json_converter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/pascal_voc_xml2coco_json_converter.py b/tools/pascal_voc_xml2coco_json_converter.py index 2e59a1cb..924b138c 100644 --- a/tools/pascal_voc_xml2coco_json_converter.py +++ b/tools/pascal_voc_xml2coco_json_converter.py @@ -105,9 +105,9 @@ def _load_annotation(self, ids=[]): bndbox = obj.find('bndbox') [xmin, xmax, ymin, ymax] = [ int(bndbox.find('xmin').text) - 1, - int(bndbox.find('xmax').text), + int(bndbox.find('xmax').text) - 1, int(bndbox.find('ymin').text) - 1, - int(bndbox.find('ymax').text) + int(bndbox.find('ymax').text) -1 ] if xmin < 0: xmin = 0 From 47a0597e61ecdcda404c0acee78fbe21cb478848 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Wed, 16 Jan 2019 22:15:26 +0530 Subject: [PATCH 44/52] first attempt at migrating to Pytorch-1.0 --- .gitignore | 2 + lib/make.sh | 96 +- lib/model/csrc/ROIAlign.h | 46 + lib/model/csrc/ROIPool.h | 48 + lib/model/csrc/cpu/ROIAlign_cpu.cpp | 257 + lib/model/csrc/cpu/nms_cpu.cpp | 75 + lib/model/csrc/cpu/vision.h | 16 + lib/model/csrc/cuda/ROIAlign_cuda.cu | 346 ++ lib/model/csrc/cuda/ROIPool_cuda.cu | 202 + .../{nms/nms_kernel.cu => csrc/cuda/nms.cu} | 85 +- lib/model/csrc/cuda/vision.h | 48 + lib/model/csrc/nms.h | 28 + lib/model/csrc/vision.cpp | 13 + lib/model/nms/.gitignore | 3 - lib/model/nms/__init__.py | 0 lib/model/nms/_ext/__init__.py | 0 lib/model/nms/_ext/nms/__init__.py | 15 - lib/model/nms/build.py | 37 - lib/model/nms/make.sh | 10 - lib/model/nms/nms_gpu.py | 12 - lib/model/nms/nms_wrapper.py | 18 - lib/model/nms/src/nms_cuda.c | 19 - lib/model/nms/src/nms_cuda.h | 5 - lib/model/nms/src/nms_cuda_kernel.cu | 161 - lib/model/nms/src/nms_cuda_kernel.h | 10 - lib/model/roi_align/__init__.py | 0 lib/model/roi_align/_ext/__init__.py | 0 .../roi_align/_ext/roi_align/__init__.py | 15 - lib/model/roi_align/build.py | 36 - lib/model/roi_align/functions/__init__.py | 0 lib/model/roi_align/functions/roi_align.py | 47 - lib/model/roi_align/make.sh | 10 - lib/model/roi_align/modules/__init__.py | 0 lib/model/roi_align/modules/roi_align.py | 42 - lib/model/roi_align/src/roi_align_cuda.c | 76 - lib/model/roi_align/src/roi_align_cuda.h | 5 - lib/model/roi_align/src/roi_align_kernel.cu | 167 - lib/model/roi_align/src/roi_align_kernel.h | 34 - lib/model/roi_crop/__init__.py | 0 lib/model/roi_crop/_ext/__init__.py | 0 .../roi_crop/_ext/crop_resize/__init__.py | 12 - .../roi_crop/_ext/crop_resize/_crop_resize.so | Bin 159103 -> 0 bytes lib/model/roi_crop/_ext/roi_crop/__init__.py | 15 - lib/model/roi_crop/build.py | 36 - lib/model/roi_crop/functions/__init__.py | 0 lib/model/roi_crop/functions/crop_resize.py | 37 - lib/model/roi_crop/functions/gridgen.py | 46 - lib/model/roi_crop/functions/roi_crop.py | 21 - lib/model/roi_crop/make.sh | 10 - lib/model/roi_crop/modules/__init__.py | 0 lib/model/roi_crop/modules/gridgen.py | 415 -- lib/model/roi_crop/modules/roi_crop.py | 8 - lib/model/roi_crop/src/roi_crop.c | 499 -- lib/model/roi_crop/src/roi_crop.h | 11 - lib/model/roi_crop/src/roi_crop_cuda.c | 105 - lib/model/roi_crop/src/roi_crop_cuda.h | 8 - .../roi_crop/src/roi_crop_cuda_kernel.cu | 330 -- lib/model/roi_crop/src/roi_crop_cuda_kernel.h | 37 - lib/model/roi_layers/__init__.py | 9 + lib/model/roi_layers/nms.py | 8 + lib/model/roi_layers/roi_align.py | 67 + lib/model/roi_layers/roi_pool.py | 62 + lib/model/roi_pooling/__init__.py | 0 lib/model/roi_pooling/_ext/__init__.py | 0 .../roi_pooling/_ext/roi_pooling/__init__.py | 15 - lib/model/roi_pooling/build.py | 35 - lib/model/roi_pooling/functions/__init__.py | 0 lib/model/roi_pooling/functions/roi_pool.py | 38 - lib/model/roi_pooling/modules/__init__.py | 0 lib/model/roi_pooling/modules/roi_pool.py | 14 - lib/model/roi_pooling/src/roi_pooling.c | 104 - lib/model/roi_pooling/src/roi_pooling.h | 2 - lib/model/roi_pooling/src/roi_pooling_cuda.c | 88 - lib/model/roi_pooling/src/roi_pooling_cuda.h | 5 - .../roi_pooling/src/roi_pooling_kernel.cu | 239 - .../roi_pooling/src/roi_pooling_kernel.h | 25 - lib/modeling/model_builder.py | 35 +- lib/{setup.py => setup_bbox.py} | 0 lib/setup_layers.py | 67 + lib/utils/cython_bbox.c | 3468 +++++++----- lib/utils/cython_nms.c | 4980 +++++++++-------- lib/utils/logging.py | 1 - lib/utils/training_stats.py | 9 +- 83 files changed, 6231 insertions(+), 6614 deletions(-) create mode 100644 lib/model/csrc/ROIAlign.h create mode 100644 lib/model/csrc/ROIPool.h create mode 100644 lib/model/csrc/cpu/ROIAlign_cpu.cpp create mode 100644 lib/model/csrc/cpu/nms_cpu.cpp create mode 100644 lib/model/csrc/cpu/vision.h create mode 100644 lib/model/csrc/cuda/ROIAlign_cuda.cu create mode 100644 lib/model/csrc/cuda/ROIPool_cuda.cu rename lib/model/{nms/nms_kernel.cu => csrc/cuda/nms.cu} (62%) create mode 100644 lib/model/csrc/cuda/vision.h create mode 100644 lib/model/csrc/nms.h create mode 100644 lib/model/csrc/vision.cpp delete mode 100644 lib/model/nms/.gitignore delete mode 100644 lib/model/nms/__init__.py delete mode 100644 lib/model/nms/_ext/__init__.py delete mode 100644 lib/model/nms/_ext/nms/__init__.py delete mode 100644 lib/model/nms/build.py delete mode 100644 lib/model/nms/make.sh delete mode 100644 lib/model/nms/nms_gpu.py delete mode 100644 lib/model/nms/nms_wrapper.py delete mode 100644 lib/model/nms/src/nms_cuda.c delete mode 100644 lib/model/nms/src/nms_cuda.h delete mode 100644 lib/model/nms/src/nms_cuda_kernel.cu delete mode 100644 lib/model/nms/src/nms_cuda_kernel.h delete mode 100644 lib/model/roi_align/__init__.py delete mode 100644 lib/model/roi_align/_ext/__init__.py delete mode 100644 lib/model/roi_align/_ext/roi_align/__init__.py delete mode 100644 lib/model/roi_align/build.py delete mode 100644 lib/model/roi_align/functions/__init__.py delete mode 100644 lib/model/roi_align/functions/roi_align.py delete mode 100755 lib/model/roi_align/make.sh delete mode 100644 lib/model/roi_align/modules/__init__.py delete mode 100644 lib/model/roi_align/modules/roi_align.py delete mode 100644 lib/model/roi_align/src/roi_align_cuda.c delete mode 100644 lib/model/roi_align/src/roi_align_cuda.h delete mode 100644 lib/model/roi_align/src/roi_align_kernel.cu delete mode 100644 lib/model/roi_align/src/roi_align_kernel.h delete mode 100644 lib/model/roi_crop/__init__.py delete mode 100644 lib/model/roi_crop/_ext/__init__.py delete mode 100644 lib/model/roi_crop/_ext/crop_resize/__init__.py delete mode 100755 lib/model/roi_crop/_ext/crop_resize/_crop_resize.so delete mode 100644 lib/model/roi_crop/_ext/roi_crop/__init__.py delete mode 100644 lib/model/roi_crop/build.py delete mode 100644 lib/model/roi_crop/functions/__init__.py delete mode 100644 lib/model/roi_crop/functions/crop_resize.py delete mode 100644 lib/model/roi_crop/functions/gridgen.py delete mode 100644 lib/model/roi_crop/functions/roi_crop.py delete mode 100755 lib/model/roi_crop/make.sh delete mode 100644 lib/model/roi_crop/modules/__init__.py delete mode 100644 lib/model/roi_crop/modules/gridgen.py delete mode 100644 lib/model/roi_crop/modules/roi_crop.py delete mode 100644 lib/model/roi_crop/src/roi_crop.c delete mode 100644 lib/model/roi_crop/src/roi_crop.h delete mode 100644 lib/model/roi_crop/src/roi_crop_cuda.c delete mode 100644 lib/model/roi_crop/src/roi_crop_cuda.h delete mode 100644 lib/model/roi_crop/src/roi_crop_cuda_kernel.cu delete mode 100644 lib/model/roi_crop/src/roi_crop_cuda_kernel.h create mode 100644 lib/model/roi_layers/__init__.py create mode 100644 lib/model/roi_layers/nms.py create mode 100644 lib/model/roi_layers/roi_align.py create mode 100644 lib/model/roi_layers/roi_pool.py delete mode 100644 lib/model/roi_pooling/__init__.py delete mode 100644 lib/model/roi_pooling/_ext/__init__.py delete mode 100644 lib/model/roi_pooling/_ext/roi_pooling/__init__.py delete mode 100644 lib/model/roi_pooling/build.py delete mode 100644 lib/model/roi_pooling/functions/__init__.py delete mode 100644 lib/model/roi_pooling/functions/roi_pool.py delete mode 100644 lib/model/roi_pooling/modules/__init__.py delete mode 100644 lib/model/roi_pooling/modules/roi_pool.py delete mode 100644 lib/model/roi_pooling/src/roi_pooling.c delete mode 100644 lib/model/roi_pooling/src/roi_pooling.h delete mode 100644 lib/model/roi_pooling/src/roi_pooling_cuda.c delete mode 100644 lib/model/roi_pooling/src/roi_pooling_cuda.h delete mode 100644 lib/model/roi_pooling/src/roi_pooling_kernel.cu delete mode 100644 lib/model/roi_pooling/src/roi_pooling_kernel.h rename lib/{setup.py => setup_bbox.py} (100%) create mode 100644 lib/setup_layers.py diff --git a/.gitignore b/.gitignore index 8a6ea232..ac1bfde2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ data/* notebooks/*.pkl /Outputs +lib/build +lib/faster_rcnn.egg-info # ------------------------------ diff --git a/lib/make.sh b/lib/make.sh index 8470621a..15ee1c38 100755 --- a/lib/make.sh +++ b/lib/make.sh @@ -1,60 +1,60 @@ #!/usr/bin/env bash -CUDA_PATH=/usr/local/cuda/ +# CUDA_PATH=/usr/local/cuda/ python setup.py build_ext --inplace rm -rf build -# Choose cuda arch as you need -CUDA_ARCH="-gencode arch=compute_30,code=sm_30 \ - -gencode arch=compute_35,code=sm_35 \ - -gencode arch=compute_50,code=sm_50 \ - -gencode arch=compute_52,code=sm_52 \ - -gencode arch=compute_60,code=sm_60 \ - -gencode arch=compute_61,code=sm_61 " -# -gencode arch=compute_70,code=sm_70 " - -# compile NMS -cd model/nms/src -echo "Compiling nms kernels by nvcc..." -nvcc -c -o nms_cuda_kernel.cu.o nms_cuda_kernel.cu \ - -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH - -cd ../ -python build.py - -# compile roi_pooling -cd ../../ -cd model/roi_pooling/src -echo "Compiling roi pooling kernels by nvcc..." -nvcc -c -o roi_pooling.cu.o roi_pooling_kernel.cu \ - -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH -cd ../ -python build.py - -# # compile roi_align +# # Choose cuda arch as you need +# CUDA_ARCH="-gencode arch=compute_30,code=sm_30 \ +# -gencode arch=compute_35,code=sm_35 \ +# -gencode arch=compute_50,code=sm_50 \ +# -gencode arch=compute_52,code=sm_52 \ +# -gencode arch=compute_60,code=sm_60 \ +# -gencode arch=compute_61,code=sm_61 " +# # -gencode arch=compute_70,code=sm_70 " + +# # compile NMS +# cd model/nms/src +# echo "Compiling nms kernels by nvcc..." +# nvcc -c -o nms_cuda_kernel.cu.o nms_cuda_kernel.cu \ +# -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH + +# cd ../ +# python build.py + +# # compile roi_pooling # cd ../../ -# cd model/roi_align/src +# cd model/roi_pooling/src +# echo "Compiling roi pooling kernels by nvcc..." +# nvcc -c -o roi_pooling.cu.o roi_pooling_kernel.cu \ +# -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH +# cd ../ +# python build.py + +# # # compile roi_align +# # cd ../../ +# # cd model/roi_align/src +# # echo "Compiling roi align kernels by nvcc..." +# # nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu \ +# # -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH +# # cd ../ +# # python build.py + +# # compile roi_crop +# cd ../../ +# cd model/roi_crop/src +# echo "Compiling roi crop kernels by nvcc..." +# nvcc -c -o roi_crop_cuda_kernel.cu.o roi_crop_cuda_kernel.cu \ +# -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH +# cd ../ +# python build.py + +# # compile roi_align (based on Caffe2's implementation) +# cd ../../ +# cd modeling/roi_xfrom/roi_align/src # echo "Compiling roi align kernels by nvcc..." # nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu \ # -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH # cd ../ # python build.py - -# compile roi_crop -cd ../../ -cd model/roi_crop/src -echo "Compiling roi crop kernels by nvcc..." -nvcc -c -o roi_crop_cuda_kernel.cu.o roi_crop_cuda_kernel.cu \ - -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH -cd ../ -python build.py - -# compile roi_align (based on Caffe2's implementation) -cd ../../ -cd modeling/roi_xfrom/roi_align/src -echo "Compiling roi align kernels by nvcc..." -nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu \ - -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH -cd ../ -python build.py diff --git a/lib/model/csrc/ROIAlign.h b/lib/model/csrc/ROIAlign.h new file mode 100644 index 00000000..3907deab --- /dev/null +++ b/lib/model/csrc/ROIAlign.h @@ -0,0 +1,46 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#pragma once + +#include "cpu/vision.h" + +#ifdef WITH_CUDA +#include "cuda/vision.h" +#endif + +// Interface for Python +at::Tensor ROIAlign_forward(const at::Tensor& input, + const at::Tensor& rois, + const float spatial_scale, + const int pooled_height, + const int pooled_width, + const int sampling_ratio) { + if (input.type().is_cuda()) { +#ifdef WITH_CUDA + return ROIAlign_forward_cuda(input, rois, spatial_scale, pooled_height, pooled_width, sampling_ratio); +#else + AT_ERROR("Not compiled with GPU support"); +#endif + } + return ROIAlign_forward_cpu(input, rois, spatial_scale, pooled_height, pooled_width, sampling_ratio); +} + +at::Tensor ROIAlign_backward(const at::Tensor& grad, + const at::Tensor& rois, + const float spatial_scale, + const int pooled_height, + const int pooled_width, + const int batch_size, + const int channels, + const int height, + const int width, + const int sampling_ratio) { + if (grad.type().is_cuda()) { +#ifdef WITH_CUDA + return ROIAlign_backward_cuda(grad, rois, spatial_scale, pooled_height, pooled_width, batch_size, channels, height, width, sampling_ratio); +#else + AT_ERROR("Not compiled with GPU support"); +#endif + } + AT_ERROR("Not implemented on the CPU"); +} + diff --git a/lib/model/csrc/ROIPool.h b/lib/model/csrc/ROIPool.h new file mode 100644 index 00000000..200fd739 --- /dev/null +++ b/lib/model/csrc/ROIPool.h @@ -0,0 +1,48 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#pragma once + +#include "cpu/vision.h" + +#ifdef WITH_CUDA +#include "cuda/vision.h" +#endif + + +std::tuple ROIPool_forward(const at::Tensor& input, + const at::Tensor& rois, + const float spatial_scale, + const int pooled_height, + const int pooled_width) { + if (input.type().is_cuda()) { +#ifdef WITH_CUDA + return ROIPool_forward_cuda(input, rois, spatial_scale, pooled_height, pooled_width); +#else + AT_ERROR("Not compiled with GPU support"); +#endif + } + AT_ERROR("Not implemented on the CPU"); +} + +at::Tensor ROIPool_backward(const at::Tensor& grad, + const at::Tensor& input, + const at::Tensor& rois, + const at::Tensor& argmax, + const float spatial_scale, + const int pooled_height, + const int pooled_width, + const int batch_size, + const int channels, + const int height, + const int width) { + if (grad.type().is_cuda()) { +#ifdef WITH_CUDA + return ROIPool_backward_cuda(grad, input, rois, argmax, spatial_scale, pooled_height, pooled_width, batch_size, channels, height, width); +#else + AT_ERROR("Not compiled with GPU support"); +#endif + } + AT_ERROR("Not implemented on the CPU"); +} + + + diff --git a/lib/model/csrc/cpu/ROIAlign_cpu.cpp b/lib/model/csrc/cpu/ROIAlign_cpu.cpp new file mode 100644 index 00000000..d35aedf2 --- /dev/null +++ b/lib/model/csrc/cpu/ROIAlign_cpu.cpp @@ -0,0 +1,257 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#include "cpu/vision.h" + +// implementation taken from Caffe2 +template +struct PreCalc { + int pos1; + int pos2; + int pos3; + int pos4; + T w1; + T w2; + T w3; + T w4; +}; + +template +void pre_calc_for_bilinear_interpolate( + const int height, + const int width, + const int pooled_height, + const int pooled_width, + const int iy_upper, + const int ix_upper, + T roi_start_h, + T roi_start_w, + T bin_size_h, + T bin_size_w, + int roi_bin_grid_h, + int roi_bin_grid_w, + std::vector>& pre_calc) { + int pre_calc_index = 0; + for (int ph = 0; ph < pooled_height; ph++) { + for (int pw = 0; pw < pooled_width; pw++) { + for (int iy = 0; iy < iy_upper; iy++) { + const T yy = roi_start_h + ph * bin_size_h + + static_cast(iy + .5f) * bin_size_h / + static_cast(roi_bin_grid_h); // e.g., 0.5, 1.5 + for (int ix = 0; ix < ix_upper; ix++) { + const T xx = roi_start_w + pw * bin_size_w + + static_cast(ix + .5f) * bin_size_w / + static_cast(roi_bin_grid_w); + + T x = xx; + T y = yy; + // deal with: inverse elements are out of feature map boundary + if (y < -1.0 || y > height || x < -1.0 || x > width) { + // empty + PreCalc pc; + pc.pos1 = 0; + pc.pos2 = 0; + pc.pos3 = 0; + pc.pos4 = 0; + pc.w1 = 0; + pc.w2 = 0; + pc.w3 = 0; + pc.w4 = 0; + pre_calc[pre_calc_index] = pc; + pre_calc_index += 1; + continue; + } + + if (y <= 0) { + y = 0; + } + if (x <= 0) { + x = 0; + } + + int y_low = (int)y; + int x_low = (int)x; + int y_high; + int x_high; + + if (y_low >= height - 1) { + y_high = y_low = height - 1; + y = (T)y_low; + } else { + y_high = y_low + 1; + } + + if (x_low >= width - 1) { + x_high = x_low = width - 1; + x = (T)x_low; + } else { + x_high = x_low + 1; + } + + T ly = y - y_low; + T lx = x - x_low; + T hy = 1. - ly, hx = 1. - lx; + T w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; + + // save weights and indeces + PreCalc pc; + pc.pos1 = y_low * width + x_low; + pc.pos2 = y_low * width + x_high; + pc.pos3 = y_high * width + x_low; + pc.pos4 = y_high * width + x_high; + pc.w1 = w1; + pc.w2 = w2; + pc.w3 = w3; + pc.w4 = w4; + pre_calc[pre_calc_index] = pc; + + pre_calc_index += 1; + } + } + } + } +} + +template +void ROIAlignForward_cpu_kernel( + const int nthreads, + const T* bottom_data, + const T& spatial_scale, + const int channels, + const int height, + const int width, + const int pooled_height, + const int pooled_width, + const int sampling_ratio, + const T* bottom_rois, + //int roi_cols, + T* top_data) { + //AT_ASSERT(roi_cols == 4 || roi_cols == 5); + int roi_cols = 5; + + int n_rois = nthreads / channels / pooled_width / pooled_height; + // (n, c, ph, pw) is an element in the pooled output + // can be parallelized using omp + // #pragma omp parallel for num_threads(32) + for (int n = 0; n < n_rois; n++) { + int index_n = n * channels * pooled_width * pooled_height; + + // roi could have 4 or 5 columns + const T* offset_bottom_rois = bottom_rois + n * roi_cols; + int roi_batch_ind = 0; + if (roi_cols == 5) { + roi_batch_ind = offset_bottom_rois[0]; + offset_bottom_rois++; + } + + // Do not using rounding; this implementation detail is critical + T roi_start_w = offset_bottom_rois[0] * spatial_scale; + T roi_start_h = offset_bottom_rois[1] * spatial_scale; + T roi_end_w = offset_bottom_rois[2] * spatial_scale; + T roi_end_h = offset_bottom_rois[3] * spatial_scale; + // T roi_start_w = round(offset_bottom_rois[0] * spatial_scale); + // T roi_start_h = round(offset_bottom_rois[1] * spatial_scale); + // T roi_end_w = round(offset_bottom_rois[2] * spatial_scale); + // T roi_end_h = round(offset_bottom_rois[3] * spatial_scale); + + // Force malformed ROIs to be 1x1 + T roi_width = std::max(roi_end_w - roi_start_w, (T)1.); + T roi_height = std::max(roi_end_h - roi_start_h, (T)1.); + T bin_size_h = static_cast(roi_height) / static_cast(pooled_height); + T bin_size_w = static_cast(roi_width) / static_cast(pooled_width); + + // We use roi_bin_grid to sample the grid and mimic integral + int roi_bin_grid_h = (sampling_ratio > 0) + ? sampling_ratio + : ceil(roi_height / pooled_height); // e.g., = 2 + int roi_bin_grid_w = + (sampling_ratio > 0) ? sampling_ratio : ceil(roi_width / pooled_width); + + // We do average (integral) pooling inside a bin + const T count = roi_bin_grid_h * roi_bin_grid_w; // e.g. = 4 + + // we want to precalculate indeces and weights shared by all chanels, + // this is the key point of optimiation + std::vector> pre_calc( + roi_bin_grid_h * roi_bin_grid_w * pooled_width * pooled_height); + pre_calc_for_bilinear_interpolate( + height, + width, + pooled_height, + pooled_width, + roi_bin_grid_h, + roi_bin_grid_w, + roi_start_h, + roi_start_w, + bin_size_h, + bin_size_w, + roi_bin_grid_h, + roi_bin_grid_w, + pre_calc); + + for (int c = 0; c < channels; c++) { + int index_n_c = index_n + c * pooled_width * pooled_height; + const T* offset_bottom_data = + bottom_data + (roi_batch_ind * channels + c) * height * width; + int pre_calc_index = 0; + + for (int ph = 0; ph < pooled_height; ph++) { + for (int pw = 0; pw < pooled_width; pw++) { + int index = index_n_c + ph * pooled_width + pw; + + T output_val = 0.; + for (int iy = 0; iy < roi_bin_grid_h; iy++) { + for (int ix = 0; ix < roi_bin_grid_w; ix++) { + PreCalc pc = pre_calc[pre_calc_index]; + output_val += pc.w1 * offset_bottom_data[pc.pos1] + + pc.w2 * offset_bottom_data[pc.pos2] + + pc.w3 * offset_bottom_data[pc.pos3] + + pc.w4 * offset_bottom_data[pc.pos4]; + + pre_calc_index += 1; + } + } + output_val /= count; + + top_data[index] = output_val; + } // for pw + } // for ph + } // for c + } // for n +} + +at::Tensor ROIAlign_forward_cpu(const at::Tensor& input, + const at::Tensor& rois, + const float spatial_scale, + const int pooled_height, + const int pooled_width, + const int sampling_ratio) { + AT_ASSERTM(!input.type().is_cuda(), "input must be a CPU tensor"); + AT_ASSERTM(!rois.type().is_cuda(), "rois must be a CPU tensor"); + + auto num_rois = rois.size(0); + auto channels = input.size(1); + auto height = input.size(2); + auto width = input.size(3); + + auto output = at::empty({num_rois, channels, pooled_height, pooled_width}, input.options()); + auto output_size = num_rois * pooled_height * pooled_width * channels; + + if (output.numel() == 0) { + return output; + } + + AT_DISPATCH_FLOATING_TYPES(input.type(), "ROIAlign_forward", [&] { + ROIAlignForward_cpu_kernel( + output_size, + input.data(), + spatial_scale, + channels, + height, + width, + pooled_height, + pooled_width, + sampling_ratio, + rois.data(), + output.data()); + }); + return output; +} diff --git a/lib/model/csrc/cpu/nms_cpu.cpp b/lib/model/csrc/cpu/nms_cpu.cpp new file mode 100644 index 00000000..1153dea0 --- /dev/null +++ b/lib/model/csrc/cpu/nms_cpu.cpp @@ -0,0 +1,75 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#include "cpu/vision.h" + + +template +at::Tensor nms_cpu_kernel(const at::Tensor& dets, + const at::Tensor& scores, + const float threshold) { + AT_ASSERTM(!dets.type().is_cuda(), "dets must be a CPU tensor"); + AT_ASSERTM(!scores.type().is_cuda(), "scores must be a CPU tensor"); + AT_ASSERTM(dets.type() == scores.type(), "dets should have the same type as scores"); + + if (dets.numel() == 0) { + return at::empty({0}, dets.options().dtype(at::kLong).device(at::kCPU)); + } + + auto x1_t = dets.select(1, 0).contiguous(); + auto y1_t = dets.select(1, 1).contiguous(); + auto x2_t = dets.select(1, 2).contiguous(); + auto y2_t = dets.select(1, 3).contiguous(); + + at::Tensor areas_t = (x2_t - x1_t + 1) * (y2_t - y1_t + 1); + + auto order_t = std::get<1>(scores.sort(0, /* descending=*/true)); + + auto ndets = dets.size(0); + at::Tensor suppressed_t = at::zeros({ndets}, dets.options().dtype(at::kByte).device(at::kCPU)); + + auto suppressed = suppressed_t.data(); + auto order = order_t.data(); + auto x1 = x1_t.data(); + auto y1 = y1_t.data(); + auto x2 = x2_t.data(); + auto y2 = y2_t.data(); + auto areas = areas_t.data(); + + for (int64_t _i = 0; _i < ndets; _i++) { + auto i = order[_i]; + if (suppressed[i] == 1) + continue; + auto ix1 = x1[i]; + auto iy1 = y1[i]; + auto ix2 = x2[i]; + auto iy2 = y2[i]; + auto iarea = areas[i]; + + for (int64_t _j = _i + 1; _j < ndets; _j++) { + auto j = order[_j]; + if (suppressed[j] == 1) + continue; + auto xx1 = std::max(ix1, x1[j]); + auto yy1 = std::max(iy1, y1[j]); + auto xx2 = std::min(ix2, x2[j]); + auto yy2 = std::min(iy2, y2[j]); + + auto w = std::max(static_cast(0), xx2 - xx1 + 1); + auto h = std::max(static_cast(0), yy2 - yy1 + 1); + auto inter = w * h; + auto ovr = inter / (iarea + areas[j] - inter); + if (ovr >= threshold) + suppressed[j] = 1; + } + } + return at::nonzero(suppressed_t == 0).squeeze(1); +} + +at::Tensor nms_cpu(const at::Tensor& dets, + const at::Tensor& scores, + const float threshold) { + at::Tensor result; + AT_DISPATCH_FLOATING_TYPES(dets.type(), "nms", [&] { + result = nms_cpu_kernel(dets, scores, threshold); + }); + return result; +} diff --git a/lib/model/csrc/cpu/vision.h b/lib/model/csrc/cpu/vision.h new file mode 100644 index 00000000..92611253 --- /dev/null +++ b/lib/model/csrc/cpu/vision.h @@ -0,0 +1,16 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#pragma once +#include + + +at::Tensor ROIAlign_forward_cpu(const at::Tensor& input, + const at::Tensor& rois, + const float spatial_scale, + const int pooled_height, + const int pooled_width, + const int sampling_ratio); + + +at::Tensor nms_cpu(const at::Tensor& dets, + const at::Tensor& scores, + const float threshold); diff --git a/lib/model/csrc/cuda/ROIAlign_cuda.cu b/lib/model/csrc/cuda/ROIAlign_cuda.cu new file mode 100644 index 00000000..5fe97ca9 --- /dev/null +++ b/lib/model/csrc/cuda/ROIAlign_cuda.cu @@ -0,0 +1,346 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#include +#include + +#include +#include +#include + +// TODO make it in a common file +#define CUDA_1D_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ + i += blockDim.x * gridDim.x) + + +template +__device__ T bilinear_interpolate(const T* bottom_data, + const int height, const int width, + T y, T x, + const int index /* index for debug only*/) { + + // deal with cases that inverse elements are out of feature map boundary + if (y < -1.0 || y > height || x < -1.0 || x > width) { + //empty + return 0; + } + + if (y <= 0) y = 0; + if (x <= 0) x = 0; + + int y_low = (int) y; + int x_low = (int) x; + int y_high; + int x_high; + + if (y_low >= height - 1) { + y_high = y_low = height - 1; + y = (T) y_low; + } else { + y_high = y_low + 1; + } + + if (x_low >= width - 1) { + x_high = x_low = width - 1; + x = (T) x_low; + } else { + x_high = x_low + 1; + } + + T ly = y - y_low; + T lx = x - x_low; + T hy = 1. - ly, hx = 1. - lx; + // do bilinear interpolation + T v1 = bottom_data[y_low * width + x_low]; + T v2 = bottom_data[y_low * width + x_high]; + T v3 = bottom_data[y_high * width + x_low]; + T v4 = bottom_data[y_high * width + x_high]; + T w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; + + T val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + + return val; +} + +template +__global__ void RoIAlignForward(const int nthreads, const T* bottom_data, + const T spatial_scale, const int channels, + const int height, const int width, + const int pooled_height, const int pooled_width, + const int sampling_ratio, + const T* bottom_rois, T* top_data) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the pooled output + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + const T* offset_bottom_rois = bottom_rois + n * 5; + int roi_batch_ind = offset_bottom_rois[0]; + + // Do not using rounding; this implementation detail is critical + T roi_start_w = offset_bottom_rois[1] * spatial_scale; + T roi_start_h = offset_bottom_rois[2] * spatial_scale; + T roi_end_w = offset_bottom_rois[3] * spatial_scale; + T roi_end_h = offset_bottom_rois[4] * spatial_scale; + // T roi_start_w = round(offset_bottom_rois[1] * spatial_scale); + // T roi_start_h = round(offset_bottom_rois[2] * spatial_scale); + // T roi_end_w = round(offset_bottom_rois[3] * spatial_scale); + // T roi_end_h = round(offset_bottom_rois[4] * spatial_scale); + + // Force malformed ROIs to be 1x1 + T roi_width = max(roi_end_w - roi_start_w, (T)1.); + T roi_height = max(roi_end_h - roi_start_h, (T)1.); + T bin_size_h = static_cast(roi_height) / static_cast(pooled_height); + T bin_size_w = static_cast(roi_width) / static_cast(pooled_width); + + const T* offset_bottom_data = bottom_data + (roi_batch_ind * channels + c) * height * width; + + // We use roi_bin_grid to sample the grid and mimic integral + int roi_bin_grid_h = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_height / pooled_height); // e.g., = 2 + int roi_bin_grid_w = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_width / pooled_width); + + // We do average (integral) pooling inside a bin + const T count = roi_bin_grid_h * roi_bin_grid_w; // e.g. = 4 + + T output_val = 0.; + for (int iy = 0; iy < roi_bin_grid_h; iy ++) // e.g., iy = 0, 1 + { + const T y = roi_start_h + ph * bin_size_h + static_cast(iy + .5f) * bin_size_h / static_cast(roi_bin_grid_h); // e.g., 0.5, 1.5 + for (int ix = 0; ix < roi_bin_grid_w; ix ++) + { + const T x = roi_start_w + pw * bin_size_w + static_cast(ix + .5f) * bin_size_w / static_cast(roi_bin_grid_w); + + T val = bilinear_interpolate(offset_bottom_data, height, width, y, x, index); + output_val += val; + } + } + output_val /= count; + + top_data[index] = output_val; + } +} + + +template +__device__ void bilinear_interpolate_gradient( + const int height, const int width, + T y, T x, + T & w1, T & w2, T & w3, T & w4, + int & x_low, int & x_high, int & y_low, int & y_high, + const int index /* index for debug only*/) { + + // deal with cases that inverse elements are out of feature map boundary + if (y < -1.0 || y > height || x < -1.0 || x > width) { + //empty + w1 = w2 = w3 = w4 = 0.; + x_low = x_high = y_low = y_high = -1; + return; + } + + if (y <= 0) y = 0; + if (x <= 0) x = 0; + + y_low = (int) y; + x_low = (int) x; + + if (y_low >= height - 1) { + y_high = y_low = height - 1; + y = (T) y_low; + } else { + y_high = y_low + 1; + } + + if (x_low >= width - 1) { + x_high = x_low = width - 1; + x = (T) x_low; + } else { + x_high = x_low + 1; + } + + T ly = y - y_low; + T lx = x - x_low; + T hy = 1. - ly, hx = 1. - lx; + + // reference in forward + // T v1 = bottom_data[y_low * width + x_low]; + // T v2 = bottom_data[y_low * width + x_high]; + // T v3 = bottom_data[y_high * width + x_low]; + // T v4 = bottom_data[y_high * width + x_high]; + // T val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + + w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; + + return; +} + +template +__global__ void RoIAlignBackwardFeature(const int nthreads, const T* top_diff, + const int num_rois, const T spatial_scale, + const int channels, const int height, const int width, + const int pooled_height, const int pooled_width, + const int sampling_ratio, + T* bottom_diff, + const T* bottom_rois) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the pooled output + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + const T* offset_bottom_rois = bottom_rois + n * 5; + int roi_batch_ind = offset_bottom_rois[0]; + + // Do not using rounding; this implementation detail is critical + T roi_start_w = offset_bottom_rois[1] * spatial_scale; + T roi_start_h = offset_bottom_rois[2] * spatial_scale; + T roi_end_w = offset_bottom_rois[3] * spatial_scale; + T roi_end_h = offset_bottom_rois[4] * spatial_scale; + // T roi_start_w = round(offset_bottom_rois[1] * spatial_scale); + // T roi_start_h = round(offset_bottom_rois[2] * spatial_scale); + // T roi_end_w = round(offset_bottom_rois[3] * spatial_scale); + // T roi_end_h = round(offset_bottom_rois[4] * spatial_scale); + + // Force malformed ROIs to be 1x1 + T roi_width = max(roi_end_w - roi_start_w, (T)1.); + T roi_height = max(roi_end_h - roi_start_h, (T)1.); + T bin_size_h = static_cast(roi_height) / static_cast(pooled_height); + T bin_size_w = static_cast(roi_width) / static_cast(pooled_width); + + T* offset_bottom_diff = bottom_diff + (roi_batch_ind * channels + c) * height * width; + + int top_offset = (n * channels + c) * pooled_height * pooled_width; + const T* offset_top_diff = top_diff + top_offset; + const T top_diff_this_bin = offset_top_diff[ph * pooled_width + pw]; + + // We use roi_bin_grid to sample the grid and mimic integral + int roi_bin_grid_h = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_height / pooled_height); // e.g., = 2 + int roi_bin_grid_w = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_width / pooled_width); + + // We do average (integral) pooling inside a bin + const T count = roi_bin_grid_h * roi_bin_grid_w; // e.g. = 4 + + for (int iy = 0; iy < roi_bin_grid_h; iy ++) // e.g., iy = 0, 1 + { + const T y = roi_start_h + ph * bin_size_h + static_cast(iy + .5f) * bin_size_h / static_cast(roi_bin_grid_h); // e.g., 0.5, 1.5 + for (int ix = 0; ix < roi_bin_grid_w; ix ++) + { + const T x = roi_start_w + pw * bin_size_w + static_cast(ix + .5f) * bin_size_w / static_cast(roi_bin_grid_w); + + T w1, w2, w3, w4; + int x_low, x_high, y_low, y_high; + + bilinear_interpolate_gradient(height, width, y, x, + w1, w2, w3, w4, + x_low, x_high, y_low, y_high, + index); + + T g1 = top_diff_this_bin * w1 / count; + T g2 = top_diff_this_bin * w2 / count; + T g3 = top_diff_this_bin * w3 / count; + T g4 = top_diff_this_bin * w4 / count; + + if (x_low >= 0 && x_high >= 0 && y_low >= 0 && y_high >= 0) + { + atomicAdd(offset_bottom_diff + y_low * width + x_low, static_cast(g1)); + atomicAdd(offset_bottom_diff + y_low * width + x_high, static_cast(g2)); + atomicAdd(offset_bottom_diff + y_high * width + x_low, static_cast(g3)); + atomicAdd(offset_bottom_diff + y_high * width + x_high, static_cast(g4)); + } // if + } // ix + } // iy + } // CUDA_1D_KERNEL_LOOP +} // RoIAlignBackward + + +at::Tensor ROIAlign_forward_cuda(const at::Tensor& input, + const at::Tensor& rois, + const float spatial_scale, + const int pooled_height, + const int pooled_width, + const int sampling_ratio) { + AT_ASSERTM(input.type().is_cuda(), "input must be a CUDA tensor"); + AT_ASSERTM(rois.type().is_cuda(), "rois must be a CUDA tensor"); + + auto num_rois = rois.size(0); + auto channels = input.size(1); + auto height = input.size(2); + auto width = input.size(3); + + auto output = at::empty({num_rois, channels, pooled_height, pooled_width}, input.options()); + auto output_size = num_rois * pooled_height * pooled_width * channels; + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + + dim3 grid(std::min(THCCeilDiv(output_size, 512L), 4096L)); + dim3 block(512); + + if (output.numel() == 0) { + THCudaCheck(cudaGetLastError()); + return output; + } + + AT_DISPATCH_FLOATING_TYPES(input.type(), "ROIAlign_forward", [&] { + RoIAlignForward<<>>( + output_size, + input.contiguous().data(), + spatial_scale, + channels, + height, + width, + pooled_height, + pooled_width, + sampling_ratio, + rois.contiguous().data(), + output.data()); + }); + THCudaCheck(cudaGetLastError()); + return output; +} + +// TODO remove the dependency on input and use instead its sizes -> save memory +at::Tensor ROIAlign_backward_cuda(const at::Tensor& grad, + const at::Tensor& rois, + const float spatial_scale, + const int pooled_height, + const int pooled_width, + const int batch_size, + const int channels, + const int height, + const int width, + const int sampling_ratio) { + AT_ASSERTM(grad.type().is_cuda(), "grad must be a CUDA tensor"); + AT_ASSERTM(rois.type().is_cuda(), "rois must be a CUDA tensor"); + + auto num_rois = rois.size(0); + auto grad_input = at::zeros({batch_size, channels, height, width}, grad.options()); + + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + + dim3 grid(std::min(THCCeilDiv(grad.numel(), 512L), 4096L)); + dim3 block(512); + + // handle possibly empty gradients + if (grad.numel() == 0) { + THCudaCheck(cudaGetLastError()); + return grad_input; + } + + AT_DISPATCH_FLOATING_TYPES(grad.type(), "ROIAlign_backward", [&] { + RoIAlignBackwardFeature<<>>( + grad.numel(), + grad.contiguous().data(), + num_rois, + spatial_scale, + channels, + height, + width, + pooled_height, + pooled_width, + sampling_ratio, + grad_input.data(), + rois.contiguous().data()); + }); + THCudaCheck(cudaGetLastError()); + return grad_input; +} diff --git a/lib/model/csrc/cuda/ROIPool_cuda.cu b/lib/model/csrc/cuda/ROIPool_cuda.cu new file mode 100644 index 00000000..b826dd9b --- /dev/null +++ b/lib/model/csrc/cuda/ROIPool_cuda.cu @@ -0,0 +1,202 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#include +#include + +#include +#include +#include + + +// TODO make it in a common file +#define CUDA_1D_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ + i += blockDim.x * gridDim.x) + + +template +__global__ void RoIPoolFForward(const int nthreads, const T* bottom_data, + const T spatial_scale, const int channels, const int height, + const int width, const int pooled_height, const int pooled_width, + const T* bottom_rois, T* top_data, int* argmax_data) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the pooled output + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + const T* offset_bottom_rois = bottom_rois + n * 5; + int roi_batch_ind = offset_bottom_rois[0]; + int roi_start_w = round(offset_bottom_rois[1] * spatial_scale); + int roi_start_h = round(offset_bottom_rois[2] * spatial_scale); + int roi_end_w = round(offset_bottom_rois[3] * spatial_scale); + int roi_end_h = round(offset_bottom_rois[4] * spatial_scale); + + // Force malformed ROIs to be 1x1 + int roi_width = max(roi_end_w - roi_start_w + 1, 1); + int roi_height = max(roi_end_h - roi_start_h + 1, 1); + T bin_size_h = static_cast(roi_height) + / static_cast(pooled_height); + T bin_size_w = static_cast(roi_width) + / static_cast(pooled_width); + + int hstart = static_cast(floor(static_cast(ph) + * bin_size_h)); + int wstart = static_cast(floor(static_cast(pw) + * bin_size_w)); + int hend = static_cast(ceil(static_cast(ph + 1) + * bin_size_h)); + int wend = static_cast(ceil(static_cast(pw + 1) + * bin_size_w)); + + // Add roi offsets and clip to input boundaries + hstart = min(max(hstart + roi_start_h, 0), height); + hend = min(max(hend + roi_start_h, 0), height); + wstart = min(max(wstart + roi_start_w, 0), width); + wend = min(max(wend + roi_start_w, 0), width); + bool is_empty = (hend <= hstart) || (wend <= wstart); + + // Define an empty pooling region to be zero + T maxval = is_empty ? 0 : -FLT_MAX; + // If nothing is pooled, argmax = -1 causes nothing to be backprop'd + int maxidx = -1; + const T* offset_bottom_data = + bottom_data + (roi_batch_ind * channels + c) * height * width; + for (int h = hstart; h < hend; ++h) { + for (int w = wstart; w < wend; ++w) { + int bottom_index = h * width + w; + if (offset_bottom_data[bottom_index] > maxval) { + maxval = offset_bottom_data[bottom_index]; + maxidx = bottom_index; + } + } + } + top_data[index] = maxval; + argmax_data[index] = maxidx; + } +} + +template +__global__ void RoIPoolFBackward(const int nthreads, const T* top_diff, + const int* argmax_data, const int num_rois, const T spatial_scale, + const int channels, const int height, const int width, + const int pooled_height, const int pooled_width, T* bottom_diff, + const T* bottom_rois) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the pooled output + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + const T* offset_bottom_rois = bottom_rois + n * 5; + int roi_batch_ind = offset_bottom_rois[0]; + int bottom_offset = (roi_batch_ind * channels + c) * height * width; + int top_offset = (n * channels + c) * pooled_height * pooled_width; + const T* offset_top_diff = top_diff + top_offset; + T* offset_bottom_diff = bottom_diff + bottom_offset; + const int* offset_argmax_data = argmax_data + top_offset; + + int argmax = offset_argmax_data[ph * pooled_width + pw]; + if (argmax != -1) { + atomicAdd( + offset_bottom_diff + argmax, + static_cast(offset_top_diff[ph * pooled_width + pw])); + + } + } +} + +std::tuple ROIPool_forward_cuda(const at::Tensor& input, + const at::Tensor& rois, + const float spatial_scale, + const int pooled_height, + const int pooled_width) { + AT_ASSERTM(input.type().is_cuda(), "input must be a CUDA tensor"); + AT_ASSERTM(rois.type().is_cuda(), "rois must be a CUDA tensor"); + + auto num_rois = rois.size(0); + auto channels = input.size(1); + auto height = input.size(2); + auto width = input.size(3); + + auto output = at::empty({num_rois, channels, pooled_height, pooled_width}, input.options()); + auto output_size = num_rois * pooled_height * pooled_width * channels; + auto argmax = at::zeros({num_rois, channels, pooled_height, pooled_width}, input.options().dtype(at::kInt)); + + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + + dim3 grid(std::min(THCCeilDiv(output_size, 512L), 4096L)); + dim3 block(512); + + if (output.numel() == 0) { + THCudaCheck(cudaGetLastError()); + return std::make_tuple(output, argmax); + } + + AT_DISPATCH_FLOATING_TYPES(input.type(), "ROIPool_forward", [&] { + RoIPoolFForward<<>>( + output_size, + input.contiguous().data(), + spatial_scale, + channels, + height, + width, + pooled_height, + pooled_width, + rois.contiguous().data(), + output.data(), + argmax.data()); + }); + THCudaCheck(cudaGetLastError()); + return std::make_tuple(output, argmax); +} + +// TODO remove the dependency on input and use instead its sizes -> save memory +at::Tensor ROIPool_backward_cuda(const at::Tensor& grad, + const at::Tensor& input, + const at::Tensor& rois, + const at::Tensor& argmax, + const float spatial_scale, + const int pooled_height, + const int pooled_width, + const int batch_size, + const int channels, + const int height, + const int width) { + AT_ASSERTM(grad.type().is_cuda(), "grad must be a CUDA tensor"); + AT_ASSERTM(rois.type().is_cuda(), "rois must be a CUDA tensor"); + // TODO add more checks + + auto num_rois = rois.size(0); + auto grad_input = at::zeros({batch_size, channels, height, width}, grad.options()); + + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + + dim3 grid(std::min(THCCeilDiv(grad.numel(), 512L), 4096L)); + dim3 block(512); + + // handle possibly empty gradients + if (grad.numel() == 0) { + THCudaCheck(cudaGetLastError()); + return grad_input; + } + + AT_DISPATCH_FLOATING_TYPES(grad.type(), "ROIPool_backward", [&] { + RoIPoolFBackward<<>>( + grad.numel(), + grad.contiguous().data(), + argmax.data(), + num_rois, + spatial_scale, + channels, + height, + width, + pooled_height, + pooled_width, + grad_input.data(), + rois.contiguous().data()); + }); + THCudaCheck(cudaGetLastError()); + return grad_input; +} diff --git a/lib/model/nms/nms_kernel.cu b/lib/model/csrc/cuda/nms.cu similarity index 62% rename from lib/model/nms/nms_kernel.cu rename to lib/model/csrc/cuda/nms.cu index 038a5901..833d8523 100644 --- a/lib/model/nms/nms_kernel.cu +++ b/lib/model/csrc/cuda/nms.cu @@ -1,24 +1,13 @@ -// ------------------------------------------------------------------ -// Faster R-CNN -// Copyright (c) 2015 Microsoft -// Licensed under The MIT License [see fast-rcnn/LICENSE for details] -// Written by Shaoqing Ren -// ------------------------------------------------------------------ - -#include "gpu_nms.hpp" +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#include +#include + +#include +#include + #include #include -#define CUDA_CHECK(condition) \ - /* Code block avoids redefinition of cudaError_t error */ \ - do { \ - cudaError_t error = condition; \ - if (error != cudaSuccess) { \ - std::cout << cudaGetErrorString(error) << std::endl; \ - } \ - } while (0) - -#define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0)) int const threadsPerBlock = sizeof(unsigned long long) * 8; __device__ inline float devIoU(float const * const a, float const * const b) { @@ -72,43 +61,35 @@ __global__ void nms_kernel(const int n_boxes, const float nms_overlap_thresh, t |= 1ULL << i; } } - const int col_blocks = DIVUP(n_boxes, threadsPerBlock); + const int col_blocks = THCCeilDiv(n_boxes, threadsPerBlock); dev_mask[cur_box_idx * col_blocks + col_start] = t; } } -void _set_device(int device_id) { - int current_device; - CUDA_CHECK(cudaGetDevice(¤t_device)); - if (current_device == device_id) { - return; - } - // The call to cudaSetDevice must come before any calls to Get, which - // may perform initialization using the GPU. - CUDA_CHECK(cudaSetDevice(device_id)); -} +// boxes is a N x 5 tensor +at::Tensor nms_cuda(const at::Tensor boxes, float nms_overlap_thresh) { + using scalar_t = float; + AT_ASSERTM(boxes.type().is_cuda(), "boxes must be a CUDA tensor"); + auto scores = boxes.select(1, 4); + auto order_t = std::get<1>(scores.sort(0, /* descending=*/true)); + auto boxes_sorted = boxes.index_select(0, order_t); -void _nms(int* keep_out, int* num_out, const float* boxes_host, int boxes_num, - int boxes_dim, float nms_overlap_thresh, int device_id) { - _set_device(device_id); + int boxes_num = boxes.size(0); - float* boxes_dev = NULL; - unsigned long long* mask_dev = NULL; + const int col_blocks = THCCeilDiv(boxes_num, threadsPerBlock); + + scalar_t* boxes_dev = boxes_sorted.data(); - const int col_blocks = DIVUP(boxes_num, threadsPerBlock); + THCState *state = at::globalContext().lazyInitCUDA(); // TODO replace with getTHCState - CUDA_CHECK(cudaMalloc(&boxes_dev, - boxes_num * boxes_dim * sizeof(float))); - CUDA_CHECK(cudaMemcpy(boxes_dev, - boxes_host, - boxes_num * boxes_dim * sizeof(float), - cudaMemcpyHostToDevice)); + unsigned long long* mask_dev = NULL; + //THCudaCheck(THCudaMalloc(state, (void**) &mask_dev, + // boxes_num * col_blocks * sizeof(unsigned long long))); - CUDA_CHECK(cudaMalloc(&mask_dev, - boxes_num * col_blocks * sizeof(unsigned long long))); + mask_dev = (unsigned long long*) THCudaMalloc(state, boxes_num * col_blocks * sizeof(unsigned long long)); - dim3 blocks(DIVUP(boxes_num, threadsPerBlock), - DIVUP(boxes_num, threadsPerBlock)); + dim3 blocks(THCCeilDiv(boxes_num, threadsPerBlock), + THCCeilDiv(boxes_num, threadsPerBlock)); dim3 threads(threadsPerBlock); nms_kernel<<>>(boxes_num, nms_overlap_thresh, @@ -116,7 +97,7 @@ void _nms(int* keep_out, int* num_out, const float* boxes_host, int boxes_num, mask_dev); std::vector mask_host(boxes_num * col_blocks); - CUDA_CHECK(cudaMemcpy(&mask_host[0], + THCudaCheck(cudaMemcpy(&mask_host[0], mask_dev, sizeof(unsigned long long) * boxes_num * col_blocks, cudaMemcpyDeviceToHost)); @@ -124,6 +105,9 @@ void _nms(int* keep_out, int* num_out, const float* boxes_host, int boxes_num, std::vector remv(col_blocks); memset(&remv[0], 0, sizeof(unsigned long long) * col_blocks); + at::Tensor keep = at::empty({boxes_num}, boxes.options().dtype(at::kLong).device(at::kCPU)); + int64_t* keep_out = keep.data(); + int num_to_keep = 0; for (int i = 0; i < boxes_num; i++) { int nblock = i / threadsPerBlock; @@ -137,8 +121,11 @@ void _nms(int* keep_out, int* num_out, const float* boxes_host, int boxes_num, } } } - *num_out = num_to_keep; - CUDA_CHECK(cudaFree(boxes_dev)); - CUDA_CHECK(cudaFree(mask_dev)); + THCudaFree(state, mask_dev); + // TODO improve this part + return std::get<0>(order_t.index({ + keep.narrow(/*dim=*/0, /*start=*/0, /*length=*/num_to_keep).to( + order_t.device(), keep.scalar_type()) + }).sort(0, false)); } diff --git a/lib/model/csrc/cuda/vision.h b/lib/model/csrc/cuda/vision.h new file mode 100644 index 00000000..977cef7b --- /dev/null +++ b/lib/model/csrc/cuda/vision.h @@ -0,0 +1,48 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#pragma once +#include + + +at::Tensor ROIAlign_forward_cuda(const at::Tensor& input, + const at::Tensor& rois, + const float spatial_scale, + const int pooled_height, + const int pooled_width, + const int sampling_ratio); + +at::Tensor ROIAlign_backward_cuda(const at::Tensor& grad, + const at::Tensor& rois, + const float spatial_scale, + const int pooled_height, + const int pooled_width, + const int batch_size, + const int channels, + const int height, + const int width, + const int sampling_ratio); + + +std::tuple ROIPool_forward_cuda(const at::Tensor& input, + const at::Tensor& rois, + const float spatial_scale, + const int pooled_height, + const int pooled_width); + +at::Tensor ROIPool_backward_cuda(const at::Tensor& grad, + const at::Tensor& input, + const at::Tensor& rois, + const at::Tensor& argmax, + const float spatial_scale, + const int pooled_height, + const int pooled_width, + const int batch_size, + const int channels, + const int height, + const int width); + +at::Tensor nms_cuda(const at::Tensor boxes, float nms_overlap_thresh); + + +at::Tensor compute_flow_cuda(const at::Tensor& boxes, + const int height, + const int width); diff --git a/lib/model/csrc/nms.h b/lib/model/csrc/nms.h new file mode 100644 index 00000000..312fed4a --- /dev/null +++ b/lib/model/csrc/nms.h @@ -0,0 +1,28 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#pragma once +#include "cpu/vision.h" + +#ifdef WITH_CUDA +#include "cuda/vision.h" +#endif + + +at::Tensor nms(const at::Tensor& dets, + const at::Tensor& scores, + const float threshold) { + + if (dets.type().is_cuda()) { +#ifdef WITH_CUDA + // TODO raise error if not compiled with CUDA + if (dets.numel() == 0) + return at::empty({0}, dets.options().dtype(at::kLong).device(at::kCPU)); + auto b = at::cat({dets, scores.unsqueeze(1)}, 1); + return nms_cuda(b, threshold); +#else + AT_ERROR("Not compiled with GPU support"); +#endif + } + + at::Tensor result = nms_cpu(dets, scores, threshold); + return result; +} diff --git a/lib/model/csrc/vision.cpp b/lib/model/csrc/vision.cpp new file mode 100644 index 00000000..ff002584 --- /dev/null +++ b/lib/model/csrc/vision.cpp @@ -0,0 +1,13 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#include "nms.h" +#include "ROIAlign.h" +#include "ROIPool.h" + + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("nms", &nms, "non-maximum suppression"); + m.def("roi_align_forward", &ROIAlign_forward, "ROIAlign_forward"); + m.def("roi_align_backward", &ROIAlign_backward, "ROIAlign_backward"); + m.def("roi_pool_forward", &ROIPool_forward, "ROIPool_forward"); + m.def("roi_pool_backward", &ROIPool_backward, "ROIPool_backward"); +} diff --git a/lib/model/nms/.gitignore b/lib/model/nms/.gitignore deleted file mode 100644 index 15a165d4..00000000 --- a/lib/model/nms/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.c -*.cpp -*.so diff --git a/lib/model/nms/__init__.py b/lib/model/nms/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/nms/_ext/__init__.py b/lib/model/nms/_ext/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/nms/_ext/nms/__init__.py b/lib/model/nms/_ext/nms/__init__.py deleted file mode 100644 index d71786fd..00000000 --- a/lib/model/nms/_ext/nms/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ - -from torch.utils.ffi import _wrap_function -from ._nms import lib as _lib, ffi as _ffi - -__all__ = [] -def _import_symbols(locals): - for symbol in dir(_lib): - fn = getattr(_lib, symbol) - if callable(fn): - locals[symbol] = _wrap_function(fn, _ffi) - else: - locals[symbol] = fn - __all__.append(symbol) - -_import_symbols(locals()) diff --git a/lib/model/nms/build.py b/lib/model/nms/build.py deleted file mode 100644 index 4f0a6659..00000000 --- a/lib/model/nms/build.py +++ /dev/null @@ -1,37 +0,0 @@ -from __future__ import print_function -import os -import torch -from torch.utils.ffi import create_extension - -#this_file = os.path.dirname(__file__) - -sources = [] -headers = [] -defines = [] -with_cuda = False - -if torch.cuda.is_available(): - print('Including CUDA code.') - sources += ['src/nms_cuda.c'] - headers += ['src/nms_cuda.h'] - defines += [('WITH_CUDA', None)] - with_cuda = True - -this_file = os.path.dirname(os.path.realpath(__file__)) -print(this_file) -extra_objects = ['src/nms_cuda_kernel.cu.o'] -extra_objects = [os.path.join(this_file, fname) for fname in extra_objects] -print(extra_objects) - -ffi = create_extension( - '_ext.nms', - headers=headers, - sources=sources, - define_macros=defines, - relative_to=__file__, - with_cuda=with_cuda, - extra_objects=extra_objects -) - -if __name__ == '__main__': - ffi.build() diff --git a/lib/model/nms/make.sh b/lib/model/nms/make.sh deleted file mode 100644 index 07c8f3ef..00000000 --- a/lib/model/nms/make.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -# CUDA_PATH=/usr/local/cuda/ - -cd src -echo "Compiling stnm kernels by nvcc..." -nvcc -c -o nms_cuda_kernel.cu.o nms_cuda_kernel.cu -x cu -Xcompiler -fPIC -arch=sm_52 - -cd ../ -python build.py diff --git a/lib/model/nms/nms_gpu.py b/lib/model/nms/nms_gpu.py deleted file mode 100644 index 4134c9d8..00000000 --- a/lib/model/nms/nms_gpu.py +++ /dev/null @@ -1,12 +0,0 @@ -from __future__ import absolute_import -import torch -import numpy as np -from ._ext import nms -import pdb - -def nms_gpu(dets, thresh): - keep = dets.new(dets.size(0), 1).zero_().int() - num_out = dets.new(1).zero_().int() - nms.nms_cuda(keep, dets, num_out, thresh) - keep = keep[:num_out[0]] - return keep diff --git a/lib/model/nms/nms_wrapper.py b/lib/model/nms/nms_wrapper.py deleted file mode 100644 index c9a39565..00000000 --- a/lib/model/nms/nms_wrapper.py +++ /dev/null @@ -1,18 +0,0 @@ -# -------------------------------------------------------- -# Fast R-CNN -# Copyright (c) 2015 Microsoft -# Licensed under The MIT License [see LICENSE for details] -# Written by Ross Girshick -# -------------------------------------------------------- -import torch -from core.config import cfg -from model.nms.nms_gpu import nms_gpu - -def nms(dets, thresh, force_cpu=False): - """Dispatch to either CPU or GPU NMS implementations.""" - if dets.shape[0] == 0: - return [] - # ---numpy version--- - # original: return gpu_nms(dets, thresh, device_id=cfg.GPU_ID) - # ---pytorch version--- - return nms_gpu(dets, thresh) diff --git a/lib/model/nms/src/nms_cuda.c b/lib/model/nms/src/nms_cuda.c deleted file mode 100644 index c999ddee..00000000 --- a/lib/model/nms/src/nms_cuda.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include "nms_cuda_kernel.h" - -// this symbol will be resolved automatically from PyTorch libs -extern THCState *state; - -int nms_cuda(THCudaIntTensor *keep_out, THCudaTensor *boxes_host, - THCudaIntTensor *num_out, float nms_overlap_thresh) { - - nms_cuda_compute(THCudaIntTensor_data(state, keep_out), - THCudaIntTensor_data(state, num_out), - THCudaTensor_data(state, boxes_host), - THCudaTensor_size(state, boxes_host, 0), - THCudaTensor_size(state, boxes_host, 1), - nms_overlap_thresh); - - return 1; -} diff --git a/lib/model/nms/src/nms_cuda.h b/lib/model/nms/src/nms_cuda.h deleted file mode 100644 index e85559a4..00000000 --- a/lib/model/nms/src/nms_cuda.h +++ /dev/null @@ -1,5 +0,0 @@ -// int nms_cuda(THCudaTensor *keep_out, THCudaTensor *num_out, -// THCudaTensor *boxes_host, THCudaTensor *nms_overlap_thresh); - -int nms_cuda(THCudaIntTensor *keep_out, THCudaTensor *boxes_host, - THCudaIntTensor *num_out, float nms_overlap_thresh); diff --git a/lib/model/nms/src/nms_cuda_kernel.cu b/lib/model/nms/src/nms_cuda_kernel.cu deleted file mode 100644 index d572684f..00000000 --- a/lib/model/nms/src/nms_cuda_kernel.cu +++ /dev/null @@ -1,161 +0,0 @@ -// ------------------------------------------------------------------ -// Faster R-CNN -// Copyright (c) 2015 Microsoft -// Licensed under The MIT License [see fast-rcnn/LICENSE for details] -// Written by Shaoqing Ren -// ------------------------------------------------------------------ - -#include -#include -#include -#include -#include "nms_cuda_kernel.h" - -#define CUDA_WARN(XXX) \ - do { if (XXX != cudaSuccess) std::cout << "CUDA Error: " << \ - cudaGetErrorString(XXX) << ", at line " << __LINE__ \ -<< std::endl; cudaDeviceSynchronize(); } while (0) - -#define CUDA_CHECK(condition) \ - /* Code block avoids redefinition of cudaError_t error */ \ - do { \ - cudaError_t error = condition; \ - if (error != cudaSuccess) { \ - std::cout << cudaGetErrorString(error) << std::endl; \ - } \ - } while (0) - -#define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0)) -int const threadsPerBlock = sizeof(unsigned long long) * 8; - -__device__ inline float devIoU(float const * const a, float const * const b) { - float left = max(a[0], b[0]), right = min(a[2], b[2]); - float top = max(a[1], b[1]), bottom = min(a[3], b[3]); - float width = max(right - left + 1, 0.f), height = max(bottom - top + 1, 0.f); - float interS = width * height; - float Sa = (a[2] - a[0] + 1) * (a[3] - a[1] + 1); - float Sb = (b[2] - b[0] + 1) * (b[3] - b[1] + 1); - return interS / (Sa + Sb - interS); -} - -__global__ void nms_kernel(int n_boxes, float nms_overlap_thresh, - float *dev_boxes, unsigned long long *dev_mask) { - const int row_start = blockIdx.y; - const int col_start = blockIdx.x; - - // if (row_start > col_start) return; - - const int row_size = - min(n_boxes - row_start * threadsPerBlock, threadsPerBlock); - const int col_size = - min(n_boxes - col_start * threadsPerBlock, threadsPerBlock); - - __shared__ float block_boxes[threadsPerBlock * 5]; - if (threadIdx.x < col_size) { - block_boxes[threadIdx.x * 5 + 0] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 0]; - block_boxes[threadIdx.x * 5 + 1] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 1]; - block_boxes[threadIdx.x * 5 + 2] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 2]; - block_boxes[threadIdx.x * 5 + 3] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 3]; - block_boxes[threadIdx.x * 5 + 4] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 4]; - } - __syncthreads(); - - if (threadIdx.x < row_size) { - const int cur_box_idx = threadsPerBlock * row_start + threadIdx.x; - const float *cur_box = dev_boxes + cur_box_idx * 5; - int i = 0; - unsigned long long t = 0; - int start = 0; - if (row_start == col_start) { - start = threadIdx.x + 1; - } - for (i = start; i < col_size; i++) { - if (devIoU(cur_box, block_boxes + i * 5) > nms_overlap_thresh) { - t |= 1ULL << i; - } - } - const int col_blocks = DIVUP(n_boxes, threadsPerBlock); - dev_mask[cur_box_idx * col_blocks + col_start] = t; - } -} - -void nms_cuda_compute(int* keep_out, int *num_out, float* boxes_host, int boxes_num, - int boxes_dim, float nms_overlap_thresh) { - - float* boxes_dev = NULL; - unsigned long long* mask_dev = NULL; - - const int col_blocks = DIVUP(boxes_num, threadsPerBlock); - - CUDA_CHECK(cudaMalloc(&boxes_dev, - boxes_num * boxes_dim * sizeof(float))); - CUDA_CHECK(cudaMemcpy(boxes_dev, - boxes_host, - boxes_num * boxes_dim * sizeof(float), - cudaMemcpyHostToDevice)); - - CUDA_CHECK(cudaMalloc(&mask_dev, - boxes_num * col_blocks * sizeof(unsigned long long))); - - dim3 blocks(DIVUP(boxes_num, threadsPerBlock), - DIVUP(boxes_num, threadsPerBlock)); - dim3 threads(threadsPerBlock); - - // printf("i am at line %d\n", boxes_num); - // printf("i am at line %d\n", boxes_dim); - - nms_kernel<<>>(boxes_num, - nms_overlap_thresh, - boxes_dev, - mask_dev); - - std::vector mask_host(boxes_num * col_blocks); - CUDA_CHECK(cudaMemcpy(&mask_host[0], - mask_dev, - sizeof(unsigned long long) * boxes_num * col_blocks, - cudaMemcpyDeviceToHost)); - - std::vector remv(col_blocks); - memset(&remv[0], 0, sizeof(unsigned long long) * col_blocks); - - // we need to create a memory for keep_out on cpu - // otherwise, the following code cannot run - - int* keep_out_cpu = new int[boxes_num]; - - int num_to_keep = 0; - for (int i = 0; i < boxes_num; i++) { - int nblock = i / threadsPerBlock; - int inblock = i % threadsPerBlock; - - if (!(remv[nblock] & (1ULL << inblock))) { - // orignal: keep_out[num_to_keep++] = i; - keep_out_cpu[num_to_keep++] = i; - unsigned long long *p = &mask_host[0] + i * col_blocks; - for (int j = nblock; j < col_blocks; j++) { - remv[j] |= p[j]; - } - } - } - - // copy keep_out_cpu to keep_out on gpu - CUDA_WARN(cudaMemcpy(keep_out, keep_out_cpu, boxes_num * sizeof(int),cudaMemcpyHostToDevice)); - - // *num_out = num_to_keep; - - // original: *num_out = num_to_keep; - // copy num_to_keep to num_out on gpu - - CUDA_WARN(cudaMemcpy(num_out, &num_to_keep, 1 * sizeof(int),cudaMemcpyHostToDevice)); - - // release cuda memory - CUDA_CHECK(cudaFree(boxes_dev)); - CUDA_CHECK(cudaFree(mask_dev)); - // release cpu memory - delete []keep_out_cpu; -} diff --git a/lib/model/nms/src/nms_cuda_kernel.h b/lib/model/nms/src/nms_cuda_kernel.h deleted file mode 100644 index ae6f83e4..00000000 --- a/lib/model/nms/src/nms_cuda_kernel.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -void nms_cuda_compute(int* keep_out, int *num_out, float* boxes_host, int boxes_num, - int boxes_dim, float nms_overlap_thresh); - -#ifdef __cplusplus -} -#endif diff --git a/lib/model/roi_align/__init__.py b/lib/model/roi_align/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/roi_align/_ext/__init__.py b/lib/model/roi_align/_ext/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/roi_align/_ext/roi_align/__init__.py b/lib/model/roi_align/_ext/roi_align/__init__.py deleted file mode 100644 index c5b6e5d5..00000000 --- a/lib/model/roi_align/_ext/roi_align/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ - -from torch.utils.ffi import _wrap_function -from ._roi_align import lib as _lib, ffi as _ffi - -__all__ = [] -def _import_symbols(locals): - for symbol in dir(_lib): - fn = getattr(_lib, symbol) - if callable(fn): - locals[symbol] = _wrap_function(fn, _ffi) - else: - locals[symbol] = fn - __all__.append(symbol) - -_import_symbols(locals()) diff --git a/lib/model/roi_align/build.py b/lib/model/roi_align/build.py deleted file mode 100644 index 30f0f2d2..00000000 --- a/lib/model/roi_align/build.py +++ /dev/null @@ -1,36 +0,0 @@ -from __future__ import print_function -import os -import torch -from torch.utils.ffi import create_extension - -# sources = ['src/roi_align.c'] -# headers = ['src/roi_align.h'] -sources = [] -headers = [] -defines = [] -with_cuda = False - -if torch.cuda.is_available(): - print('Including CUDA code.') - sources += ['src/roi_align_cuda.c'] - headers += ['src/roi_align_cuda.h'] - defines += [('WITH_CUDA', None)] - with_cuda = True - -this_file = os.path.dirname(os.path.realpath(__file__)) -print(this_file) -extra_objects = ['src/roi_align_kernel.cu.o'] -extra_objects = [os.path.join(this_file, fname) for fname in extra_objects] - -ffi = create_extension( - '_ext.roi_align', - headers=headers, - sources=sources, - define_macros=defines, - relative_to=__file__, - with_cuda=with_cuda, - extra_objects=extra_objects -) - -if __name__ == '__main__': - ffi.build() diff --git a/lib/model/roi_align/functions/__init__.py b/lib/model/roi_align/functions/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/roi_align/functions/roi_align.py b/lib/model/roi_align/functions/roi_align.py deleted file mode 100644 index b6ebcdba..00000000 --- a/lib/model/roi_align/functions/roi_align.py +++ /dev/null @@ -1,47 +0,0 @@ -import torch -from torch.autograd import Function -from .._ext import roi_align - - -# TODO use save_for_backward instead -class RoIAlignFunction(Function): - def __init__(self, aligned_height, aligned_width, spatial_scale): - self.aligned_width = int(aligned_width) - self.aligned_height = int(aligned_height) - self.spatial_scale = float(spatial_scale) - self.rois = None - self.feature_size = None - - def forward(self, features, rois): - self.rois = rois - self.feature_size = features.size() - - batch_size, num_channels, data_height, data_width = features.size() - num_rois = rois.size(0) - - output = features.new(num_rois, num_channels, self.aligned_height, self.aligned_width).zero_() - if features.is_cuda: - roi_align.roi_align_forward_cuda(self.aligned_height, - self.aligned_width, - self.spatial_scale, features, - rois, output) - else: - raise NotImplementedError - - return output - - def backward(self, grad_output): - assert(self.feature_size is not None and grad_output.is_cuda) - - batch_size, num_channels, data_height, data_width = self.feature_size - - grad_input = self.rois.new(batch_size, num_channels, data_height, - data_width).zero_() - roi_align.roi_align_backward_cuda(self.aligned_height, - self.aligned_width, - self.spatial_scale, grad_output, - self.rois, grad_input) - - # print grad_input - - return grad_input, None diff --git a/lib/model/roi_align/make.sh b/lib/model/roi_align/make.sh deleted file mode 100755 index 49b80b7a..00000000 --- a/lib/model/roi_align/make.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -CUDA_PATH=/usr/local/cuda/ - -cd src -echo "Compiling my_lib kernels by nvcc..." -nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu -x cu -Xcompiler -fPIC -arch=sm_52 - -cd ../ -python build.py diff --git a/lib/model/roi_align/modules/__init__.py b/lib/model/roi_align/modules/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/roi_align/modules/roi_align.py b/lib/model/roi_align/modules/roi_align.py deleted file mode 100644 index ca02e3bd..00000000 --- a/lib/model/roi_align/modules/roi_align.py +++ /dev/null @@ -1,42 +0,0 @@ -from torch.nn.modules.module import Module -from torch.nn.functional import avg_pool2d, max_pool2d -from ..functions.roi_align import RoIAlignFunction - - -class RoIAlign(Module): - def __init__(self, aligned_height, aligned_width, spatial_scale): - super(RoIAlign, self).__init__() - - self.aligned_width = int(aligned_width) - self.aligned_height = int(aligned_height) - self.spatial_scale = float(spatial_scale) - - def forward(self, features, rois): - return RoIAlignFunction(self.aligned_height, self.aligned_width, - self.spatial_scale)(features, rois) - -class RoIAlignAvg(Module): - def __init__(self, aligned_height, aligned_width, spatial_scale): - super(RoIAlignAvg, self).__init__() - - self.aligned_width = int(aligned_width) - self.aligned_height = int(aligned_height) - self.spatial_scale = float(spatial_scale) - - def forward(self, features, rois): - x = RoIAlignFunction(self.aligned_height+1, self.aligned_width+1, - self.spatial_scale)(features, rois) - return avg_pool2d(x, kernel_size=2, stride=1) - -class RoIAlignMax(Module): - def __init__(self, aligned_height, aligned_width, spatial_scale): - super(RoIAlignMax, self).__init__() - - self.aligned_width = int(aligned_width) - self.aligned_height = int(aligned_height) - self.spatial_scale = float(spatial_scale) - - def forward(self, features, rois): - x = RoIAlignFunction(self.aligned_height+1, self.aligned_width+1, - self.spatial_scale)(features, rois) - return max_pool2d(x, kernel_size=2, stride=1) diff --git a/lib/model/roi_align/src/roi_align_cuda.c b/lib/model/roi_align/src/roi_align_cuda.c deleted file mode 100644 index 0644fc60..00000000 --- a/lib/model/roi_align/src/roi_align_cuda.c +++ /dev/null @@ -1,76 +0,0 @@ -#include -#include -#include "roi_align_kernel.h" - -extern THCState *state; - -int roi_align_forward_cuda(int aligned_height, int aligned_width, float spatial_scale, - THCudaTensor * features, THCudaTensor * rois, THCudaTensor * output) -{ - // Grab the input tensor - float * data_flat = THCudaTensor_data(state, features); - float * rois_flat = THCudaTensor_data(state, rois); - - float * output_flat = THCudaTensor_data(state, output); - - // Number of ROIs - int num_rois = THCudaTensor_size(state, rois, 0); - int size_rois = THCudaTensor_size(state, rois, 1); - if (size_rois != 5) - { - return 0; - } - - // data height - int data_height = THCudaTensor_size(state, features, 2); - // data width - int data_width = THCudaTensor_size(state, features, 3); - // Number of channels - int num_channels = THCudaTensor_size(state, features, 1); - - cudaStream_t stream = THCState_getCurrentStream(state); - - ROIAlignForwardLaucher( - data_flat, spatial_scale, num_rois, data_height, - data_width, num_channels, aligned_height, - aligned_width, rois_flat, - output_flat, stream); - - return 1; -} - -int roi_align_backward_cuda(int aligned_height, int aligned_width, float spatial_scale, - THCudaTensor * top_grad, THCudaTensor * rois, THCudaTensor * bottom_grad) -{ - // Grab the input tensor - float * top_grad_flat = THCudaTensor_data(state, top_grad); - float * rois_flat = THCudaTensor_data(state, rois); - - float * bottom_grad_flat = THCudaTensor_data(state, bottom_grad); - - // Number of ROIs - int num_rois = THCudaTensor_size(state, rois, 0); - int size_rois = THCudaTensor_size(state, rois, 1); - if (size_rois != 5) - { - return 0; - } - - // batch size - int batch_size = THCudaTensor_size(state, bottom_grad, 0); - // data height - int data_height = THCudaTensor_size(state, bottom_grad, 2); - // data width - int data_width = THCudaTensor_size(state, bottom_grad, 3); - // Number of channels - int num_channels = THCudaTensor_size(state, bottom_grad, 1); - - cudaStream_t stream = THCState_getCurrentStream(state); - ROIAlignBackwardLaucher( - top_grad_flat, spatial_scale, batch_size, num_rois, data_height, - data_width, num_channels, aligned_height, - aligned_width, rois_flat, - bottom_grad_flat, stream); - - return 1; -} diff --git a/lib/model/roi_align/src/roi_align_cuda.h b/lib/model/roi_align/src/roi_align_cuda.h deleted file mode 100644 index 97bd08d9..00000000 --- a/lib/model/roi_align/src/roi_align_cuda.h +++ /dev/null @@ -1,5 +0,0 @@ -int roi_align_forward_cuda(int aligned_height, int aligned_width, float spatial_scale, - THCudaTensor * features, THCudaTensor * rois, THCudaTensor * output); - -int roi_align_backward_cuda(int aligned_height, int aligned_width, float spatial_scale, - THCudaTensor * top_grad, THCudaTensor * rois, THCudaTensor * bottom_grad); diff --git a/lib/model/roi_align/src/roi_align_kernel.cu b/lib/model/roi_align/src/roi_align_kernel.cu deleted file mode 100644 index 1ddc6bc6..00000000 --- a/lib/model/roi_align/src/roi_align_kernel.cu +++ /dev/null @@ -1,167 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include "roi_align_kernel.h" - -#define CUDA_1D_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ - i += blockDim.x * gridDim.x) - - - __global__ void ROIAlignForward(const int nthreads, const float* bottom_data, const float spatial_scale, const int height, const int width, - const int channels, const int aligned_height, const int aligned_width, const float* bottom_rois, float* top_data) { - CUDA_1D_KERNEL_LOOP(index, nthreads) { - // (n, c, ph, pw) is an element in the aligned output - // int n = index; - // int pw = n % aligned_width; - // n /= aligned_width; - // int ph = n % aligned_height; - // n /= aligned_height; - // int c = n % channels; - // n /= channels; - - int pw = index % aligned_width; - int ph = (index / aligned_width) % aligned_height; - int c = (index / aligned_width / aligned_height) % channels; - int n = index / aligned_width / aligned_height / channels; - - // bottom_rois += n * 5; - float roi_batch_ind = bottom_rois[n * 5 + 0]; - float roi_start_w = bottom_rois[n * 5 + 1] * spatial_scale; - float roi_start_h = bottom_rois[n * 5 + 2] * spatial_scale; - float roi_end_w = bottom_rois[n * 5 + 3] * spatial_scale; - float roi_end_h = bottom_rois[n * 5 + 4] * spatial_scale; - - // Force malformed ROIs to be 1x1 - float roi_width = fmaxf(roi_end_w - roi_start_w + 1., 0.); - float roi_height = fmaxf(roi_end_h - roi_start_h + 1., 0.); - float bin_size_h = roi_height / (aligned_height - 1.); - float bin_size_w = roi_width / (aligned_width - 1.); - - float h = (float)(ph) * bin_size_h + roi_start_h; - float w = (float)(pw) * bin_size_w + roi_start_w; - - int hstart = fminf(floor(h), height - 2); - int wstart = fminf(floor(w), width - 2); - - int img_start = roi_batch_ind * channels * height * width; - - // bilinear interpolation - if (h < 0 || h >= height || w < 0 || w >= width) { - top_data[index] = 0.; - } else { - float h_ratio = h - (float)(hstart); - float w_ratio = w - (float)(wstart); - int upleft = img_start + (c * height + hstart) * width + wstart; - int upright = upleft + 1; - int downleft = upleft + width; - int downright = downleft + 1; - - top_data[index] = bottom_data[upleft] * (1. - h_ratio) * (1. - w_ratio) - + bottom_data[upright] * (1. - h_ratio) * w_ratio - + bottom_data[downleft] * h_ratio * (1. - w_ratio) - + bottom_data[downright] * h_ratio * w_ratio; - } - } - } - - - int ROIAlignForwardLaucher(const float* bottom_data, const float spatial_scale, const int num_rois, const int height, const int width, - const int channels, const int aligned_height, const int aligned_width, const float* bottom_rois, float* top_data, cudaStream_t stream) { - const int kThreadsPerBlock = 1024; - const int output_size = num_rois * aligned_height * aligned_width * channels; - cudaError_t err; - - - ROIAlignForward<<<(output_size + kThreadsPerBlock - 1) / kThreadsPerBlock, kThreadsPerBlock, 0, stream>>>( - output_size, bottom_data, spatial_scale, height, width, channels, - aligned_height, aligned_width, bottom_rois, top_data); - - err = cudaGetLastError(); - if(cudaSuccess != err) { - fprintf( stderr, "cudaCheckError() failed : %s\n", cudaGetErrorString( err ) ); - exit( -1 ); - } - - return 1; - } - - - __global__ void ROIAlignBackward(const int nthreads, const float* top_diff, const float spatial_scale, const int height, const int width, - const int channels, const int aligned_height, const int aligned_width, float* bottom_diff, const float* bottom_rois) { - CUDA_1D_KERNEL_LOOP(index, nthreads) { - - // (n, c, ph, pw) is an element in the aligned output - int pw = index % aligned_width; - int ph = (index / aligned_width) % aligned_height; - int c = (index / aligned_width / aligned_height) % channels; - int n = index / aligned_width / aligned_height / channels; - - float roi_batch_ind = bottom_rois[n * 5 + 0]; - float roi_start_w = bottom_rois[n * 5 + 1] * spatial_scale; - float roi_start_h = bottom_rois[n * 5 + 2] * spatial_scale; - float roi_end_w = bottom_rois[n * 5 + 3] * spatial_scale; - float roi_end_h = bottom_rois[n * 5 + 4] * spatial_scale; - /* int roi_start_w = round(bottom_rois[1] * spatial_scale); */ - /* int roi_start_h = round(bottom_rois[2] * spatial_scale); */ - /* int roi_end_w = round(bottom_rois[3] * spatial_scale); */ - /* int roi_end_h = round(bottom_rois[4] * spatial_scale); */ - - // Force malformed ROIs to be 1x1 - float roi_width = fmaxf(roi_end_w - roi_start_w + 1., 0.); - float roi_height = fmaxf(roi_end_h - roi_start_h + 1., 0.); - float bin_size_h = roi_height / (aligned_height - 1.); - float bin_size_w = roi_width / (aligned_width - 1.); - - float h = (float)(ph) * bin_size_h + roi_start_h; - float w = (float)(pw) * bin_size_w + roi_start_w; - - int hstart = fminf(floor(h), height - 2); - int wstart = fminf(floor(w), width - 2); - - int img_start = roi_batch_ind * channels * height * width; - - // bilinear interpolation - if (!(h < 0 || h >= height || w < 0 || w >= width)) { - float h_ratio = h - (float)(hstart); - float w_ratio = w - (float)(wstart); - int upleft = img_start + (c * height + hstart) * width + wstart; - int upright = upleft + 1; - int downleft = upleft + width; - int downright = downleft + 1; - - atomicAdd(bottom_diff + upleft, top_diff[index] * (1. - h_ratio) * (1 - w_ratio)); - atomicAdd(bottom_diff + upright, top_diff[index] * (1. - h_ratio) * w_ratio); - atomicAdd(bottom_diff + downleft, top_diff[index] * h_ratio * (1 - w_ratio)); - atomicAdd(bottom_diff + downright, top_diff[index] * h_ratio * w_ratio); - } - } - } - - int ROIAlignBackwardLaucher(const float* top_diff, const float spatial_scale, const int batch_size, const int num_rois, const int height, const int width, - const int channels, const int aligned_height, const int aligned_width, const float* bottom_rois, float* bottom_diff, cudaStream_t stream) { - const int kThreadsPerBlock = 1024; - const int output_size = num_rois * aligned_height * aligned_width * channels; - cudaError_t err; - - ROIAlignBackward<<<(output_size + kThreadsPerBlock - 1) / kThreadsPerBlock, kThreadsPerBlock, 0, stream>>>( - output_size, top_diff, spatial_scale, height, width, channels, - aligned_height, aligned_width, bottom_diff, bottom_rois); - - err = cudaGetLastError(); - if(cudaSuccess != err) { - fprintf( stderr, "cudaCheckError() failed : %s\n", cudaGetErrorString( err ) ); - exit( -1 ); - } - - return 1; - } - - -#ifdef __cplusplus -} -#endif diff --git a/lib/model/roi_align/src/roi_align_kernel.h b/lib/model/roi_align/src/roi_align_kernel.h deleted file mode 100644 index bf8f1672..00000000 --- a/lib/model/roi_align/src/roi_align_kernel.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _ROI_ALIGN_KERNEL -#define _ROI_ALIGN_KERNEL - -#ifdef __cplusplus -extern "C" { -#endif - -__global__ void ROIAlignForward(const int nthreads, const float* bottom_data, - const float spatial_scale, const int height, const int width, - const int channels, const int aligned_height, const int aligned_width, - const float* bottom_rois, float* top_data); - -int ROIAlignForwardLaucher( - const float* bottom_data, const float spatial_scale, const int num_rois, const int height, - const int width, const int channels, const int aligned_height, - const int aligned_width, const float* bottom_rois, - float* top_data, cudaStream_t stream); - -__global__ void ROIAlignBackward(const int nthreads, const float* top_diff, - const float spatial_scale, const int height, const int width, - const int channels, const int aligned_height, const int aligned_width, - float* bottom_diff, const float* bottom_rois); - -int ROIAlignBackwardLaucher(const float* top_diff, const float spatial_scale, const int batch_size, const int num_rois, - const int height, const int width, const int channels, const int aligned_height, - const int aligned_width, const float* bottom_rois, - float* bottom_diff, cudaStream_t stream); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/lib/model/roi_crop/__init__.py b/lib/model/roi_crop/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/roi_crop/_ext/__init__.py b/lib/model/roi_crop/_ext/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/roi_crop/_ext/crop_resize/__init__.py b/lib/model/roi_crop/_ext/crop_resize/__init__.py deleted file mode 100644 index 95ca1995..00000000 --- a/lib/model/roi_crop/_ext/crop_resize/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ - -from torch.utils.ffi import _wrap_function -from ._crop_resize import lib as _lib, ffi as _ffi - -__all__ = [] -def _import_symbols(locals): - for symbol in dir(_lib): - fn = getattr(_lib, symbol) - locals[symbol] = _wrap_function(fn, _ffi) - __all__.append(symbol) - -_import_symbols(locals()) diff --git a/lib/model/roi_crop/_ext/crop_resize/_crop_resize.so b/lib/model/roi_crop/_ext/crop_resize/_crop_resize.so deleted file mode 100755 index 9baf6615c37b3a600f3315c0297d00b55c143846..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 159103 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 E5Ac0#_y7O^ diff --git a/lib/model/roi_crop/_ext/roi_crop/__init__.py b/lib/model/roi_crop/_ext/roi_crop/__init__.py deleted file mode 100644 index a6423514..00000000 --- a/lib/model/roi_crop/_ext/roi_crop/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ - -from torch.utils.ffi import _wrap_function -from ._roi_crop import lib as _lib, ffi as _ffi - -__all__ = [] -def _import_symbols(locals): - for symbol in dir(_lib): - fn = getattr(_lib, symbol) - if callable(fn): - locals[symbol] = _wrap_function(fn, _ffi) - else: - locals[symbol] = fn - __all__.append(symbol) - -_import_symbols(locals()) diff --git a/lib/model/roi_crop/build.py b/lib/model/roi_crop/build.py deleted file mode 100644 index 964055a4..00000000 --- a/lib/model/roi_crop/build.py +++ /dev/null @@ -1,36 +0,0 @@ -from __future__ import print_function -import os -import torch -from torch.utils.ffi import create_extension - -#this_file = os.path.dirname(__file__) - -sources = ['src/roi_crop.c'] -headers = ['src/roi_crop.h'] -defines = [] -with_cuda = False - -if torch.cuda.is_available(): - print('Including CUDA code.') - sources += ['src/roi_crop_cuda.c'] - headers += ['src/roi_crop_cuda.h'] - defines += [('WITH_CUDA', None)] - with_cuda = True - -this_file = os.path.dirname(os.path.realpath(__file__)) -print(this_file) -extra_objects = ['src/roi_crop_cuda_kernel.cu.o'] -extra_objects = [os.path.join(this_file, fname) for fname in extra_objects] - -ffi = create_extension( - '_ext.roi_crop', - headers=headers, - sources=sources, - define_macros=defines, - relative_to=__file__, - with_cuda=with_cuda, - extra_objects=extra_objects -) - -if __name__ == '__main__': - ffi.build() diff --git a/lib/model/roi_crop/functions/__init__.py b/lib/model/roi_crop/functions/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/roi_crop/functions/crop_resize.py b/lib/model/roi_crop/functions/crop_resize.py deleted file mode 100644 index 1916c8fb..00000000 --- a/lib/model/roi_crop/functions/crop_resize.py +++ /dev/null @@ -1,37 +0,0 @@ -# functions/add.py -import torch -from torch.autograd import Function -from .._ext import roi_crop -from cffi import FFI -ffi = FFI() - -class RoICropFunction(Function): - def forward(self, input1, input2): - self.input1 = input1 - self.input2 = input2 - self.device_c = ffi.new("int *") - output = torch.zeros(input2.size()[0], input1.size()[1], input2.size()[1], input2.size()[2]) - #print('decice %d' % torch.cuda.current_device()) - if input1.is_cuda: - self.device = torch.cuda.current_device() - else: - self.device = -1 - self.device_c[0] = self.device - if not input1.is_cuda: - roi_crop.BilinearSamplerBHWD_updateOutput(input1, input2, output) - else: - output = output.cuda(self.device) - roi_crop.BilinearSamplerBHWD_updateOutput_cuda(input1, input2, output) - return output - - def backward(self, grad_output): - grad_input1 = torch.zeros(self.input1.size()) - grad_input2 = torch.zeros(self.input2.size()) - #print('backward decice %d' % self.device) - if not grad_output.is_cuda: - roi_crop.BilinearSamplerBHWD_updateGradInput(self.input1, self.input2, grad_input1, grad_input2, grad_output) - else: - grad_input1 = grad_input1.cuda(self.device) - grad_input2 = grad_input2.cuda(self.device) - roi_crop.BilinearSamplerBHWD_updateGradInput_cuda(self.input1, self.input2, grad_input1, grad_input2, grad_output) - return grad_input1, grad_input2 diff --git a/lib/model/roi_crop/functions/gridgen.py b/lib/model/roi_crop/functions/gridgen.py deleted file mode 100644 index 5fbbed34..00000000 --- a/lib/model/roi_crop/functions/gridgen.py +++ /dev/null @@ -1,46 +0,0 @@ -# functions/add.py -import torch -from torch.autograd import Function -import numpy as np - - -class AffineGridGenFunction(Function): - def __init__(self, height, width,lr=1): - super(AffineGridGenFunction, self).__init__() - self.lr = lr - self.height, self.width = height, width - self.grid = np.zeros( [self.height, self.width, 3], dtype=np.float32) - self.grid[:,:,0] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/(self.height)), 0), repeats = self.width, axis = 0).T, 0) - self.grid[:,:,1] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/(self.width)), 0), repeats = self.height, axis = 0), 0) - # self.grid[:,:,0] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/(self.height - 1)), 0), repeats = self.width, axis = 0).T, 0) - # self.grid[:,:,1] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/(self.width - 1)), 0), repeats = self.height, axis = 0), 0) - self.grid[:,:,2] = np.ones([self.height, width]) - self.grid = torch.from_numpy(self.grid.astype(np.float32)) - #print(self.grid) - - def forward(self, input1): - self.input1 = input1 - output = input1.new(torch.Size([input1.size(0)]) + self.grid.size()).zero_() - self.batchgrid = input1.new(torch.Size([input1.size(0)]) + self.grid.size()).zero_() - for i in range(input1.size(0)): - self.batchgrid[i] = self.grid.astype(self.batchgrid[i]) - - # if input1.is_cuda: - # self.batchgrid = self.batchgrid.cuda() - # output = output.cuda() - - for i in range(input1.size(0)): - output = torch.bmm(self.batchgrid.view(-1, self.height*self.width, 3), torch.transpose(input1, 1, 2)).view(-1, self.height, self.width, 2) - - return output - - def backward(self, grad_output): - - grad_input1 = self.input1.new(self.input1.size()).zero_() - - # if grad_output.is_cuda: - # self.batchgrid = self.batchgrid.cuda() - # grad_input1 = grad_input1.cuda() - - grad_input1 = torch.baddbmm(grad_input1, torch.transpose(grad_output.view(-1, self.height*self.width, 2), 1,2), self.batchgrid.view(-1, self.height*self.width, 3)) - return grad_input1 diff --git a/lib/model/roi_crop/functions/roi_crop.py b/lib/model/roi_crop/functions/roi_crop.py deleted file mode 100644 index 5092f6e9..00000000 --- a/lib/model/roi_crop/functions/roi_crop.py +++ /dev/null @@ -1,21 +0,0 @@ -# functions/add.py -import torch -from torch.autograd import Function -from .._ext import roi_crop -import pdb - -class RoICropFunction(Function): - def forward(self, input1, input2): - self.input1 = input1.clone() - self.input2 = input2.clone() - output = input2.new(input2.size()[0], input1.size()[1], input2.size()[1], input2.size()[2]).zero_() - assert output.get_device() == input1.get_device(), "output and input1 must on the same device" - assert output.get_device() == input2.get_device(), "output and input2 must on the same device" - roi_crop.BilinearSamplerBHWD_updateOutput_cuda(input1, input2, output) - return output - - def backward(self, grad_output): - grad_input1 = self.input1.new(self.input1.size()).zero_() - grad_input2 = self.input2.new(self.input2.size()).zero_() - roi_crop.BilinearSamplerBHWD_updateGradInput_cuda(self.input1, self.input2, grad_input1, grad_input2, grad_output) - return grad_input1, grad_input2 diff --git a/lib/model/roi_crop/make.sh b/lib/model/roi_crop/make.sh deleted file mode 100755 index 7f122cf2..00000000 --- a/lib/model/roi_crop/make.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -CUDA_PATH=/usr/local/cuda/ - -cd src -echo "Compiling my_lib kernels by nvcc..." -nvcc -c -o roi_crop_cuda_kernel.cu.o roi_crop_cuda_kernel.cu -x cu -Xcompiler -fPIC -arch=sm_52 - -cd ../ -python3 build.py diff --git a/lib/model/roi_crop/modules/__init__.py b/lib/model/roi_crop/modules/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/roi_crop/modules/gridgen.py b/lib/model/roi_crop/modules/gridgen.py deleted file mode 100644 index 37baf487..00000000 --- a/lib/model/roi_crop/modules/gridgen.py +++ /dev/null @@ -1,415 +0,0 @@ -from torch.nn.modules.module import Module -import torch -from torch.autograd import Variable -import numpy as np -from ..functions.gridgen import AffineGridGenFunction - -import pyximport -pyximport.install(setup_args={"include_dirs":np.get_include()}, - reload_support=True) - - -class _AffineGridGen(Module): - def __init__(self, height, width, lr = 1, aux_loss = False): - super(_AffineGridGen, self).__init__() - self.height, self.width = height, width - self.aux_loss = aux_loss - self.f = AffineGridGenFunction(self.height, self.width, lr=lr) - self.lr = lr - def forward(self, input): - # if not self.aux_loss: - return self.f(input) - # else: - # identity = torch.from_numpy(np.array([[1,0,0], [0,1,0]], dtype=np.float32)) - # batch_identity = torch.zeros([input.size(0), 2,3]) - # for i in range(input.size(0)): - # batch_identity[i] = identity - # batch_identity = Variable(batch_identity) - # loss = torch.mul(input - batch_identity, input - batch_identity) - # loss = torch.sum(loss,1) - # loss = torch.sum(loss,2) - - # return self.f(input), loss.view(-1,1) - - -# class CylinderGridGen(Module): -# def __init__(self, height, width, lr = 1, aux_loss = False): -# super(CylinderGridGen, self).__init__() -# self.height, self.width = height, width -# self.aux_loss = aux_loss -# self.f = CylinderGridGenFunction(self.height, self.width, lr=lr) -# self.lr = lr -# def forward(self, input): - -# if not self.aux_loss: -# return self.f(input) -# else: -# return self.f(input), torch.mul(input, input).view(-1,1) - - -class AffineGridGenV2(Module): - def __init__(self, height, width, lr = 1, aux_loss = False): - super(AffineGridGenV2, self).__init__() - self.height, self.width = height, width - self.aux_loss = aux_loss - self.lr = lr - - self.grid = np.zeros( [self.height, self.width, 3], dtype=np.float32) - self.grid[:,:,0] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.height), 0), repeats = self.width, axis = 0).T, 0) - self.grid[:,:,1] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.width), 0), repeats = self.height, axis = 0), 0) - self.grid[:,:,2] = np.ones([self.height, width]) - self.grid = torch.from_numpy(self.grid.astype(np.float32)) - - - def forward(self, input1): - self.batchgrid = torch.zeros(torch.Size([input1.size(0)]) + self.grid.size()) - - for i in range(input1.size(0)): - self.batchgrid[i] = self.grid - self.batchgrid = Variable(self.batchgrid) - - if input1.is_cuda: - self.batchgrid = self.batchgrid.cuda() - - output = torch.bmm(self.batchgrid.view(-1, self.height*self.width, 3), torch.transpose(input1, 1, 2)).view(-1, self.height, self.width, 2) - - return output - - -class CylinderGridGenV2(Module): - def __init__(self, height, width, lr = 1): - super(CylinderGridGenV2, self).__init__() - self.height, self.width = height, width - self.lr = lr - self.grid = np.zeros( [self.height, self.width, 3], dtype=np.float32) - self.grid[:,:,0] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.height), 0), repeats = self.width, axis = 0).T, 0) - self.grid[:,:,1] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.width), 0), repeats = self.height, axis = 0), 0) - self.grid[:,:,2] = np.ones([self.height, width]) - self.grid = torch.from_numpy(self.grid.astype(np.float32)) - def forward(self, input): - self.batchgrid = torch.zeros(torch.Size([input.size(0)]) + self.grid.size() ) - #print(self.batchgrid.size()) - for i in range(input.size(0)): - self.batchgrid[i,:,:,:] = self.grid - self.batchgrid = Variable(self.batchgrid) - - #print(self.batchgrid.size()) - - input_u = input.view(-1,1,1,1).repeat(1,self.height, self.width,1) - #print(input_u.requires_grad, self.batchgrid) - - output0 = self.batchgrid[:,:,:,0:1] - output1 = torch.atan(torch.tan(np.pi/2.0*(self.batchgrid[:,:,:,1:2] + self.batchgrid[:,:,:,2:] * input_u[:,:,:,:]))) /(np.pi/2) - #print(output0.size(), output1.size()) - - output = torch.cat([output0, output1], 3) - return output - - -class DenseAffineGridGen(Module): - def __init__(self, height, width, lr = 1, aux_loss = False): - super(DenseAffineGridGen, self).__init__() - self.height, self.width = height, width - self.aux_loss = aux_loss - self.lr = lr - - self.grid = np.zeros( [self.height, self.width, 3], dtype=np.float32) - self.grid[:,:,0] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.height), 0), repeats = self.width, axis = 0).T, 0) - self.grid[:,:,1] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.width), 0), repeats = self.height, axis = 0), 0) - self.grid[:,:,2] = np.ones([self.height, width]) - self.grid = torch.from_numpy(self.grid.astype(np.float32)) - - - def forward(self, input1): - self.batchgrid = torch.zeros(torch.Size([input1.size(0)]) + self.grid.size()) - - for i in range(input1.size(0)): - self.batchgrid[i] = self.grid - - self.batchgrid = Variable(self.batchgrid) - #print self.batchgrid, input1[:,:,:,0:3] - #print self.batchgrid, input1[:,:,:,4:6] - x = torch.mul(self.batchgrid, input1[:,:,:,0:3]) - y = torch.mul(self.batchgrid, input1[:,:,:,3:6]) - - output = torch.cat([torch.sum(x,3),torch.sum(y,3)], 3) - return output - - - - -class DenseAffine3DGridGen(Module): - def __init__(self, height, width, lr = 1, aux_loss = False): - super(DenseAffine3DGridGen, self).__init__() - self.height, self.width = height, width - self.aux_loss = aux_loss - self.lr = lr - - self.grid = np.zeros( [self.height, self.width, 3], dtype=np.float32) - self.grid[:,:,0] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.height), 0), repeats = self.width, axis = 0).T, 0) - self.grid[:,:,1] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.width), 0), repeats = self.height, axis = 0), 0) - self.grid[:,:,2] = np.ones([self.height, width]) - self.grid = torch.from_numpy(self.grid.astype(np.float32)) - - self.theta = self.grid[:,:,0] * np.pi/2 + np.pi/2 - self.phi = self.grid[:,:,1] * np.pi - - self.x = torch.sin(self.theta) * torch.cos(self.phi) - self.y = torch.sin(self.theta) * torch.sin(self.phi) - self.z = torch.cos(self.theta) - - self.grid3d = torch.from_numpy(np.zeros( [self.height, self.width, 4], dtype=np.float32)) - - self.grid3d[:,:,0] = self.x - self.grid3d[:,:,1] = self.y - self.grid3d[:,:,2] = self.z - self.grid3d[:,:,3] = self.grid[:,:,2] - - - def forward(self, input1): - self.batchgrid3d = torch.zeros(torch.Size([input1.size(0)]) + self.grid3d.size()) - - for i in range(input1.size(0)): - self.batchgrid3d[i] = self.grid3d - - self.batchgrid3d = Variable(self.batchgrid3d) - #print(self.batchgrid3d) - - x = torch.sum(torch.mul(self.batchgrid3d, input1[:,:,:,0:4]), 3) - y = torch.sum(torch.mul(self.batchgrid3d, input1[:,:,:,4:8]), 3) - z = torch.sum(torch.mul(self.batchgrid3d, input1[:,:,:,8:]), 3) - #print(x) - r = torch.sqrt(x**2 + y**2 + z**2) + 1e-5 - - #print(r) - theta = torch.acos(z/r)/(np.pi/2) - 1 - #phi = torch.atan(y/x) - phi = torch.atan(y/(x + 1e-5)) + np.pi * x.lt(0).type(torch.FloatTensor) * (y.ge(0).type(torch.FloatTensor) - y.lt(0).type(torch.FloatTensor)) - phi = phi/np.pi - - - output = torch.cat([theta,phi], 3) - - return output - - - - - -class DenseAffine3DGridGen_rotate(Module): - def __init__(self, height, width, lr = 1, aux_loss = False): - super(DenseAffine3DGridGen_rotate, self).__init__() - self.height, self.width = height, width - self.aux_loss = aux_loss - self.lr = lr - - self.grid = np.zeros( [self.height, self.width, 3], dtype=np.float32) - self.grid[:,:,0] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.height), 0), repeats = self.width, axis = 0).T, 0) - self.grid[:,:,1] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.width), 0), repeats = self.height, axis = 0), 0) - self.grid[:,:,2] = np.ones([self.height, width]) - self.grid = torch.from_numpy(self.grid.astype(np.float32)) - - self.theta = self.grid[:,:,0] * np.pi/2 + np.pi/2 - self.phi = self.grid[:,:,1] * np.pi - - self.x = torch.sin(self.theta) * torch.cos(self.phi) - self.y = torch.sin(self.theta) * torch.sin(self.phi) - self.z = torch.cos(self.theta) - - self.grid3d = torch.from_numpy(np.zeros( [self.height, self.width, 4], dtype=np.float32)) - - self.grid3d[:,:,0] = self.x - self.grid3d[:,:,1] = self.y - self.grid3d[:,:,2] = self.z - self.grid3d[:,:,3] = self.grid[:,:,2] - - - def forward(self, input1, input2): - self.batchgrid3d = torch.zeros(torch.Size([input1.size(0)]) + self.grid3d.size()) - - for i in range(input1.size(0)): - self.batchgrid3d[i] = self.grid3d - - self.batchgrid3d = Variable(self.batchgrid3d) - - self.batchgrid = torch.zeros(torch.Size([input1.size(0)]) + self.grid.size()) - - for i in range(input1.size(0)): - self.batchgrid[i] = self.grid - - self.batchgrid = Variable(self.batchgrid) - - #print(self.batchgrid3d) - - x = torch.sum(torch.mul(self.batchgrid3d, input1[:,:,:,0:4]), 3) - y = torch.sum(torch.mul(self.batchgrid3d, input1[:,:,:,4:8]), 3) - z = torch.sum(torch.mul(self.batchgrid3d, input1[:,:,:,8:]), 3) - #print(x) - r = torch.sqrt(x**2 + y**2 + z**2) + 1e-5 - - #print(r) - theta = torch.acos(z/r)/(np.pi/2) - 1 - #phi = torch.atan(y/x) - phi = torch.atan(y/(x + 1e-5)) + np.pi * x.lt(0).type(torch.FloatTensor) * (y.ge(0).type(torch.FloatTensor) - y.lt(0).type(torch.FloatTensor)) - phi = phi/np.pi - - input_u = input2.view(-1,1,1,1).repeat(1,self.height, self.width,1) - - output = torch.cat([theta,phi], 3) - - output1 = torch.atan(torch.tan(np.pi/2.0*(output[:,:,:,1:2] + self.batchgrid[:,:,:,2:] * input_u[:,:,:,:]))) /(np.pi/2) - output2 = torch.cat([output[:,:,:,0:1], output1], 3) - - return output2 - - -class Depth3DGridGen(Module): - def __init__(self, height, width, lr = 1, aux_loss = False): - super(Depth3DGridGen, self).__init__() - self.height, self.width = height, width - self.aux_loss = aux_loss - self.lr = lr - - self.grid = np.zeros( [self.height, self.width, 3], dtype=np.float32) - self.grid[:,:,0] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.height), 0), repeats = self.width, axis = 0).T, 0) - self.grid[:,:,1] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.width), 0), repeats = self.height, axis = 0), 0) - self.grid[:,:,2] = np.ones([self.height, width]) - self.grid = torch.from_numpy(self.grid.astype(np.float32)) - - self.theta = self.grid[:,:,0] * np.pi/2 + np.pi/2 - self.phi = self.grid[:,:,1] * np.pi - - self.x = torch.sin(self.theta) * torch.cos(self.phi) - self.y = torch.sin(self.theta) * torch.sin(self.phi) - self.z = torch.cos(self.theta) - - self.grid3d = torch.from_numpy(np.zeros( [self.height, self.width, 4], dtype=np.float32)) - - self.grid3d[:,:,0] = self.x - self.grid3d[:,:,1] = self.y - self.grid3d[:,:,2] = self.z - self.grid3d[:,:,3] = self.grid[:,:,2] - - - def forward(self, depth, trans0, trans1, rotate): - self.batchgrid3d = torch.zeros(torch.Size([depth.size(0)]) + self.grid3d.size()) - - for i in range(depth.size(0)): - self.batchgrid3d[i] = self.grid3d - - self.batchgrid3d = Variable(self.batchgrid3d) - - self.batchgrid = torch.zeros(torch.Size([depth.size(0)]) + self.grid.size()) - - for i in range(depth.size(0)): - self.batchgrid[i] = self.grid - - self.batchgrid = Variable(self.batchgrid) - - x = self.batchgrid3d[:,:,:,0:1] * depth + trans0.view(-1,1,1,1).repeat(1, self.height, self.width, 1) - - y = self.batchgrid3d[:,:,:,1:2] * depth + trans1.view(-1,1,1,1).repeat(1, self.height, self.width, 1) - z = self.batchgrid3d[:,:,:,2:3] * depth - #print(x.size(), y.size(), z.size()) - r = torch.sqrt(x**2 + y**2 + z**2) + 1e-5 - - #print(r) - theta = torch.acos(z/r)/(np.pi/2) - 1 - #phi = torch.atan(y/x) - phi = torch.atan(y/(x + 1e-5)) + np.pi * x.lt(0).type(torch.FloatTensor) * (y.ge(0).type(torch.FloatTensor) - y.lt(0).type(torch.FloatTensor)) - phi = phi/np.pi - - #print(theta.size(), phi.size()) - - - input_u = rotate.view(-1,1,1,1).repeat(1,self.height, self.width,1) - - output = torch.cat([theta,phi], 3) - #print(output.size()) - - output1 = torch.atan(torch.tan(np.pi/2.0*(output[:,:,:,1:2] + self.batchgrid[:,:,:,2:] * input_u[:,:,:,:]))) /(np.pi/2) - output2 = torch.cat([output[:,:,:,0:1], output1], 3) - - return output2 - - - - - -class Depth3DGridGen_with_mask(Module): - def __init__(self, height, width, lr = 1, aux_loss = False, ray_tracing = False): - super(Depth3DGridGen_with_mask, self).__init__() - self.height, self.width = height, width - self.aux_loss = aux_loss - self.lr = lr - self.ray_tracing = ray_tracing - - self.grid = np.zeros( [self.height, self.width, 3], dtype=np.float32) - self.grid[:,:,0] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.height), 0), repeats = self.width, axis = 0).T, 0) - self.grid[:,:,1] = np.expand_dims(np.repeat(np.expand_dims(np.arange(-1, 1, 2.0/self.width), 0), repeats = self.height, axis = 0), 0) - self.grid[:,:,2] = np.ones([self.height, width]) - self.grid = torch.from_numpy(self.grid.astype(np.float32)) - - self.theta = self.grid[:,:,0] * np.pi/2 + np.pi/2 - self.phi = self.grid[:,:,1] * np.pi - - self.x = torch.sin(self.theta) * torch.cos(self.phi) - self.y = torch.sin(self.theta) * torch.sin(self.phi) - self.z = torch.cos(self.theta) - - self.grid3d = torch.from_numpy(np.zeros( [self.height, self.width, 4], dtype=np.float32)) - - self.grid3d[:,:,0] = self.x - self.grid3d[:,:,1] = self.y - self.grid3d[:,:,2] = self.z - self.grid3d[:,:,3] = self.grid[:,:,2] - - - def forward(self, depth, trans0, trans1, rotate): - self.batchgrid3d = torch.zeros(torch.Size([depth.size(0)]) + self.grid3d.size()) - - for i in range(depth.size(0)): - self.batchgrid3d[i] = self.grid3d - - self.batchgrid3d = Variable(self.batchgrid3d) - - self.batchgrid = torch.zeros(torch.Size([depth.size(0)]) + self.grid.size()) - - for i in range(depth.size(0)): - self.batchgrid[i] = self.grid - - self.batchgrid = Variable(self.batchgrid) - - if depth.is_cuda: - self.batchgrid = self.batchgrid.cuda() - self.batchgrid3d = self.batchgrid3d.cuda() - - - x_ = self.batchgrid3d[:,:,:,0:1] * depth + trans0.view(-1,1,1,1).repeat(1, self.height, self.width, 1) - - y_ = self.batchgrid3d[:,:,:,1:2] * depth + trans1.view(-1,1,1,1).repeat(1, self.height, self.width, 1) - z = self.batchgrid3d[:,:,:,2:3] * depth - #print(x.size(), y.size(), z.size()) - - rotate_z = rotate.view(-1,1,1,1).repeat(1,self.height, self.width,1) * np.pi - - x = x_ * torch.cos(rotate_z) - y_ * torch.sin(rotate_z) - y = x_ * torch.sin(rotate_z) + y_ * torch.cos(rotate_z) - - - r = torch.sqrt(x**2 + y**2 + z**2) + 1e-5 - - #print(r) - theta = torch.acos(z/r)/(np.pi/2) - 1 - #phi = torch.atan(y/x) - - if depth.is_cuda: - phi = torch.atan(y/(x + 1e-5)) + np.pi * x.lt(0).type(torch.cuda.FloatTensor) * (y.ge(0).type(torch.cuda.FloatTensor) - y.lt(0).type(torch.cuda.FloatTensor)) - else: - phi = torch.atan(y/(x + 1e-5)) + np.pi * x.lt(0).type(torch.FloatTensor) * (y.ge(0).type(torch.FloatTensor) - y.lt(0).type(torch.FloatTensor)) - - - phi = phi/np.pi - - output = torch.cat([theta,phi], 3) - return output diff --git a/lib/model/roi_crop/modules/roi_crop.py b/lib/model/roi_crop/modules/roi_crop.py deleted file mode 100644 index f5f1c7f1..00000000 --- a/lib/model/roi_crop/modules/roi_crop.py +++ /dev/null @@ -1,8 +0,0 @@ -from torch.nn.modules.module import Module -from ..functions.roi_crop import RoICropFunction - -class _RoICrop(Module): - def __init__(self, layout = 'BHWD'): - super(_RoICrop, self).__init__() - def forward(self, input1, input2): - return RoICropFunction()(input1, input2) diff --git a/lib/model/roi_crop/src/roi_crop.c b/lib/model/roi_crop/src/roi_crop.c deleted file mode 100644 index 4f68a9c0..00000000 --- a/lib/model/roi_crop/src/roi_crop.c +++ /dev/null @@ -1,499 +0,0 @@ -#include -#include -#include - -#define real float - -int BilinearSamplerBHWD_updateOutput(THFloatTensor *inputImages, THFloatTensor *grids, THFloatTensor *output) -{ - - int batchsize = THFloatTensor_size(inputImages, 0); - int inputImages_height = THFloatTensor_size(inputImages, 1); - int inputImages_width = THFloatTensor_size(inputImages, 2); - int output_height = THFloatTensor_size(output, 1); - int output_width = THFloatTensor_size(output, 2); - int inputImages_channels = THFloatTensor_size(inputImages, 3); - - int output_strideBatch = THFloatTensor_stride(output, 0); - int output_strideHeight = THFloatTensor_stride(output, 1); - int output_strideWidth = THFloatTensor_stride(output, 2); - - int inputImages_strideBatch = THFloatTensor_stride(inputImages, 0); - int inputImages_strideHeight = THFloatTensor_stride(inputImages, 1); - int inputImages_strideWidth = THFloatTensor_stride(inputImages, 2); - - int grids_strideBatch = THFloatTensor_stride(grids, 0); - int grids_strideHeight = THFloatTensor_stride(grids, 1); - int grids_strideWidth = THFloatTensor_stride(grids, 2); - - - real *inputImages_data, *output_data, *grids_data; - inputImages_data = THFloatTensor_data(inputImages); - output_data = THFloatTensor_data(output); - grids_data = THFloatTensor_data(grids); - - int b, yOut, xOut; - - for(b=0; b < batchsize; b++) - { - for(yOut=0; yOut < output_height; yOut++) - { - for(xOut=0; xOut < output_width; xOut++) - { - //read the grid - real yf = grids_data[b*grids_strideBatch + yOut*grids_strideHeight + xOut*grids_strideWidth]; - real xf = grids_data[b*grids_strideBatch + yOut*grids_strideHeight + xOut*grids_strideWidth + 1]; - - // get the weights for interpolation - int yInTopLeft, xInTopLeft; - real yWeightTopLeft, xWeightTopLeft; - - real xcoord = (xf + 1) * (inputImages_width - 1) / 2; - xInTopLeft = floor(xcoord); - xWeightTopLeft = 1 - (xcoord - xInTopLeft); - - real ycoord = (yf + 1) * (inputImages_height - 1) / 2; - yInTopLeft = floor(ycoord); - yWeightTopLeft = 1 - (ycoord - yInTopLeft); - - - - const int outAddress = output_strideBatch * b + output_strideHeight * yOut + output_strideWidth * xOut; - const int inTopLeftAddress = inputImages_strideBatch * b + inputImages_strideHeight * yInTopLeft + inputImages_strideWidth * xInTopLeft; - const int inTopRightAddress = inTopLeftAddress + inputImages_strideWidth; - const int inBottomLeftAddress = inTopLeftAddress + inputImages_strideHeight; - const int inBottomRightAddress = inBottomLeftAddress + inputImages_strideWidth; - - real v=0; - real inTopLeft=0; - real inTopRight=0; - real inBottomLeft=0; - real inBottomRight=0; - - // we are careful with the boundaries - bool topLeftIsIn = xInTopLeft >= 0 && xInTopLeft <= inputImages_width-1 && yInTopLeft >= 0 && yInTopLeft <= inputImages_height-1; - bool topRightIsIn = xInTopLeft+1 >= 0 && xInTopLeft+1 <= inputImages_width-1 && yInTopLeft >= 0 && yInTopLeft <= inputImages_height-1; - bool bottomLeftIsIn = xInTopLeft >= 0 && xInTopLeft <= inputImages_width-1 && yInTopLeft+1 >= 0 && yInTopLeft+1 <= inputImages_height-1; - bool bottomRightIsIn = xInTopLeft+1 >= 0 && xInTopLeft+1 <= inputImages_width-1 && yInTopLeft+1 >= 0 && yInTopLeft+1 <= inputImages_height-1; - - int t; - // interpolation happens here - for(t=0; t= 0 && xInTopLeft <= inputImages_width-1 && yInTopLeft >= 0 && yInTopLeft <= inputImages_height-1; - bool topRightIsIn = xInTopLeft+1 >= 0 && xInTopLeft+1 <= inputImages_width-1 && yInTopLeft >= 0 && yInTopLeft <= inputImages_height-1; - bool bottomLeftIsIn = xInTopLeft >= 0 && xInTopLeft <= inputImages_width-1 && yInTopLeft+1 >= 0 && yInTopLeft+1 <= inputImages_height-1; - bool bottomRightIsIn = xInTopLeft+1 >= 0 && xInTopLeft+1 <= inputImages_width-1 && yInTopLeft+1 >= 0 && yInTopLeft+1 <= inputImages_height-1; - - int t; - - for(t=0; t= 0 && xInTopLeft <= inputImages_width-1 && yInTopLeft >= 0 && yInTopLeft <= inputImages_height-1; - bool topRightIsIn = xInTopLeft+1 >= 0 && xInTopLeft+1 <= inputImages_width-1 && yInTopLeft >= 0 && yInTopLeft <= inputImages_height-1; - bool bottomLeftIsIn = xInTopLeft >= 0 && xInTopLeft <= inputImages_width-1 && yInTopLeft+1 >= 0 && yInTopLeft+1 <= inputImages_height-1; - bool bottomRightIsIn = xInTopLeft+1 >= 0 && xInTopLeft+1 <= inputImages_width-1 && yInTopLeft+1 >= 0 && yInTopLeft+1 <= inputImages_height-1; - - int t; - // interpolation happens here - for(t=0; t= 0 && xInTopLeft <= inputImages_width-1 && yInTopLeft >= 0 && yInTopLeft <= inputImages_height-1; - bool topRightIsIn = xInTopLeft+1 >= 0 && xInTopLeft+1 <= inputImages_width-1 && yInTopLeft >= 0 && yInTopLeft <= inputImages_height-1; - bool bottomLeftIsIn = xInTopLeft >= 0 && xInTopLeft <= inputImages_width-1 && yInTopLeft+1 >= 0 && yInTopLeft+1 <= inputImages_height-1; - bool bottomRightIsIn = xInTopLeft+1 >= 0 && xInTopLeft+1 <= inputImages_width-1 && yInTopLeft+1 >= 0 && yInTopLeft+1 <= inputImages_height-1; - - int t; - - for(t=0; t -#include -#include -#include "roi_crop_cuda_kernel.h" - -#define real float - -// this symbol will be resolved automatically from PyTorch libs -extern THCState *state; - -// Bilinear sampling is done in BHWD (coalescing is not obvious in BDHW) -// we assume BHWD format in inputImages -// we assume BHW(YX) format on grids - -int BilinearSamplerBHWD_updateOutput_cuda(THCudaTensor *inputImages, THCudaTensor *grids, THCudaTensor *output){ -// THCState *state = getCutorchState(L); -// THCudaTensor *inputImages = (THCudaTensor *)luaT_checkudata(L, 2, "torch.CudaTensor"); -// THCudaTensor *grids = (THCudaTensor *)luaT_checkudata(L, 3, "torch.CudaTensor"); -// THCudaTensor *output = (THCudaTensor *)luaT_checkudata(L, 4, "torch.CudaTensor"); - - int success = 0; - success = BilinearSamplerBHWD_updateOutput_cuda_kernel(THCudaTensor_size(state, output, 1), - THCudaTensor_size(state, output, 3), - THCudaTensor_size(state, output, 2), - THCudaTensor_size(state, output, 0), - THCudaTensor_size(state, inputImages, 1), - THCudaTensor_size(state, inputImages, 2), - THCudaTensor_size(state, inputImages, 3), - THCudaTensor_size(state, inputImages, 0), - THCudaTensor_data(state, inputImages), - THCudaTensor_stride(state, inputImages, 0), - THCudaTensor_stride(state, inputImages, 1), - THCudaTensor_stride(state, inputImages, 2), - THCudaTensor_stride(state, inputImages, 3), - THCudaTensor_data(state, grids), - THCudaTensor_stride(state, grids, 0), - THCudaTensor_stride(state, grids, 3), - THCudaTensor_stride(state, grids, 1), - THCudaTensor_stride(state, grids, 2), - THCudaTensor_data(state, output), - THCudaTensor_stride(state, output, 0), - THCudaTensor_stride(state, output, 1), - THCudaTensor_stride(state, output, 2), - THCudaTensor_stride(state, output, 3), - THCState_getCurrentStream(state)); - - //check for errors - if (!success) { - THError("aborting"); - } - return 1; -} - -int BilinearSamplerBHWD_updateGradInput_cuda(THCudaTensor *inputImages, THCudaTensor *grids, THCudaTensor *gradInputImages, - THCudaTensor *gradGrids, THCudaTensor *gradOutput) -{ -// THCState *state = getCutorchState(L); -// THCudaTensor *inputImages = (THCudaTensor *)luaT_checkudata(L, 2, "torch.CudaTensor"); -// THCudaTensor *grids = (THCudaTensor *)luaT_checkudata(L, 3, "torch.CudaTensor"); -// THCudaTensor *gradInputImages = (THCudaTensor *)luaT_checkudata(L, 4, "torch.CudaTensor"); -// THCudaTensor *gradGrids = (THCudaTensor *)luaT_checkudata(L, 5, "torch.CudaTensor"); -// THCudaTensor *gradOutput = (THCudaTensor *)luaT_checkudata(L, 6, "torch.CudaTensor"); - - int success = 0; - success = BilinearSamplerBHWD_updateGradInput_cuda_kernel(THCudaTensor_size(state, gradOutput, 1), - THCudaTensor_size(state, gradOutput, 3), - THCudaTensor_size(state, gradOutput, 2), - THCudaTensor_size(state, gradOutput, 0), - THCudaTensor_size(state, inputImages, 1), - THCudaTensor_size(state, inputImages, 2), - THCudaTensor_size(state, inputImages, 3), - THCudaTensor_size(state, inputImages, 0), - THCudaTensor_data(state, inputImages), - THCudaTensor_stride(state, inputImages, 0), - THCudaTensor_stride(state, inputImages, 1), - THCudaTensor_stride(state, inputImages, 2), - THCudaTensor_stride(state, inputImages, 3), - THCudaTensor_data(state, grids), - THCudaTensor_stride(state, grids, 0), - THCudaTensor_stride(state, grids, 3), - THCudaTensor_stride(state, grids, 1), - THCudaTensor_stride(state, grids, 2), - THCudaTensor_data(state, gradInputImages), - THCudaTensor_stride(state, gradInputImages, 0), - THCudaTensor_stride(state, gradInputImages, 1), - THCudaTensor_stride(state, gradInputImages, 2), - THCudaTensor_stride(state, gradInputImages, 3), - THCudaTensor_data(state, gradGrids), - THCudaTensor_stride(state, gradGrids, 0), - THCudaTensor_stride(state, gradGrids, 3), - THCudaTensor_stride(state, gradGrids, 1), - THCudaTensor_stride(state, gradGrids, 2), - THCudaTensor_data(state, gradOutput), - THCudaTensor_stride(state, gradOutput, 0), - THCudaTensor_stride(state, gradOutput, 1), - THCudaTensor_stride(state, gradOutput, 2), - THCudaTensor_stride(state, gradOutput, 3), - THCState_getCurrentStream(state)); - - //check for errors - if (!success) { - THError("aborting"); - } - return 1; -} diff --git a/lib/model/roi_crop/src/roi_crop_cuda.h b/lib/model/roi_crop/src/roi_crop_cuda.h deleted file mode 100644 index 29085ef2..00000000 --- a/lib/model/roi_crop/src/roi_crop_cuda.h +++ /dev/null @@ -1,8 +0,0 @@ -// Bilinear sampling is done in BHWD (coalescing is not obvious in BDHW) -// we assume BHWD format in inputImages -// we assume BHW(YX) format on grids - -int BilinearSamplerBHWD_updateOutput_cuda(THCudaTensor *inputImages, THCudaTensor *grids, THCudaTensor *output); - -int BilinearSamplerBHWD_updateGradInput_cuda(THCudaTensor *inputImages, THCudaTensor *grids, THCudaTensor *gradInputImages, - THCudaTensor *gradGrids, THCudaTensor *gradOutput); diff --git a/lib/model/roi_crop/src/roi_crop_cuda_kernel.cu b/lib/model/roi_crop/src/roi_crop_cuda_kernel.cu deleted file mode 100644 index b1c20e4c..00000000 --- a/lib/model/roi_crop/src/roi_crop_cuda_kernel.cu +++ /dev/null @@ -1,330 +0,0 @@ -#include -#include -#include "roi_crop_cuda_kernel.h" - -#define real float - -// Bilinear sampling is done in BHWD (coalescing is not obvious in BDHW) -// we assume BHWD format in inputImages -// we assume BHW(YX) format on grids - -__device__ void getTopLeft(float x, int width, int& point, float& weight) -{ - /* for interpolation : - stores in point and weight : - - the x-coordinate of the pixel on the left (or y-coordinate of the upper pixel) - - the weight for interpolating - */ - - float xcoord = (x + 1) * (width - 1) / 2; - point = floor(xcoord); - weight = 1 - (xcoord - point); -} - -__device__ bool between(int value, int lowerBound, int upperBound) -{ - return (value >= lowerBound && value <= upperBound); -} - -__device__ void sumReduceShMem(volatile float s[]) -{ - /* obviously only works for 32 elements */ - /* sums up a shared memory array of 32 elements, stores it in s[0] */ - /* whole warp can then read first element (broadcasting) */ - if(threadIdx.x<16) { s[threadIdx.x] = s[threadIdx.x] + s[threadIdx.x+16]; } - if(threadIdx.x<8) { s[threadIdx.x] = s[threadIdx.x] + s[threadIdx.x+8]; } - if(threadIdx.x<4) { s[threadIdx.x] = s[threadIdx.x] + s[threadIdx.x+4]; } - if(threadIdx.x<2) { s[threadIdx.x] = s[threadIdx.x] + s[threadIdx.x+2]; } - if(threadIdx.x<1) { s[threadIdx.x] = s[threadIdx.x] + s[threadIdx.x+1]; } -} - -// CUDA: grid stride looping -#define CUDA_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ - i < (n); \ - i += blockDim.x * gridDim.x) - -__global__ void bilinearSamplingFromGrid(const int nthreads, float* inputImages_data, int inputImages_strideBatch, int inputImages_strideChannels, int inputImages_strideHeight, int inputImages_strideWidth, - float* grids_data, int grids_strideBatch, int grids_strideYX, int grids_strideHeight, int grids_strideWidth, - float* output_data, int output_strideBatch, int output_strideChannels, int output_strideHeight, int output_strideWidth, - int inputImages_channels, int inputImages_height, int inputImages_width, - int output_channels, int output_height, int output_width, int output_batchsize, - int roiPerImage) -{ - CUDA_KERNEL_LOOP(index, nthreads) - { - const int xOut = index % output_width; - const int yOut = (index / output_width) % output_height; - const int cOut = (index / output_width / output_height) % output_channels; - const int b = index / output_width / output_height / output_channels; - - const int width = inputImages_width; - const int height = inputImages_height; - - const int b_input = b / roiPerImage; - - float yf = grids_data[b*grids_strideBatch + yOut*grids_strideHeight + xOut*grids_strideWidth]; - float xf = grids_data[b*grids_strideBatch + yOut*grids_strideHeight + xOut*grids_strideWidth + 1]; - - int yInTopLeft, xInTopLeft; - float yWeightTopLeft, xWeightTopLeft; - getTopLeft(xf, inputImages_width, xInTopLeft, xWeightTopLeft); - getTopLeft(yf, inputImages_height, yInTopLeft, yWeightTopLeft); - - // const int outAddress = output_strideBatch * b + output_strideHeight * yOut + output_strideWidth * xOut; - const int outAddress = output_strideBatch * b + output_strideChannels * cOut + output_strideHeight * yOut + xOut; - - const int inTopLeftAddress = inputImages_strideBatch * b_input + inputImages_strideChannels * cOut + inputImages_strideHeight * yInTopLeft + xInTopLeft; - const int inTopRightAddress = inTopLeftAddress + inputImages_strideWidth; - const int inBottomLeftAddress = inTopLeftAddress + inputImages_strideHeight; - const int inBottomRightAddress = inBottomLeftAddress + inputImages_strideWidth; - - float v=0; - float inTopLeft=0; - float inTopRight=0; - float inBottomLeft=0; - float inBottomRight=0; - - bool topLeftIsIn = between(xInTopLeft, 0, width-1) && between(yInTopLeft, 0, height-1); - bool topRightIsIn = between(xInTopLeft+1, 0, width-1) && between(yInTopLeft, 0, height-1); - bool bottomLeftIsIn = between(xInTopLeft, 0, width-1) && between(yInTopLeft+1, 0, height-1); - bool bottomRightIsIn = between(xInTopLeft+1, 0, width-1) && between(yInTopLeft+1, 0, height-1); - - if (!topLeftIsIn && !topRightIsIn && !bottomLeftIsIn && !bottomRightIsIn) - continue; - - if(topLeftIsIn) inTopLeft = inputImages_data[inTopLeftAddress]; - if(topRightIsIn) inTopRight = inputImages_data[inTopRightAddress]; - if(bottomLeftIsIn) inBottomLeft = inputImages_data[inBottomLeftAddress]; - if(bottomRightIsIn) inBottomRight = inputImages_data[inBottomRightAddress]; - - v = xWeightTopLeft * yWeightTopLeft * inTopLeft - + (1 - xWeightTopLeft) * yWeightTopLeft * inTopRight - + xWeightTopLeft * (1 - yWeightTopLeft) * inBottomLeft - + (1 - xWeightTopLeft) * (1 - yWeightTopLeft) * inBottomRight; - - output_data[outAddress] = v; - } - -} - -__global__ void backwardBilinearSampling(const int nthreads, float* inputImages_data, int inputImages_strideBatch, int inputImages_strideChannels, int inputImages_strideHeight, int inputImages_strideWidth, - float* gradInputImages_data, int gradInputImages_strideBatch, int gradInputImages_strideChannels, int gradInputImages_strideHeight, int gradInputImages_strideWidth, - float* grids_data, int grids_strideBatch, int grids_strideYX, int grids_strideHeight, int grids_strideWidth, - float* gradGrids_data, int gradGrids_strideBatch, int gradGrids_strideYX, int gradGrids_strideHeight, int gradGrids_strideWidth, - float* gradOutput_data, int gradOutput_strideBatch, int gradOutput_strideChannels, int gradOutput_strideHeight, int gradOutput_strideWidth, - int inputImages_channels, int inputImages_height, int inputImages_width, - int gradOutput_channels, int gradOutput_height, int gradOutput_width, int gradOutput_batchsize, - int roiPerImage) -{ - - CUDA_KERNEL_LOOP(index, nthreads) - { - const int xOut = index % gradOutput_width; - const int yOut = (index / gradOutput_width) % gradOutput_height; - const int cOut = (index / gradOutput_width / gradOutput_height) % gradOutput_channels; - const int b = index / gradOutput_width / gradOutput_height / gradOutput_channels; - - const int b_input = b / roiPerImage; - - const int width = inputImages_width; - const int height = inputImages_height; - - float yf = grids_data[b*grids_strideBatch + yOut*grids_strideHeight + xOut*grids_strideWidth]; - float xf = grids_data[b*grids_strideBatch + yOut*grids_strideHeight + xOut*grids_strideWidth + 1]; - - int yInTopLeft, xInTopLeft; - float yWeightTopLeft, xWeightTopLeft; - getTopLeft(xf, inputImages_width, xInTopLeft, xWeightTopLeft); - getTopLeft(yf, inputImages_height, yInTopLeft, yWeightTopLeft); - - const int inTopLeftAddress = inputImages_strideBatch * b_input + inputImages_strideChannels * cOut + inputImages_strideHeight * yInTopLeft + xInTopLeft; - const int inTopRightAddress = inTopLeftAddress + inputImages_strideWidth; - const int inBottomLeftAddress = inTopLeftAddress + inputImages_strideHeight; - const int inBottomRightAddress = inBottomLeftAddress + inputImages_strideWidth; - - const int gradInputImagesTopLeftAddress = gradInputImages_strideBatch * b_input + gradInputImages_strideChannels * cOut - + gradInputImages_strideHeight * yInTopLeft + xInTopLeft; - const int gradInputImagesTopRightAddress = gradInputImagesTopLeftAddress + gradInputImages_strideWidth; - const int gradInputImagesBottomLeftAddress = gradInputImagesTopLeftAddress + gradInputImages_strideHeight; - const int gradInputImagesBottomRightAddress = gradInputImagesBottomLeftAddress + gradInputImages_strideWidth; - - const int gradOutputAddress = gradOutput_strideBatch * b + gradOutput_strideChannels * cOut + gradOutput_strideHeight * yOut + xOut; - - float topLeftDotProduct = 0; - float topRightDotProduct = 0; - float bottomLeftDotProduct = 0; - float bottomRightDotProduct = 0; - - bool topLeftIsIn = between(xInTopLeft, 0, width-1) && between(yInTopLeft, 0, height-1); - bool topRightIsIn = between(xInTopLeft+1, 0, width-1) && between(yInTopLeft, 0, height-1); - bool bottomLeftIsIn = between(xInTopLeft, 0, width-1) && between(yInTopLeft+1, 0, height-1); - bool bottomRightIsIn = between(xInTopLeft+1, 0, width-1) && between(yInTopLeft+1, 0, height-1); - - float gradOutValue = gradOutput_data[gradOutputAddress]; - // bool between(int value, int lowerBound, int upperBound) - if(topLeftIsIn) - { - float inTopLeft = inputImages_data[inTopLeftAddress]; - topLeftDotProduct += inTopLeft * gradOutValue; - atomicAdd(&gradInputImages_data[gradInputImagesTopLeftAddress], xWeightTopLeft * yWeightTopLeft * gradOutValue); - } - - if(topRightIsIn) - { - float inTopRight = inputImages_data[inTopRightAddress]; - topRightDotProduct += inTopRight * gradOutValue; - atomicAdd(&gradInputImages_data[gradInputImagesTopRightAddress], (1 - xWeightTopLeft) * yWeightTopLeft * gradOutValue); - } - - if(bottomLeftIsIn) - { - float inBottomLeft = inputImages_data[inBottomLeftAddress]; - bottomLeftDotProduct += inBottomLeft * gradOutValue; - atomicAdd(&gradInputImages_data[gradInputImagesBottomLeftAddress], xWeightTopLeft * (1 - yWeightTopLeft) * gradOutValue); - } - - if(bottomRightIsIn) - { - float inBottomRight = inputImages_data[inBottomRightAddress]; - bottomRightDotProduct += inBottomRight * gradOutValue; - atomicAdd(&gradInputImages_data[gradInputImagesBottomRightAddress], (1 - xWeightTopLeft) * (1 - yWeightTopLeft) * gradOutValue); - } - } -} - - -#ifdef __cplusplus -extern "C" { -#endif - -int BilinearSamplerBHWD_updateOutput_cuda_kernel(/*output->size[1]*/int oc, - /*output->size[3]*/int ow, - /*output->size[2]*/int oh, - /*output->size[0]*/int ob, - /*THCudaTensor_size(state, inputImages, 1)*/int ic, - /*THCudaTensor_size(state, inputImages, 2)*/int ih, - /*THCudaTensor_size(state, inputImages, 3)*/int iw, - /*THCudaTensor_size(state, inputImages, 0)*/int ib, - /*THCudaTensor *inputImages*/float *inputImages, int isb, int isc, int ish, int isw, - /*THCudaTensor *grids*/float *grids, int gsb, int gsc, int gsh, int gsw, - /*THCudaTensor *output*/float *output, int osb, int osc, int osh, int osw, - /*THCState_getCurrentStream(state)*/cudaStream_t stream) -{ - const int kThreadsPerBlock = 1024; - int output_size = ob * oh * ow * oc; - cudaError_t err; - int roiPerImage = ob / ib; - - // printf("forward pass\n"); - - bilinearSamplingFromGrid<<<(output_size + kThreadsPerBlock - 1) / kThreadsPerBlock, kThreadsPerBlock, 0, stream>>>( - output_size, - /*THCudaTensor_data(state, inputImages)*/inputImages, - /*THCudaTensor_stride(state, inputImages, 0)*/isb, - /*THCudaTensor_stride(state, inputImages, 3)*/isc, - /*THCudaTensor_stride(state, inputImages, 1)*/ish, - /*THCudaTensor_stride(state, inputImages, 2)*/isw, - /*THCudaTensor_data(state, grids)*/grids, - /*THCudaTensor_stride(state, grids, 0)*/gsb, - /*THCudaTensor_stride(state, grids, 3)*/gsc, - /*THCudaTensor_stride(state, grids, 1)*/gsh, - /*THCudaTensor_stride(state, grids, 2)*/gsw, - /*THCudaTensor_data(state, output)*/output, - /*THCudaTensor_stride(state, output, 0)*/osb, - /*THCudaTensor_stride(state, output, 3)*/osc, - /*THCudaTensor_stride(state, output, 1)*/osh, - /*THCudaTensor_stride(state, output, 2)*/osw, - /*THCudaTensor_size(state, inputImages, 3)*/ic, - /*THCudaTensor_size(state, inputImages, 1)*/ih, - /*THCudaTensor_size(state, inputImages, 2)*/iw, - /*THCudaTensor_size(state, output, 3)*/oc, - /*THCudaTensor_size(state, output, 1)*/oh, - /*THCudaTensor_size(state, output, 2)*/ow, - /*THCudaTensor_size(state, output, 0)*/ob, - /*Number of rois per image*/roiPerImage); - - // check for errors - err = cudaGetLastError(); - if (err != cudaSuccess) { - printf("error in BilinearSampler.updateOutput: %s\n", cudaGetErrorString(err)); - //THError("aborting"); - return 0; - } - return 1; -} - -int BilinearSamplerBHWD_updateGradInput_cuda_kernel(/*gradOutput->size[1]*/int goc, - /*gradOutput->size[3]*/int gow, - /*gradOutput->size[2]*/int goh, - /*gradOutput->size[0]*/int gob, - /*THCudaTensor_size(state, inputImages, 1)*/int ic, - /*THCudaTensor_size(state, inputImages, 2)*/int ih, - /*THCudaTensor_size(state, inputImages, 3)*/int iw, - /*THCudaTensor_size(state, inputImages, 0)*/int ib, - /*THCudaTensor *inputImages*/float *inputImages, int isb, int isc, int ish, int isw, - /*THCudaTensor *grids*/float *grids, int gsb, int gsc, int gsh, int gsw, - /*THCudaTensor *gradInputImages*/float *gradInputImages, int gisb, int gisc, int gish, int gisw, - /*THCudaTensor *gradGrids*/float *gradGrids, int ggsb, int ggsc, int ggsh, int ggsw, - /*THCudaTensor *gradOutput*/float *gradOutput, int gosb, int gosc, int gosh, int gosw, - /*THCState_getCurrentStream(state)*/cudaStream_t stream) -{ - - const int kThreadsPerBlock = 1024; - int output_size = gob * goh * gow * goc; - cudaError_t err; - int roiPerImage = gob / ib; - - // printf("%d %d %d %d\n", gob, goh, gow, goc); - // printf("%d %d %d %d\n", ib, ih, iw, ic); - // printf("backward pass\n"); - - backwardBilinearSampling<<<(output_size + kThreadsPerBlock - 1) / kThreadsPerBlock, kThreadsPerBlock, 0, stream>>>( - output_size, - /*THCudaTensor_data(state, inputImages)*/inputImages, - /*THCudaTensor_stride(state, inputImages, 0)*/isb, - /*THCudaTensor_stride(state, inputImages, 3)*/isc, - /*THCudaTensor_stride(state, inputImages, 1)*/ish, - /*THCudaTensor_stride(state, inputImages, 2)*/isw, - /*THCudaTensor_data(state, gradInputImages)*/gradInputImages, - /*THCudaTensor_stride(state, gradInputImages, 0)*/gisb, - /*THCudaTensor_stride(state, gradInputImages, 3)*/gisc, - /*THCudaTensor_stride(state, gradInputImages, 1)*/gish, - /*THCudaTensor_stride(state, gradInputImages, 2)*/gisw, - /*THCudaTensor_data(state, grids)*/grids, - /*THCudaTensor_stride(state, grids, 0)*/gsb, - /*THCudaTensor_stride(state, grids, 3)*/gsc, - /*THCudaTensor_stride(state, grids, 1)*/gsh, - /*THCudaTensor_stride(state, grids, 2)*/gsw, - /*THCudaTensor_data(state, gradGrids)*/gradGrids, - /*THCudaTensor_stride(state, gradGrids, 0)*/ggsb, - /*THCudaTensor_stride(state, gradGrids, 3)*/ggsc, - /*THCudaTensor_stride(state, gradGrids, 1)*/ggsh, - /*THCudaTensor_stride(state, gradGrids, 2)*/ggsw, - /*THCudaTensor_data(state, gradOutput)*/gradOutput, - /*THCudaTensor_stride(state, gradOutput, 0)*/gosb, - /*THCudaTensor_stride(state, gradOutput, 3)*/gosc, - /*THCudaTensor_stride(state, gradOutput, 1)*/gosh, - /*THCudaTensor_stride(state, gradOutput, 2)*/gosw, - /*THCudaTensor_size(state, inputImages, 3)*/ic, - /*THCudaTensor_size(state, inputImages, 1)*/ih, - /*THCudaTensor_size(state, inputImages, 2)*/iw, - /*THCudaTensor_size(state, gradOutput, 3)*/goc, - /*THCudaTensor_size(state, gradOutput, 1)*/goh, - /*THCudaTensor_size(state, gradOutput, 2)*/gow, - /*THCudaTensor_size(state, gradOutput, 0)*/gob, - /*Number of rois per image*/roiPerImage); - - // check for errors - err = cudaGetLastError(); - if (err != cudaSuccess) { - printf("error in BilinearSampler.updateGradInput: %s\n", cudaGetErrorString(err)); - //THError("aborting"); - return 0; - } - return 1; -} - -#ifdef __cplusplus -} -#endif diff --git a/lib/model/roi_crop/src/roi_crop_cuda_kernel.h b/lib/model/roi_crop/src/roi_crop_cuda_kernel.h deleted file mode 100644 index 5c06c073..00000000 --- a/lib/model/roi_crop/src/roi_crop_cuda_kernel.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - - -int BilinearSamplerBHWD_updateOutput_cuda_kernel(/*output->size[3]*/int oc, - /*output->size[2]*/int ow, - /*output->size[1]*/int oh, - /*output->size[0]*/int ob, - /*THCudaTensor_size(state, inputImages, 3)*/int ic, - /*THCudaTensor_size(state, inputImages, 1)*/int ih, - /*THCudaTensor_size(state, inputImages, 2)*/int iw, - /*THCudaTensor_size(state, inputImages, 0)*/int ib, - /*THCudaTensor *inputImages*/float *inputImages, int isb, int isc, int ish, int isw, - /*THCudaTensor *grids*/float *grids, int gsb, int gsc, int gsh, int gsw, - /*THCudaTensor *output*/float *output, int osb, int osc, int osh, int osw, - /*THCState_getCurrentStream(state)*/cudaStream_t stream); - -int BilinearSamplerBHWD_updateGradInput_cuda_kernel(/*gradOutput->size[3]*/int goc, - /*gradOutput->size[2]*/int gow, - /*gradOutput->size[1]*/int goh, - /*gradOutput->size[0]*/int gob, - /*THCudaTensor_size(state, inputImages, 3)*/int ic, - /*THCudaTensor_size(state, inputImages, 1)*/int ih, - /*THCudaTensor_size(state, inputImages, 2)*/int iw, - /*THCudaTensor_size(state, inputImages, 0)*/int ib, - /*THCudaTensor *inputImages*/float *inputImages, int isb, int isc, int ish, int isw, - /*THCudaTensor *grids*/float *grids, int gsb, int gsc, int gsh, int gsw, - /*THCudaTensor *gradInputImages*/float *gradInputImages, int gisb, int gisc, int gish, int gisw, - /*THCudaTensor *gradGrids*/float *gradGrids, int ggsb, int ggsc, int ggsh, int ggsw, - /*THCudaTensor *gradOutput*/float *gradOutput, int gosb, int gosc, int gosh, int gosw, - /*THCState_getCurrentStream(state)*/cudaStream_t stream); - - -#ifdef __cplusplus -} -#endif diff --git a/lib/model/roi_layers/__init__.py b/lib/model/roi_layers/__init__.py new file mode 100644 index 00000000..dbd59b50 --- /dev/null +++ b/lib/model/roi_layers/__init__.py @@ -0,0 +1,9 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +import torch +from .nms import nms +from .roi_align import ROIAlign +from .roi_align import roi_align +from .roi_pool import ROIPool +from .roi_pool import roi_pool + +__all__ = ["nms", "roi_align", "ROIAlign", "roi_pool", "ROIPool"] diff --git a/lib/model/roi_layers/nms.py b/lib/model/roi_layers/nms.py new file mode 100644 index 00000000..ffe4cc12 --- /dev/null +++ b/lib/model/roi_layers/nms.py @@ -0,0 +1,8 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +# from ._utils import _C +from model import _C + +nms = _C.nms +# nms.__doc__ = """ +# This function performs Non-maximum suppresion""" + diff --git a/lib/model/roi_layers/roi_align.py b/lib/model/roi_layers/roi_align.py new file mode 100644 index 00000000..cd03715e --- /dev/null +++ b/lib/model/roi_layers/roi_align.py @@ -0,0 +1,67 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +import torch +from torch import nn +from torch.autograd import Function +from torch.autograd.function import once_differentiable +from torch.nn.modules.utils import _pair + +from model import _C + + +class _ROIAlign(Function): + @staticmethod + def forward(ctx, input, roi, output_size, spatial_scale, sampling_ratio): + ctx.save_for_backward(roi) + ctx.output_size = _pair(output_size) + ctx.spatial_scale = spatial_scale + ctx.sampling_ratio = sampling_ratio + ctx.input_shape = input.size() + output = _C.roi_align_forward(input, roi, spatial_scale, + output_size[0], output_size[1], + sampling_ratio) + return output + + @staticmethod + @once_differentiable + def backward(ctx, grad_output): + rois, = ctx.saved_tensors + output_size = ctx.output_size + spatial_scale = ctx.spatial_scale + sampling_ratio = ctx.sampling_ratio + bs, ch, h, w = ctx.input_shape + grad_input = _C.roi_align_backward( + grad_output, + rois, + spatial_scale, + output_size[0], + output_size[1], + bs, + ch, + h, + w, + sampling_ratio, + ) + return grad_input, None, None, None, None + + +roi_align = _ROIAlign.apply + + +class ROIAlign(nn.Module): + def __init__(self, output_size, spatial_scale, sampling_ratio): + super(ROIAlign, self).__init__() + self.output_size = output_size + self.spatial_scale = spatial_scale + self.sampling_ratio = sampling_ratio + + def forward(self, input, rois): + return roi_align(input, rois, self.output_size, self.spatial_scale, + self.sampling_ratio) + + def __repr__(self): + tmpstr = self.__class__.__name__ + "(" + tmpstr += "output_size=" + str(self.output_size) + tmpstr += ", spatial_scale=" + str(self.spatial_scale) + tmpstr += ", sampling_ratio=" + str(self.sampling_ratio) + tmpstr += ")" + return tmpstr diff --git a/lib/model/roi_layers/roi_pool.py b/lib/model/roi_layers/roi_pool.py new file mode 100644 index 00000000..3fac3443 --- /dev/null +++ b/lib/model/roi_layers/roi_pool.py @@ -0,0 +1,62 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +import torch +from torch import nn +from torch.autograd import Function +from torch.autograd.function import once_differentiable +from torch.nn.modules.utils import _pair + +from model import _C + + +class _ROIPool(Function): + @staticmethod + def forward(ctx, input, roi, output_size, spatial_scale): + ctx.output_size = _pair(output_size) + ctx.spatial_scale = spatial_scale + ctx.input_shape = input.size() + output, argmax = _C.roi_pool_forward(input, roi, spatial_scale, + output_size[0], output_size[1]) + ctx.save_for_backward(input, roi, argmax) + return output + + @staticmethod + @once_differentiable + def backward(ctx, grad_output): + input, rois, argmax = ctx.saved_tensors + output_size = ctx.output_size + spatial_scale = ctx.spatial_scale + bs, ch, h, w = ctx.input_shape + grad_input = _C.roi_pool_backward( + grad_output, + input, + rois, + argmax, + spatial_scale, + output_size[0], + output_size[1], + bs, + ch, + h, + w, + ) + return grad_input, None, None, None + + +roi_pool = _ROIPool.apply + + +class ROIPool(nn.Module): + def __init__(self, output_size, spatial_scale): + super(ROIPool, self).__init__() + self.output_size = output_size + self.spatial_scale = spatial_scale + + def forward(self, input, rois): + return roi_pool(input, rois, self.output_size, self.spatial_scale) + + def __repr__(self): + tmpstr = self.__class__.__name__ + "(" + tmpstr += "output_size=" + str(self.output_size) + tmpstr += ", spatial_scale=" + str(self.spatial_scale) + tmpstr += ")" + return tmpstr diff --git a/lib/model/roi_pooling/__init__.py b/lib/model/roi_pooling/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/roi_pooling/_ext/__init__.py b/lib/model/roi_pooling/_ext/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/roi_pooling/_ext/roi_pooling/__init__.py b/lib/model/roi_pooling/_ext/roi_pooling/__init__.py deleted file mode 100644 index d900ec5a..00000000 --- a/lib/model/roi_pooling/_ext/roi_pooling/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ - -from torch.utils.ffi import _wrap_function -from ._roi_pooling import lib as _lib, ffi as _ffi - -__all__ = [] -def _import_symbols(locals): - for symbol in dir(_lib): - fn = getattr(_lib, symbol) - if callable(fn): - locals[symbol] = _wrap_function(fn, _ffi) - else: - locals[symbol] = fn - __all__.append(symbol) - -_import_symbols(locals()) diff --git a/lib/model/roi_pooling/build.py b/lib/model/roi_pooling/build.py deleted file mode 100644 index 7381d5b8..00000000 --- a/lib/model/roi_pooling/build.py +++ /dev/null @@ -1,35 +0,0 @@ -from __future__ import print_function -import os -import torch -from torch.utils.ffi import create_extension - - -sources = ['src/roi_pooling.c'] -headers = ['src/roi_pooling.h'] -defines = [] -with_cuda = False - -if torch.cuda.is_available(): - print('Including CUDA code.') - sources += ['src/roi_pooling_cuda.c'] - headers += ['src/roi_pooling_cuda.h'] - defines += [('WITH_CUDA', None)] - with_cuda = True - -this_file = os.path.dirname(os.path.realpath(__file__)) -print(this_file) -extra_objects = ['src/roi_pooling.cu.o'] -extra_objects = [os.path.join(this_file, fname) for fname in extra_objects] - -ffi = create_extension( - '_ext.roi_pooling', - headers=headers, - sources=sources, - define_macros=defines, - relative_to=__file__, - with_cuda=with_cuda, - extra_objects=extra_objects -) - -if __name__ == '__main__': - ffi.build() diff --git a/lib/model/roi_pooling/functions/__init__.py b/lib/model/roi_pooling/functions/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/roi_pooling/functions/roi_pool.py b/lib/model/roi_pooling/functions/roi_pool.py deleted file mode 100644 index b7d22abd..00000000 --- a/lib/model/roi_pooling/functions/roi_pool.py +++ /dev/null @@ -1,38 +0,0 @@ -import torch -from torch.autograd import Function -from .._ext import roi_pooling -import pdb - -class RoIPoolFunction(Function): - def __init__(ctx, pooled_height, pooled_width, spatial_scale): - ctx.pooled_width = pooled_width - ctx.pooled_height = pooled_height - ctx.spatial_scale = spatial_scale - ctx.feature_size = None - - def forward(ctx, features, rois): - ctx.feature_size = features.size() - batch_size, num_channels, data_height, data_width = ctx.feature_size - num_rois = rois.size(0) - output = features.new(num_rois, num_channels, ctx.pooled_height, ctx.pooled_width).zero_() - ctx.argmax = features.new(num_rois, num_channels, ctx.pooled_height, ctx.pooled_width).zero_().int() - ctx.rois = rois - if not features.is_cuda: - _features = features.permute(0, 2, 3, 1) - roi_pooling.roi_pooling_forward(ctx.pooled_height, ctx.pooled_width, ctx.spatial_scale, - _features, rois, output) - else: - roi_pooling.roi_pooling_forward_cuda(ctx.pooled_height, ctx.pooled_width, ctx.spatial_scale, - features, rois, output, ctx.argmax) - - return output - - def backward(ctx, grad_output): - assert(ctx.feature_size is not None and grad_output.is_cuda) - batch_size, num_channels, data_height, data_width = ctx.feature_size - grad_input = grad_output.new(batch_size, num_channels, data_height, data_width).zero_() - - roi_pooling.roi_pooling_backward_cuda(ctx.pooled_height, ctx.pooled_width, ctx.spatial_scale, - grad_output, ctx.rois, grad_input, ctx.argmax) - - return grad_input, None diff --git a/lib/model/roi_pooling/modules/__init__.py b/lib/model/roi_pooling/modules/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/roi_pooling/modules/roi_pool.py b/lib/model/roi_pooling/modules/roi_pool.py deleted file mode 100644 index 516c16fe..00000000 --- a/lib/model/roi_pooling/modules/roi_pool.py +++ /dev/null @@ -1,14 +0,0 @@ -from torch.nn.modules.module import Module -from ..functions.roi_pool import RoIPoolFunction - - -class _RoIPooling(Module): - def __init__(self, pooled_height, pooled_width, spatial_scale): - super(_RoIPooling, self).__init__() - - self.pooled_width = int(pooled_width) - self.pooled_height = int(pooled_height) - self.spatial_scale = float(spatial_scale) - - def forward(self, features, rois): - return RoIPoolFunction(self.pooled_height, self.pooled_width, self.spatial_scale)(features, rois) diff --git a/lib/model/roi_pooling/src/roi_pooling.c b/lib/model/roi_pooling/src/roi_pooling.c deleted file mode 100644 index 47a754d6..00000000 --- a/lib/model/roi_pooling/src/roi_pooling.c +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include - -int roi_pooling_forward(int pooled_height, int pooled_width, float spatial_scale, - THFloatTensor * features, THFloatTensor * rois, THFloatTensor * output) -{ - // Grab the input tensor - float * data_flat = THFloatTensor_data(features); - float * rois_flat = THFloatTensor_data(rois); - - float * output_flat = THFloatTensor_data(output); - - // Number of ROIs - int num_rois = THFloatTensor_size(rois, 0); - int size_rois = THFloatTensor_size(rois, 1); - // batch size - int batch_size = THFloatTensor_size(features, 0); - if(batch_size != 1) - { - return 0; - } - // data height - int data_height = THFloatTensor_size(features, 1); - // data width - int data_width = THFloatTensor_size(features, 2); - // Number of channels - int num_channels = THFloatTensor_size(features, 3); - - // Set all element of the output tensor to -inf. - THFloatStorage_fill(THFloatTensor_storage(output), -1); - - // For each ROI R = [batch_index x1 y1 x2 y2]: max pool over R - int index_roi = 0; - int index_output = 0; - int n; - for (n = 0; n < num_rois; ++n) - { - int roi_batch_ind = rois_flat[index_roi + 0]; - int roi_start_w = round(rois_flat[index_roi + 1] * spatial_scale); - int roi_start_h = round(rois_flat[index_roi + 2] * spatial_scale); - int roi_end_w = round(rois_flat[index_roi + 3] * spatial_scale); - int roi_end_h = round(rois_flat[index_roi + 4] * spatial_scale); - // CHECK_GE(roi_batch_ind, 0); - // CHECK_LT(roi_batch_ind, batch_size); - - int roi_height = fmaxf(roi_end_h - roi_start_h + 1, 1); - int roi_width = fmaxf(roi_end_w - roi_start_w + 1, 1); - float bin_size_h = (float)(roi_height) / (float)(pooled_height); - float bin_size_w = (float)(roi_width) / (float)(pooled_width); - - int index_data = roi_batch_ind * data_height * data_width * num_channels; - const int output_area = pooled_width * pooled_height; - - int c, ph, pw; - for (ph = 0; ph < pooled_height; ++ph) - { - for (pw = 0; pw < pooled_width; ++pw) - { - int hstart = (floor((float)(ph) * bin_size_h)); - int wstart = (floor((float)(pw) * bin_size_w)); - int hend = (ceil((float)(ph + 1) * bin_size_h)); - int wend = (ceil((float)(pw + 1) * bin_size_w)); - - hstart = fminf(fmaxf(hstart + roi_start_h, 0), data_height); - hend = fminf(fmaxf(hend + roi_start_h, 0), data_height); - wstart = fminf(fmaxf(wstart + roi_start_w, 0), data_width); - wend = fminf(fmaxf(wend + roi_start_w, 0), data_width); - - const int pool_index = index_output + (ph * pooled_width + pw); - int is_empty = (hend <= hstart) || (wend <= wstart); - if (is_empty) - { - for (c = 0; c < num_channels * output_area; c += output_area) - { - output_flat[pool_index + c] = 0; - } - } - else - { - int h, w, c; - for (h = hstart; h < hend; ++h) - { - for (w = wstart; w < wend; ++w) - { - for (c = 0; c < num_channels; ++c) - { - const int index = (h * data_width + w) * num_channels + c; - if (data_flat[index_data + index] > output_flat[pool_index + c * output_area]) - { - output_flat[pool_index + c * output_area] = data_flat[index_data + index]; - } - } - } - } - } - } - } - - // Increment ROI index - index_roi += size_rois; - index_output += pooled_height * pooled_width * num_channels; - } - return 1; -} \ No newline at end of file diff --git a/lib/model/roi_pooling/src/roi_pooling.h b/lib/model/roi_pooling/src/roi_pooling.h deleted file mode 100644 index 06052deb..00000000 --- a/lib/model/roi_pooling/src/roi_pooling.h +++ /dev/null @@ -1,2 +0,0 @@ -int roi_pooling_forward(int pooled_height, int pooled_width, float spatial_scale, - THFloatTensor * features, THFloatTensor * rois, THFloatTensor * output); \ No newline at end of file diff --git a/lib/model/roi_pooling/src/roi_pooling_cuda.c b/lib/model/roi_pooling/src/roi_pooling_cuda.c deleted file mode 100644 index 32eb3f77..00000000 --- a/lib/model/roi_pooling/src/roi_pooling_cuda.c +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include -#include "roi_pooling_kernel.h" - -extern THCState *state; - -int roi_pooling_forward_cuda(int pooled_height, int pooled_width, float spatial_scale, - THCudaTensor * features, THCudaTensor * rois, THCudaTensor * output, THCudaIntTensor * argmax) -{ - // Grab the input tensor - float * data_flat = THCudaTensor_data(state, features); - float * rois_flat = THCudaTensor_data(state, rois); - - float * output_flat = THCudaTensor_data(state, output); - int * argmax_flat = THCudaIntTensor_data(state, argmax); - - // Number of ROIs - int num_rois = THCudaTensor_size(state, rois, 0); - int size_rois = THCudaTensor_size(state, rois, 1); - if (size_rois != 5) - { - return 0; - } - - // batch size - // int batch_size = THCudaTensor_size(state, features, 0); - // if (batch_size != 1) - // { - // return 0; - // } - // data height - int data_height = THCudaTensor_size(state, features, 2); - // data width - int data_width = THCudaTensor_size(state, features, 3); - // Number of channels - int num_channels = THCudaTensor_size(state, features, 1); - - cudaStream_t stream = THCState_getCurrentStream(state); - - ROIPoolForwardLaucher( - data_flat, spatial_scale, num_rois, data_height, - data_width, num_channels, pooled_height, - pooled_width, rois_flat, - output_flat, argmax_flat, stream); - - return 1; -} - -int roi_pooling_backward_cuda(int pooled_height, int pooled_width, float spatial_scale, - THCudaTensor * top_grad, THCudaTensor * rois, THCudaTensor * bottom_grad, THCudaIntTensor * argmax) -{ - // Grab the input tensor - float * top_grad_flat = THCudaTensor_data(state, top_grad); - float * rois_flat = THCudaTensor_data(state, rois); - - float * bottom_grad_flat = THCudaTensor_data(state, bottom_grad); - int * argmax_flat = THCudaIntTensor_data(state, argmax); - - // Number of ROIs - int num_rois = THCudaTensor_size(state, rois, 0); - int size_rois = THCudaTensor_size(state, rois, 1); - if (size_rois != 5) - { - return 0; - } - - // batch size - int batch_size = THCudaTensor_size(state, bottom_grad, 0); - // if (batch_size != 1) - // { - // return 0; - // } - // data height - int data_height = THCudaTensor_size(state, bottom_grad, 2); - // data width - int data_width = THCudaTensor_size(state, bottom_grad, 3); - // Number of channels - int num_channels = THCudaTensor_size(state, bottom_grad, 1); - - cudaStream_t stream = THCState_getCurrentStream(state); - ROIPoolBackwardLaucher( - top_grad_flat, spatial_scale, batch_size, num_rois, data_height, - data_width, num_channels, pooled_height, - pooled_width, rois_flat, - bottom_grad_flat, argmax_flat, stream); - - return 1; -} diff --git a/lib/model/roi_pooling/src/roi_pooling_cuda.h b/lib/model/roi_pooling/src/roi_pooling_cuda.h deleted file mode 100644 index c08881e8..00000000 --- a/lib/model/roi_pooling/src/roi_pooling_cuda.h +++ /dev/null @@ -1,5 +0,0 @@ -int roi_pooling_forward_cuda(int pooled_height, int pooled_width, float spatial_scale, - THCudaTensor * features, THCudaTensor * rois, THCudaTensor * output, THCudaIntTensor * argmax); - -int roi_pooling_backward_cuda(int pooled_height, int pooled_width, float spatial_scale, - THCudaTensor * top_grad, THCudaTensor * rois, THCudaTensor * bottom_grad, THCudaIntTensor * argmax); \ No newline at end of file diff --git a/lib/model/roi_pooling/src/roi_pooling_kernel.cu b/lib/model/roi_pooling/src/roi_pooling_kernel.cu deleted file mode 100644 index 813bc5da..00000000 --- a/lib/model/roi_pooling/src/roi_pooling_kernel.cu +++ /dev/null @@ -1,239 +0,0 @@ -// #ifdef __cplusplus -// extern "C" { -// #endif - -#include -#include -#include -#include -#include "roi_pooling_kernel.h" - - -#define DIVUP(m, n) ((m) / (m) + ((m) % (n) > 0)) - -#define CUDA_1D_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ - i += blockDim.x * gridDim.x) - -// CUDA: grid stride looping -#define CUDA_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ - i < (n); \ - i += blockDim.x * gridDim.x) - -__global__ void ROIPoolForward(const int nthreads, const float* bottom_data, - const float spatial_scale, const int height, const int width, - const int channels, const int pooled_height, const int pooled_width, - const float* bottom_rois, float* top_data, int* argmax_data) -{ - CUDA_KERNEL_LOOP(index, nthreads) - { - // (n, c, ph, pw) is an element in the pooled output - // int n = index; - // int pw = n % pooled_width; - // n /= pooled_width; - // int ph = n % pooled_height; - // n /= pooled_height; - // int c = n % channels; - // n /= channels; - int pw = index % pooled_width; - int ph = (index / pooled_width) % pooled_height; - int c = (index / pooled_width / pooled_height) % channels; - int n = index / pooled_width / pooled_height / channels; - - // bottom_rois += n * 5; - int roi_batch_ind = bottom_rois[n * 5 + 0]; - int roi_start_w = round(bottom_rois[n * 5 + 1] * spatial_scale); - int roi_start_h = round(bottom_rois[n * 5 + 2] * spatial_scale); - int roi_end_w = round(bottom_rois[n * 5 + 3] * spatial_scale); - int roi_end_h = round(bottom_rois[n * 5 + 4] * spatial_scale); - - // Force malformed ROIs to be 1x1 - int roi_width = fmaxf(roi_end_w - roi_start_w + 1, 1); - int roi_height = fmaxf(roi_end_h - roi_start_h + 1, 1); - float bin_size_h = (float)(roi_height) / (float)(pooled_height); - float bin_size_w = (float)(roi_width) / (float)(pooled_width); - - int hstart = (int)(floor((float)(ph) * bin_size_h)); - int wstart = (int)(floor((float)(pw) * bin_size_w)); - int hend = (int)(ceil((float)(ph + 1) * bin_size_h)); - int wend = (int)(ceil((float)(pw + 1) * bin_size_w)); - - // Add roi offsets and clip to input boundaries - hstart = fminf(fmaxf(hstart + roi_start_h, 0), height); - hend = fminf(fmaxf(hend + roi_start_h, 0), height); - wstart = fminf(fmaxf(wstart + roi_start_w, 0), width); - wend = fminf(fmaxf(wend + roi_start_w, 0), width); - bool is_empty = (hend <= hstart) || (wend <= wstart); - - // Define an empty pooling region to be zero - float maxval = is_empty ? 0 : -FLT_MAX; - // If nothing is pooled, argmax = -1 causes nothing to be backprop'd - int maxidx = -1; - // bottom_data += roi_batch_ind * channels * height * width; - - int bottom_data_batch_offset = roi_batch_ind * channels * height * width; - int bottom_data_offset = bottom_data_batch_offset + c * height * width; - - for (int h = hstart; h < hend; ++h) { - for (int w = wstart; w < wend; ++w) { - // int bottom_index = (h * width + w) * channels + c; - // int bottom_index = (c * height + h) * width + w; - int bottom_index = h * width + w; - if (bottom_data[bottom_data_offset + bottom_index] > maxval) { - maxval = bottom_data[bottom_data_offset + bottom_index]; - maxidx = bottom_data_offset + bottom_index; - } - } - } - top_data[index] = maxval; - if (argmax_data != NULL) - argmax_data[index] = maxidx; - } -} - -int ROIPoolForwardLaucher( - const float* bottom_data, const float spatial_scale, const int num_rois, const int height, - const int width, const int channels, const int pooled_height, - const int pooled_width, const float* bottom_rois, - float* top_data, int* argmax_data, cudaStream_t stream) -{ - const int kThreadsPerBlock = 1024; - int output_size = num_rois * pooled_height * pooled_width * channels; - cudaError_t err; - - ROIPoolForward<<<(output_size + kThreadsPerBlock - 1) / kThreadsPerBlock, kThreadsPerBlock, 0, stream>>>( - output_size, bottom_data, spatial_scale, height, width, channels, pooled_height, - pooled_width, bottom_rois, top_data, argmax_data); - - // dim3 blocks(DIVUP(output_size, kThreadsPerBlock), - // DIVUP(output_size, kThreadsPerBlock)); - // dim3 threads(kThreadsPerBlock); - // - // ROIPoolForward<<>>( - // output_size, bottom_data, spatial_scale, height, width, channels, pooled_height, - // pooled_width, bottom_rois, top_data, argmax_data); - - err = cudaGetLastError(); - if(cudaSuccess != err) - { - fprintf( stderr, "cudaCheckError() failed : %s\n", cudaGetErrorString( err ) ); - exit( -1 ); - } - - return 1; -} - - -__global__ void ROIPoolBackward(const int nthreads, const float* top_diff, - const int* argmax_data, const int num_rois, const float spatial_scale, - const int height, const int width, const int channels, - const int pooled_height, const int pooled_width, float* bottom_diff, - const float* bottom_rois) { - CUDA_1D_KERNEL_LOOP(index, nthreads) - { - - // (n, c, ph, pw) is an element in the pooled output - int n = index; - int w = n % width; - n /= width; - int h = n % height; - n /= height; - int c = n % channels; - n /= channels; - - float gradient = 0; - // Accumulate gradient over all ROIs that pooled this element - for (int roi_n = 0; roi_n < num_rois; ++roi_n) - { - const float* offset_bottom_rois = bottom_rois + roi_n * 5; - int roi_batch_ind = offset_bottom_rois[0]; - // Skip if ROI's batch index doesn't match n - if (n != roi_batch_ind) { - continue; - } - - int roi_start_w = round(offset_bottom_rois[1] * spatial_scale); - int roi_start_h = round(offset_bottom_rois[2] * spatial_scale); - int roi_end_w = round(offset_bottom_rois[3] * spatial_scale); - int roi_end_h = round(offset_bottom_rois[4] * spatial_scale); - - // Skip if ROI doesn't include (h, w) - const bool in_roi = (w >= roi_start_w && w <= roi_end_w && - h >= roi_start_h && h <= roi_end_h); - if (!in_roi) { - continue; - } - - int offset = roi_n * pooled_height * pooled_width * channels; - const float* offset_top_diff = top_diff + offset; - const int* offset_argmax_data = argmax_data + offset; - - // Compute feasible set of pooled units that could have pooled - // this bottom unit - - // Force malformed ROIs to be 1x1 - int roi_width = fmaxf(roi_end_w - roi_start_w + 1, 1); - int roi_height = fmaxf(roi_end_h - roi_start_h + 1, 1); - - float bin_size_h = (float)(roi_height) / (float)(pooled_height); - float bin_size_w = (float)(roi_width) / (float)(pooled_width); - - int phstart = floor((float)(h - roi_start_h) / bin_size_h); - int phend = ceil((float)(h - roi_start_h + 1) / bin_size_h); - int pwstart = floor((float)(w - roi_start_w) / bin_size_w); - int pwend = ceil((float)(w - roi_start_w + 1) / bin_size_w); - - phstart = fminf(fmaxf(phstart, 0), pooled_height); - phend = fminf(fmaxf(phend, 0), pooled_height); - pwstart = fminf(fmaxf(pwstart, 0), pooled_width); - pwend = fminf(fmaxf(pwend, 0), pooled_width); - - for (int ph = phstart; ph < phend; ++ph) { - for (int pw = pwstart; pw < pwend; ++pw) { - if (offset_argmax_data[(c * pooled_height + ph) * pooled_width + pw] == index) - { - gradient += offset_top_diff[(c * pooled_height + ph) * pooled_width + pw]; - } - } - } - } - bottom_diff[index] = gradient; - } -} - -int ROIPoolBackwardLaucher(const float* top_diff, const float spatial_scale, const int batch_size, const int num_rois, - const int height, const int width, const int channels, const int pooled_height, - const int pooled_width, const float* bottom_rois, - float* bottom_diff, const int* argmax_data, cudaStream_t stream) -{ - const int kThreadsPerBlock = 1024; - int output_size = batch_size * height * width * channels; - cudaError_t err; - - ROIPoolBackward<<<(output_size + kThreadsPerBlock - 1) / kThreadsPerBlock, kThreadsPerBlock, 0, stream>>>( - output_size, top_diff, argmax_data, num_rois, spatial_scale, height, width, channels, pooled_height, - pooled_width, bottom_diff, bottom_rois); - - // dim3 blocks(DIVUP(output_size, kThreadsPerBlock), - // DIVUP(output_size, kThreadsPerBlock)); - // dim3 threads(kThreadsPerBlock); - // - // ROIPoolBackward<<>>( - // output_size, top_diff, argmax_data, num_rois, spatial_scale, height, width, channels, pooled_height, - // pooled_width, bottom_diff, bottom_rois); - - err = cudaGetLastError(); - if(cudaSuccess != err) - { - fprintf( stderr, "cudaCheckError() failed : %s\n", cudaGetErrorString( err ) ); - exit( -1 ); - } - - return 1; -} - - -// #ifdef __cplusplus -// } -// #endif diff --git a/lib/model/roi_pooling/src/roi_pooling_kernel.h b/lib/model/roi_pooling/src/roi_pooling_kernel.h deleted file mode 100644 index f6e68eb0..00000000 --- a/lib/model/roi_pooling/src/roi_pooling_kernel.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _ROI_POOLING_KERNEL -#define _ROI_POOLING_KERNEL - -#ifdef __cplusplus -extern "C" { -#endif - -int ROIPoolForwardLaucher( - const float* bottom_data, const float spatial_scale, const int num_rois, const int height, - const int width, const int channels, const int pooled_height, - const int pooled_width, const float* bottom_rois, - float* top_data, int* argmax_data, cudaStream_t stream); - - -int ROIPoolBackwardLaucher(const float* top_diff, const float spatial_scale, const int batch_size, const int num_rois, - const int height, const int width, const int channels, const int pooled_height, - const int pooled_width, const float* bottom_rois, - float* bottom_diff, const int* argmax_data, cudaStream_t stream); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/lib/modeling/model_builder.py b/lib/modeling/model_builder.py index 0c7f1f49..a2578bca 100644 --- a/lib/modeling/model_builder.py +++ b/lib/modeling/model_builder.py @@ -8,9 +8,10 @@ from torch.autograd import Variable from core.config import cfg -from model.roi_pooling.functions.roi_pool import RoIPoolFunction -from model.roi_crop.functions.roi_crop import RoICropFunction -from modeling.roi_xfrom.roi_align.functions.roi_align import RoIAlignFunction +# from model.roi_pooling.functions.roi_pool import RoIPoolFunction +# from model.roi_crop.functions.roi_crop import RoICropFunction +# from modeling.roi_xfrom.roi_align.functions.roi_align import RoIAlignFunction +from model.roi_layers import ROIPool, ROIAlign import modeling.rpn_heads as rpn_heads import modeling.fast_rcnn_heads as fast_rcnn_heads import modeling.mask_rcnn_heads as mask_rcnn_heads @@ -258,7 +259,7 @@ def roi_feature_transform(self, blobs_in, rpn_ret, blob_rois='rois', method='RoI - Use of FPN or not - Specifics of the transform method """ - assert method in {'RoIPoolF', 'RoICrop', 'RoIAlign'}, \ + assert method in {'RoIPoolF', 'RoIAlign'}, \ 'Unknown pooling method: {}'.format(method) if isinstance(blobs_in, list): @@ -276,19 +277,10 @@ def roi_feature_transform(self, blobs_in, rpn_ret, blob_rois='rois', method='RoI rois = Variable(torch.from_numpy(rpn_ret[bl_rois])).cuda(device_id) if method == 'RoIPoolF': # Warning!: Not check if implementation matches Detectron - xform_out = RoIPoolFunction(resolution, resolution, sc)(bl_in, rois) - elif method == 'RoICrop': - # Warning!: Not check if implementation matches Detectron - grid_xy = net_utils.affine_grid_gen( - rois, bl_in.size()[2:], self.grid_size) - grid_yx = torch.stack( - [grid_xy.data[:, :, :, 1], grid_xy.data[:, :, :, 0]], 3).contiguous() - xform_out = RoICropFunction()(bl_in, Variable(grid_yx).detach()) - if cfg.CROP_RESIZE_WITH_MAX_POOL: - xform_out = F.max_pool2d(xform_out, 2, 2) + xform_out = ROIPool((resolution, resolution), sc)(bl_in, rois) elif method == 'RoIAlign': xform_out = RoIAlignFunction( - resolution, resolution, sc, sampling_ratio)(bl_in, rois) + (resolution, resolution), sc, sampling_ratio)(bl_in, rois) bl_out_list.append(xform_out) # The pooled features from all levels are concatenated along the @@ -309,17 +301,10 @@ def roi_feature_transform(self, blobs_in, rpn_ret, blob_rois='rois', method='RoI device_id = blobs_in.get_device() rois = Variable(torch.from_numpy(rpn_ret[blob_rois])).cuda(device_id) if method == 'RoIPoolF': - xform_out = RoIPoolFunction(resolution, resolution, spatial_scale)(blobs_in, rois) - elif method == 'RoICrop': - grid_xy = net_utils.affine_grid_gen(rois, blobs_in.size()[2:], self.grid_size) - grid_yx = torch.stack( - [grid_xy.data[:, :, :, 1], grid_xy.data[:, :, :, 0]], 3).contiguous() - xform_out = RoICropFunction()(blobs_in, Variable(grid_yx).detach()) - if cfg.CROP_RESIZE_WITH_MAX_POOL: - xform_out = F.max_pool2d(xform_out, 2, 2) + xform_out = ROIPool((resolution, resolution), spatial_scale)(blobs_in, rois) elif method == 'RoIAlign': - xform_out = RoIAlignFunction( - resolution, resolution, spatial_scale, sampling_ratio)(blobs_in, rois) + xform_out = ROIAlign( + (resolution, resolution), spatial_scale, sampling_ratio)(blobs_in, rois) return xform_out diff --git a/lib/setup.py b/lib/setup_bbox.py similarity index 100% rename from lib/setup.py rename to lib/setup_bbox.py diff --git a/lib/setup_layers.py b/lib/setup_layers.py new file mode 100644 index 00000000..7e7e2001 --- /dev/null +++ b/lib/setup_layers.py @@ -0,0 +1,67 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#!/usr/bin/env python + +import glob +import os + +import torch +from setuptools import find_packages +from setuptools import setup +from torch.utils.cpp_extension import CUDA_HOME +from torch.utils.cpp_extension import CppExtension +from torch.utils.cpp_extension import CUDAExtension + +requirements = ["torch", "torchvision"] + + +def get_extensions(): + this_dir = os.path.dirname(os.path.abspath(__file__)) + extensions_dir = os.path.join(this_dir, "model", "csrc") + + main_file = glob.glob(os.path.join(extensions_dir, "*.cpp")) + source_cpu = glob.glob(os.path.join(extensions_dir, "cpu", "*.cpp")) + source_cuda = glob.glob(os.path.join(extensions_dir, "cuda", "*.cu")) + + sources = main_file + source_cpu + extension = CppExtension + + extra_compile_args = {"cxx": []} + define_macros = [] + + if torch.cuda.is_available() and CUDA_HOME is not None: + extension = CUDAExtension + sources += source_cuda + define_macros += [("WITH_CUDA", None)] + extra_compile_args["nvcc"] = [ + "-DCUDA_HAS_FP16=1", + "-D__CUDA_NO_HALF_OPERATORS__", + "-D__CUDA_NO_HALF_CONVERSIONS__", + "-D__CUDA_NO_HALF2_OPERATORS__", + ] + + sources = [os.path.join(extensions_dir, s) for s in sources] + + include_dirs = [extensions_dir] + + ext_modules = [ + extension( + "model._C", + sources, + include_dirs=include_dirs, + define_macros=define_macros, + extra_compile_args=extra_compile_args, + ) + ] + + return ext_modules + + +setup( + name="faster_rcnn", + version="0.1", + description="object detection in pytorch", + packages=find_packages(exclude=("configs", "tests",)), + # install_requires=requirements, + ext_modules=get_extensions(), + cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension}, +) diff --git a/lib/utils/cython_bbox.c b/lib/utils/cython_bbox.c index c368a8ed..c4d2b640 100644 --- a/lib/utils/cython_bbox.c +++ b/lib/utils/cython_bbox.c @@ -1,13 +1,37 @@ -/* Generated by Cython 0.26.1 */ +/* Generated by Cython 0.29.2 */ + +/* BEGIN: Cython Metadata +{ + "distutils": { + "depends": [ + "/home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h", + "/home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/ufuncobject.h" + ], + "extra_compile_args": [ + "-Wno-cpp" + ], + "include_dirs": [ + "/home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/numpy/core/include" + ], + "name": "utils.cython_bbox", + "sources": [ + "utils/cython_bbox.pyx" + ] + }, + "module_name": "utils.cython_bbox" +} +END: Cython Metadata */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26_1" +#define CYTHON_ABI "0_29_2" +#define CYTHON_HEX_VERSION 0x001D02F0 +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +55,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -49,8 +73,12 @@ #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -69,6 +97,14 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -102,6 +138,14 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -154,6 +198,18 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif + #ifndef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) + #endif + #ifndef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -163,7 +219,107 @@ #undef SHIFT #undef BASE #undef MASK + #ifdef SIZEOF_VOID_P + enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; + #endif +#endif +#ifndef __has_attribute + #define __has_attribute(x) 0 +#endif +#ifndef __has_cpp_attribute + #define __has_cpp_attribute(x) 0 +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) +#ifdef _MSC_VER + #ifndef _MSC_STDINT_H_ + #if _MSC_VER < 1300 + typedef unsigned char uint8_t; + typedef unsigned int uint32_t; + #else + typedef unsigned __int8 uint8_t; + typedef unsigned __int32 uint32_t; + #endif + #endif +#else + #include +#endif +#ifndef CYTHON_FALLTHROUGH + #if defined(__cplusplus) && __cplusplus >= 201103L + #if __has_cpp_attribute(fallthrough) + #define CYTHON_FALLTHROUGH [[fallthrough]] + #elif __has_cpp_attribute(clang::fallthrough) + #define CYTHON_FALLTHROUGH [[clang::fallthrough]] + #elif __has_cpp_attribute(gnu::fallthrough) + #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] + #endif + #endif + #ifndef CYTHON_FALLTHROUGH + #if __has_attribute(fallthrough) + #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) + #else + #define CYTHON_FALLTHROUGH + #endif + #endif + #if defined(__clang__ ) && defined(__apple_build_version__) + #if __apple_build_version__ < 7000000 + #undef CYTHON_FALLTHROUGH + #define CYTHON_FALLTHROUGH + #endif + #endif +#endif + +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #elif defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif @@ -192,12 +348,15 @@ #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif -#if PY_VERSION_HEX < 0x030700A0 || !defined(METH_FASTCALL) +#ifndef METH_STACKLESS + #define METH_STACKLESS 0 +#endif +#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs); - typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **args, + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); + typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else #define __Pyx_PyCFunctionFast _PyCFunctionFast @@ -205,10 +364,103 @@ #endif #if CYTHON_FAST_PYCCALL #define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))))) + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if CYTHON_USE_DICT_VERSIONS +#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ + (version_var) = __PYX_GET_DICT_VERSION(dict);\ + (cache_var) = (value); +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ + static PY_UINT64_T __pyx_dict_version = 0;\ + static PyObject *__pyx_dict_cached_value = NULL;\ + if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ + (VAR) = __pyx_dict_cached_value;\ + } else {\ + (VAR) = __pyx_dict_cached_value = (LOOKUP);\ + __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ + }\ + } +#else +#define __PYX_GET_DICT_VERSION(dict) (0) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 + #define PyMem_RawMalloc(n) PyMem_Malloc(n) + #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) + #define PyMem_RawFree(p) PyMem_Free(p) +#endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) +#include "pythread.h" +#define Py_tss_NEEDS_INIT 0 +typedef int Py_tss_t; +static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { + *key = PyThread_create_key(); + return 0; // PyThread_create_key reports success always +} +static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { + Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); + *key = Py_tss_NEEDS_INIT; + return key; +} +static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { + PyObject_Free(key); +} +static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { + return *key != Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { + PyThread_delete_key(*key); + *key = Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { + return PyThread_set_key_value(*key, value); +} +static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { + return PyThread_get_key_value(*key); +} +#endif // TSS (Thread Specific Storage) API +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS +#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) +#else +#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -253,20 +505,8 @@ #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) - #define PyObject_Malloc(s) PyMem_Malloc(s) - #define PyObject_Free(p) PyMem_Free(p) - #define PyObject_Realloc(p) PyMem_Realloc(p) -#endif -#if CYTHON_COMPILING_IN_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) -#else - #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) -#endif -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else @@ -281,6 +521,7 @@ #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact + #define PyObject_Unicode PyObject_Str #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) @@ -292,8 +533,11 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) +#if CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) +#else + #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) +#endif #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type @@ -328,112 +572,26 @@ #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif -#ifndef __has_cpp_attribute - #define __has_cpp_attribute(x) 0 -#endif #if CYTHON_USE_ASYNC_SLOTS #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #endif #else #define __Pyx_PyType_AsAsync(obj) NULL #endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict - #else - #define CYTHON_RESTRICT - #endif -#endif -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -#ifndef CYTHON_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) -#ifdef _MSC_VER - #ifndef _MSC_STDINT_H_ - #if _MSC_VER < 1300 - typedef unsigned char uint8_t; - typedef unsigned int uint32_t; - #else - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - #endif - #endif -#else - #include -#endif -#ifndef CYTHON_FALLTHROUGH - #ifdef __cplusplus - #if __has_cpp_attribute(fallthrough) - #define CYTHON_FALLTHROUGH [[fallthrough]] - #elif __has_cpp_attribute(clang::fallthrough) - #define CYTHON_FALLTHROUGH [[clang::fallthrough]] - #endif - #endif - #ifndef CYTHON_FALLTHROUGH - #if __has_attribute(fallthrough) || (defined(__GNUC__) && defined(__attribute__)) - #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) - #else - #define CYTHON_FALLTHROUGH - #endif - #endif -#endif - -#ifndef CYTHON_INLINE - #if defined(__clang__) - #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) - #elif defined(__GNUC__) - #define CYTHON_INLINE __inline__ - #elif defined(_MSC_VER) - #define CYTHON_INLINE __inline - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_INLINE inline - #else - #define CYTHON_INLINE - #endif +#ifndef __Pyx_PyAsyncMethodsStruct + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; #endif #if defined(WIN32) || defined(MS_WINDOWS) @@ -461,14 +619,6 @@ static CYTHON_INLINE float __PYX_NAN() { __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ } -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -479,16 +629,16 @@ static CYTHON_INLINE float __PYX_NAN() { #define __PYX_HAVE__utils__cython_bbox #define __PYX_HAVE_API__utils__cython_bbox +/* Early includes */ #include #include -#include #include "numpy/arrayobject.h" #include "numpy/ufuncobject.h" #ifdef _OPENMP #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -512,6 +662,9 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) +static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { + return (size_t) i < (size_t) limit; +} #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) @@ -519,8 +672,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) -#elif defined (_MSC_VER) && defined (_M_X64) - #define __Pyx_sst_abs(value) _abs64(value) +#elif defined (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -542,6 +695,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -552,24 +711,22 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -#if PY_MAJOR_VERSION < 3 -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -647,7 +804,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); @@ -670,10 +827,10 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime; +static PyObject *__pyx_cython_runtime = NULL; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static PyObject *__pyx_empty_unicode; @@ -746,8 +903,20 @@ typedef struct { char is_valid_array; } __Pyx_BufFmt_Context; +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":725 + +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< @@ -756,7 +925,7 @@ typedef struct { */ typedef npy_int8 __pyx_t_5numpy_int8_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":726 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< @@ -765,7 +934,7 @@ typedef npy_int8 __pyx_t_5numpy_int8_t; */ typedef npy_int16 __pyx_t_5numpy_int16_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":727 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< @@ -774,7 +943,7 @@ typedef npy_int16 __pyx_t_5numpy_int16_t; */ typedef npy_int32 __pyx_t_5numpy_int32_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":728 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< @@ -783,7 +952,7 @@ typedef npy_int32 __pyx_t_5numpy_int32_t; */ typedef npy_int64 __pyx_t_5numpy_int64_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":732 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< @@ -792,7 +961,7 @@ typedef npy_int64 __pyx_t_5numpy_int64_t; */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":733 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":784 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< @@ -801,7 +970,7 @@ typedef npy_uint8 __pyx_t_5numpy_uint8_t; */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":734 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< @@ -810,7 +979,7 @@ typedef npy_uint16 __pyx_t_5numpy_uint16_t; */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":735 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":786 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< @@ -819,7 +988,7 @@ typedef npy_uint32 __pyx_t_5numpy_uint32_t; */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":739 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< @@ -828,7 +997,7 @@ typedef npy_uint64 __pyx_t_5numpy_uint64_t; */ typedef npy_float32 __pyx_t_5numpy_float32_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":740 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< @@ -837,7 +1006,7 @@ typedef npy_float32 __pyx_t_5numpy_float32_t; */ typedef npy_float64 __pyx_t_5numpy_float64_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":749 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":800 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< @@ -846,7 +1015,7 @@ typedef npy_float64 __pyx_t_5numpy_float64_t; */ typedef npy_long __pyx_t_5numpy_int_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":750 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< @@ -855,7 +1024,7 @@ typedef npy_long __pyx_t_5numpy_int_t; */ typedef npy_longlong __pyx_t_5numpy_long_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":751 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< @@ -864,7 +1033,7 @@ typedef npy_longlong __pyx_t_5numpy_long_t; */ typedef npy_longlong __pyx_t_5numpy_longlong_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":753 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":804 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< @@ -873,7 +1042,7 @@ typedef npy_longlong __pyx_t_5numpy_longlong_t; */ typedef npy_ulong __pyx_t_5numpy_uint_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":754 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":805 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< @@ -882,7 +1051,7 @@ typedef npy_ulong __pyx_t_5numpy_uint_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":755 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":806 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< @@ -891,7 +1060,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":757 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":808 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< @@ -900,7 +1069,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; */ typedef npy_intp __pyx_t_5numpy_intp_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":758 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":809 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< @@ -909,7 +1078,7 @@ typedef npy_intp __pyx_t_5numpy_intp_t; */ typedef npy_uintp __pyx_t_5numpy_uintp_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":760 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":811 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< @@ -918,7 +1087,7 @@ typedef npy_uintp __pyx_t_5numpy_uintp_t; */ typedef npy_double __pyx_t_5numpy_float_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":761 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":812 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< @@ -927,7 +1096,7 @@ typedef npy_double __pyx_t_5numpy_float_t; */ typedef npy_double __pyx_t_5numpy_double_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":762 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< @@ -971,7 +1140,7 @@ static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(do /*--- Type declarations ---*/ -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":764 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< @@ -980,7 +1149,7 @@ static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(do */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":765 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< @@ -989,7 +1158,7 @@ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":766 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":817 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< @@ -998,7 +1167,7 @@ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":768 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":819 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< @@ -1073,16 +1242,7 @@ typedef npy_cdouble __pyx_t_5numpy_complex_t; /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro)) - return tp->tp_getattro(obj, attr_name); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif @@ -1103,23 +1263,52 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ const char* function_name); /* ArgTypeTest.proto */ -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* IsLittleEndian.proto */ static CYTHON_INLINE int __Pyx_Is_Little_Endian(void); /* BufferFormatCheck.proto */ -static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, - __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); -static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts); static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, __Pyx_BufFmt_StackElem* stack, __Pyx_TypeInfo* type); +/* BufferGetAndValidate.proto */ +#define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\ + ((obj == Py_None || obj == NULL) ?\ + (__Pyx_ZeroBuffer(buf), 0) :\ + __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)) +static int __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj, + __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +static void __Pyx_ZeroBuffer(Py_buffer* buf); +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); +static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; +static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + /* GetModuleGlobalName.proto */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); +#if CYTHON_USE_DICT_VERSIONS +#define __Pyx_GetModuleGlobalName(var, name) {\ + static PY_UINT64_T __pyx_dict_version = 0;\ + static PyObject *__pyx_dict_cached_value = NULL;\ + (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ + (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ + __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ +} +#define __Pyx_GetModuleGlobalNameUncached(var, name) {\ + PY_UINT64_T __pyx_dict_version;\ + PyObject *__pyx_dict_cached_value;\ + (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ +} +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); +#else +#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) +#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); +#endif /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON @@ -1131,39 +1320,39 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg /* ExtTypeTest.proto */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); -/* NoFastGil.proto */ -#define __Pyx_PyGILState_Ensure PyGILState_Ensure -#define __Pyx_PyGILState_Release PyGILState_Release -#define __Pyx_FastGIL_Remember() -#define __Pyx_FastGIL_Forget() -#define __Pyx_FastGilFuncInit() - #define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif - /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif #else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif @@ -1171,25 +1360,53 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif +#define __Pyx_BUILD_ASSERT_EXPR(cond)\ + (sizeof(char [1 - 2*!(cond)]) - 1) +#ifndef Py_MEMBER_SIZE +#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) +#endif + static size_t __pyx_pyframe_localsplus_offset = 0; + #include "frameobject.h" + #define __Pxy_PyFrame_Initialize_Offsets()\ + ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ + (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) + #define __Pyx_PyFrame_GetLocalsplus(frame)\ + (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) +#endif + +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY -static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { - PyObject *value; - value = PyDict_GetItemWithError(d, key); - if (unlikely(!value)) { - if (!PyErr_Occurred()) { - PyObject* args = PyTuple_Pack(1, key); - if (likely(args)) - PyErr_SetObject(PyExc_KeyError, args); - Py_XDECREF(args); - } - return NULL; - } - Py_INCREF(value); - return value; -} +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); +#define __Pyx_PyObject_Dict_GetItem(obj, name)\ + (likely(PyDict_CheckExact(obj)) ?\ + __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) #else - #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) #endif /* RaiseTooManyValuesToUnpack.proto */ @@ -1201,6 +1418,11 @@ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); /* RaiseNoneIterError.proto */ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); +/* GetTopmostException.proto */ +#if CYTHON_USE_EXC_INFO_STACK +static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); +#endif + /* SaveResetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) @@ -1228,11 +1450,26 @@ static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); #endif +/* TypeImport.proto */ +#ifndef __PYX_HAVE_RT_ImportType_proto +#define __PYX_HAVE_RT_ImportType_proto +enum __Pyx_ImportType_CheckSize { + __Pyx_ImportType_CheckSize_Error = 0, + __Pyx_ImportType_CheckSize_Warn = 1, + __Pyx_ImportType_CheckSize_Ignore = 2 +}; +static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size); +#endif + /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /* CLineInTraceback.proto */ -static int __Pyx_CLineForTraceback(int c_line); +#ifdef CYTHON_CLINE_IN_TRACEBACK +#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) +#else +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); +#endif /* CodeObjectCache.proto */ typedef struct { @@ -1276,10 +1513,6 @@ typedef struct { #endif -/* None.proto */ -static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; -static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; - /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value); @@ -1399,23 +1632,21 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* PyIdentifierFromString.proto */ -#if !defined(__Pyx_PyIdentifier_FromString) -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else - #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) -#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) #endif +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) -/* ModuleImport.proto */ -static PyObject *__Pyx_ImportModule(const char *name); - -/* TypeImport.proto */ -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); +/* CheckBinaryVersion.proto */ +static int __Pyx_check_binary_version(void); /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); @@ -1440,7 +1671,7 @@ static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; /* Module declarations from 'cpython.ref' */ -/* Module declarations from 'libc.stdlib' */ +/* Module declarations from 'cpython.mem' */ /* Module declarations from 'numpy' */ @@ -1455,6 +1686,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, cha /* Module declarations from 'utils.cython_bbox' */ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5utils_11cython_bbox_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_5utils_11cython_bbox_DTYPE_t), { 0 }, 0, 'R', 0, 0 }; #define __Pyx_MODULE_NAME "utils.cython_bbox" +extern int __pyx_module_is_main_utils__cython_bbox; int __pyx_module_is_main_utils__cython_bbox = 0; /* Implementation of 'utils.cython_bbox' */ @@ -1471,6 +1703,7 @@ static const char __pyx_k_iw[] = "iw"; static const char __pyx_k_np[] = "np"; static const char __pyx_k_ua[] = "ua"; static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_DTYPE[] = "DTYPE"; static const char __pyx_k_boxes[] = "boxes"; @@ -1519,6 +1752,7 @@ static PyObject *__pyx_n_s_iw; static PyObject *__pyx_n_s_k; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_n; +static PyObject *__pyx_n_s_name; static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; static PyObject *__pyx_n_s_np; @@ -1545,9 +1779,8 @@ static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; -static PyObject *__pyx_tuple__9; -static PyObject *__pyx_tuple__10; -static PyObject *__pyx_codeobj__11; +static PyObject *__pyx_codeobj__9; +/* Late includes */ /* "utils/cython_bbox.pyx":32 * @@ -1560,7 +1793,7 @@ static PyObject *__pyx_codeobj__11; /* Python wrapper */ static PyObject *__pyx_pw_5utils_11cython_bbox_1bbox_overlaps(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_5utils_11cython_bbox_bbox_overlaps[] = "\n Parameters\n ----------\n boxes: (N, 4) ndarray of float\n query_boxes: (K, 4) ndarray of float\n Returns\n -------\n overlaps: (N, K) ndarray of overlap between boxes and query_boxes\n "; -static PyMethodDef __pyx_mdef_5utils_11cython_bbox_1bbox_overlaps = {"bbox_overlaps", (PyCFunction)__pyx_pw_5utils_11cython_bbox_1bbox_overlaps, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5utils_11cython_bbox_bbox_overlaps}; +static PyMethodDef __pyx_mdef_5utils_11cython_bbox_1bbox_overlaps = {"bbox_overlaps", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5utils_11cython_bbox_1bbox_overlaps, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5utils_11cython_bbox_bbox_overlaps}; static PyObject *__pyx_pw_5utils_11cython_bbox_1bbox_overlaps(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_boxes = 0; PyArrayObject *__pyx_v_query_boxes = 0; @@ -1584,11 +1817,11 @@ static PyObject *__pyx_pw_5utils_11cython_bbox_1bbox_overlaps(PyObject *__pyx_se kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_boxes)) != 0)) kw_args--; + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_boxes)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_query_boxes)) != 0)) kw_args--; + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_query_boxes)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("bbox_overlaps", 1, 2, 2, 1); __PYX_ERR(0, 32, __pyx_L3_error) } @@ -1651,31 +1884,31 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj PyArrayObject *__pyx_t_5 = NULL; unsigned int __pyx_t_6; unsigned int __pyx_t_7; - size_t __pyx_t_8; - Py_ssize_t __pyx_t_9; - size_t __pyx_t_10; - Py_ssize_t __pyx_t_11; - size_t __pyx_t_12; - Py_ssize_t __pyx_t_13; - size_t __pyx_t_14; - Py_ssize_t __pyx_t_15; - unsigned int __pyx_t_16; + unsigned int __pyx_t_8; + size_t __pyx_t_9; + Py_ssize_t __pyx_t_10; + size_t __pyx_t_11; + Py_ssize_t __pyx_t_12; + size_t __pyx_t_13; + Py_ssize_t __pyx_t_14; + size_t __pyx_t_15; + Py_ssize_t __pyx_t_16; unsigned int __pyx_t_17; - size_t __pyx_t_18; - Py_ssize_t __pyx_t_19; - __pyx_t_5utils_11cython_bbox_DTYPE_t __pyx_t_20; - size_t __pyx_t_21; - Py_ssize_t __pyx_t_22; - __pyx_t_5utils_11cython_bbox_DTYPE_t __pyx_t_23; - __pyx_t_5utils_11cython_bbox_DTYPE_t __pyx_t_24; - size_t __pyx_t_25; - Py_ssize_t __pyx_t_26; + unsigned int __pyx_t_18; + unsigned int __pyx_t_19; + size_t __pyx_t_20; + Py_ssize_t __pyx_t_21; + __pyx_t_5utils_11cython_bbox_DTYPE_t __pyx_t_22; + size_t __pyx_t_23; + Py_ssize_t __pyx_t_24; + __pyx_t_5utils_11cython_bbox_DTYPE_t __pyx_t_25; + __pyx_t_5utils_11cython_bbox_DTYPE_t __pyx_t_26; size_t __pyx_t_27; Py_ssize_t __pyx_t_28; - __pyx_t_5utils_11cython_bbox_DTYPE_t __pyx_t_29; - int __pyx_t_30; - size_t __pyx_t_31; - Py_ssize_t __pyx_t_32; + size_t __pyx_t_29; + Py_ssize_t __pyx_t_30; + __pyx_t_5utils_11cython_bbox_DTYPE_t __pyx_t_31; + int __pyx_t_32; size_t __pyx_t_33; Py_ssize_t __pyx_t_34; size_t __pyx_t_35; @@ -1691,7 +1924,9 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj size_t __pyx_t_45; Py_ssize_t __pyx_t_46; size_t __pyx_t_47; - size_t __pyx_t_48; + Py_ssize_t __pyx_t_48; + size_t __pyx_t_49; + size_t __pyx_t_50; __Pyx_RefNannySetupContext("bbox_overlaps", 0); __pyx_pybuffer_overlaps.pybuffer.buf = NULL; __pyx_pybuffer_overlaps.refcount = 0; @@ -1741,7 +1976,7 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * cdef DTYPE_t iw, ih, box_area * cdef DTYPE_t ua */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); @@ -1763,9 +1998,9 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 46, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1811,8 +2046,9 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * (query_boxes[k, 2] - query_boxes[k, 0] + 1) * */ __pyx_t_6 = __pyx_v_K; - for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { - __pyx_v_k = __pyx_t_7; + __pyx_t_7 = __pyx_t_6; + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { + __pyx_v_k = __pyx_t_8; /* "utils/cython_bbox.pyx":53 * for k in range(K): @@ -1821,12 +2057,12 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * (query_boxes[k, 3] - query_boxes[k, 1] + 1) * ) */ - __pyx_t_8 = __pyx_v_k; - __pyx_t_9 = 2; - if (__pyx_t_9 < 0) __pyx_t_9 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; - __pyx_t_10 = __pyx_v_k; - __pyx_t_11 = 0; - if (__pyx_t_11 < 0) __pyx_t_11 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; + __pyx_t_9 = __pyx_v_k; + __pyx_t_10 = 2; + if (__pyx_t_10 < 0) __pyx_t_10 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; + __pyx_t_11 = __pyx_v_k; + __pyx_t_12 = 0; + if (__pyx_t_12 < 0) __pyx_t_12 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; /* "utils/cython_bbox.pyx":54 * box_area = ( @@ -1835,12 +2071,12 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * ) * for n in range(N): */ - __pyx_t_12 = __pyx_v_k; - __pyx_t_13 = 3; - if (__pyx_t_13 < 0) __pyx_t_13 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; - __pyx_t_14 = __pyx_v_k; - __pyx_t_15 = 1; - if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; + __pyx_t_13 = __pyx_v_k; + __pyx_t_14 = 3; + if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; + __pyx_t_15 = __pyx_v_k; + __pyx_t_16 = 1; + if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; /* "utils/cython_bbox.pyx":53 * for k in range(K): @@ -1849,7 +2085,7 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * (query_boxes[k, 3] - query_boxes[k, 1] + 1) * ) */ - __pyx_v_box_area = ((((*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_9, __pyx_pybuffernd_query_boxes.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_11, __pyx_pybuffernd_query_boxes.diminfo[1].strides))) + 1.0) * (((*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_query_boxes.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_query_boxes.diminfo[1].strides))) + 1.0)); + __pyx_v_box_area = ((((*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_10, __pyx_pybuffernd_query_boxes.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_query_boxes.diminfo[1].strides))) + 1.0) * (((*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_query_boxes.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_query_boxes.diminfo[1].strides))) + 1.0)); /* "utils/cython_bbox.pyx":56 * (query_boxes[k, 3] - query_boxes[k, 1] + 1) @@ -1858,9 +2094,10 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * iw = ( * min(boxes[n, 2], query_boxes[k, 2]) - */ - __pyx_t_16 = __pyx_v_N; - for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { - __pyx_v_n = __pyx_t_17; + __pyx_t_17 = __pyx_v_N; + __pyx_t_18 = __pyx_t_17; + for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { + __pyx_v_n = __pyx_t_19; /* "utils/cython_bbox.pyx":58 * for n in range(N): @@ -1869,18 +2106,18 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * max(boxes[n, 0], query_boxes[k, 0]) + 1 * ) */ - __pyx_t_18 = __pyx_v_k; - __pyx_t_19 = 2; - if (__pyx_t_19 < 0) __pyx_t_19 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; - __pyx_t_20 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_query_boxes.diminfo[1].strides)); - __pyx_t_21 = __pyx_v_n; - __pyx_t_22 = 2; - if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_pybuffernd_boxes.diminfo[1].shape; - __pyx_t_23 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_boxes.diminfo[1].strides)); - if (((__pyx_t_20 < __pyx_t_23) != 0)) { - __pyx_t_24 = __pyx_t_20; + __pyx_t_20 = __pyx_v_k; + __pyx_t_21 = 2; + if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; + __pyx_t_22 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_query_boxes.diminfo[1].strides)); + __pyx_t_23 = __pyx_v_n; + __pyx_t_24 = 2; + if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_pybuffernd_boxes.diminfo[1].shape; + __pyx_t_25 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_boxes.diminfo[1].strides)); + if (((__pyx_t_22 < __pyx_t_25) != 0)) { + __pyx_t_26 = __pyx_t_22; } else { - __pyx_t_24 = __pyx_t_23; + __pyx_t_26 = __pyx_t_25; } /* "utils/cython_bbox.pyx":59 @@ -1890,18 +2127,18 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * ) * if iw > 0: */ - __pyx_t_25 = __pyx_v_k; - __pyx_t_26 = 0; - if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; - __pyx_t_20 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_query_boxes.diminfo[1].strides)); - __pyx_t_27 = __pyx_v_n; + __pyx_t_27 = __pyx_v_k; __pyx_t_28 = 0; - if (__pyx_t_28 < 0) __pyx_t_28 += __pyx_pybuffernd_boxes.diminfo[1].shape; - __pyx_t_23 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_boxes.diminfo[1].strides)); - if (((__pyx_t_20 > __pyx_t_23) != 0)) { - __pyx_t_29 = __pyx_t_20; + if (__pyx_t_28 < 0) __pyx_t_28 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; + __pyx_t_22 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_query_boxes.diminfo[1].strides)); + __pyx_t_29 = __pyx_v_n; + __pyx_t_30 = 0; + if (__pyx_t_30 < 0) __pyx_t_30 += __pyx_pybuffernd_boxes.diminfo[1].shape; + __pyx_t_25 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_30, __pyx_pybuffernd_boxes.diminfo[1].strides)); + if (((__pyx_t_22 > __pyx_t_25) != 0)) { + __pyx_t_31 = __pyx_t_22; } else { - __pyx_t_29 = __pyx_t_23; + __pyx_t_31 = __pyx_t_25; } /* "utils/cython_bbox.pyx":58 @@ -1911,7 +2148,7 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * max(boxes[n, 0], query_boxes[k, 0]) + 1 * ) */ - __pyx_v_iw = ((__pyx_t_24 - __pyx_t_29) + 1.0); + __pyx_v_iw = ((__pyx_t_26 - __pyx_t_31) + 1.0); /* "utils/cython_bbox.pyx":61 * max(boxes[n, 0], query_boxes[k, 0]) + 1 @@ -1920,8 +2157,8 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * ih = ( * min(boxes[n, 3], query_boxes[k, 3]) - */ - __pyx_t_30 = ((__pyx_v_iw > 0.0) != 0); - if (__pyx_t_30) { + __pyx_t_32 = ((__pyx_v_iw > 0.0) != 0); + if (__pyx_t_32) { /* "utils/cython_bbox.pyx":63 * if iw > 0: @@ -1930,18 +2167,18 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * max(boxes[n, 1], query_boxes[k, 1]) + 1 * ) */ - __pyx_t_31 = __pyx_v_k; - __pyx_t_32 = 3; - if (__pyx_t_32 < 0) __pyx_t_32 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; - __pyx_t_29 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_32, __pyx_pybuffernd_query_boxes.diminfo[1].strides)); - __pyx_t_33 = __pyx_v_n; + __pyx_t_33 = __pyx_v_k; __pyx_t_34 = 3; - if (__pyx_t_34 < 0) __pyx_t_34 += __pyx_pybuffernd_boxes.diminfo[1].shape; - __pyx_t_24 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_34, __pyx_pybuffernd_boxes.diminfo[1].strides)); - if (((__pyx_t_29 < __pyx_t_24) != 0)) { - __pyx_t_20 = __pyx_t_29; + if (__pyx_t_34 < 0) __pyx_t_34 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; + __pyx_t_31 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_34, __pyx_pybuffernd_query_boxes.diminfo[1].strides)); + __pyx_t_35 = __pyx_v_n; + __pyx_t_36 = 3; + if (__pyx_t_36 < 0) __pyx_t_36 += __pyx_pybuffernd_boxes.diminfo[1].shape; + __pyx_t_26 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_36, __pyx_pybuffernd_boxes.diminfo[1].strides)); + if (((__pyx_t_31 < __pyx_t_26) != 0)) { + __pyx_t_22 = __pyx_t_31; } else { - __pyx_t_20 = __pyx_t_24; + __pyx_t_22 = __pyx_t_26; } /* "utils/cython_bbox.pyx":64 @@ -1951,18 +2188,18 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * ) * if ih > 0: */ - __pyx_t_35 = __pyx_v_k; - __pyx_t_36 = 1; - if (__pyx_t_36 < 0) __pyx_t_36 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; - __pyx_t_29 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_36, __pyx_pybuffernd_query_boxes.diminfo[1].strides)); - __pyx_t_37 = __pyx_v_n; + __pyx_t_37 = __pyx_v_k; __pyx_t_38 = 1; - if (__pyx_t_38 < 0) __pyx_t_38 += __pyx_pybuffernd_boxes.diminfo[1].shape; - __pyx_t_24 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_38, __pyx_pybuffernd_boxes.diminfo[1].strides)); - if (((__pyx_t_29 > __pyx_t_24) != 0)) { - __pyx_t_23 = __pyx_t_29; + if (__pyx_t_38 < 0) __pyx_t_38 += __pyx_pybuffernd_query_boxes.diminfo[1].shape; + __pyx_t_31 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_query_boxes.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_query_boxes.diminfo[0].strides, __pyx_t_38, __pyx_pybuffernd_query_boxes.diminfo[1].strides)); + __pyx_t_39 = __pyx_v_n; + __pyx_t_40 = 1; + if (__pyx_t_40 < 0) __pyx_t_40 += __pyx_pybuffernd_boxes.diminfo[1].shape; + __pyx_t_26 = (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_40, __pyx_pybuffernd_boxes.diminfo[1].strides)); + if (((__pyx_t_31 > __pyx_t_26) != 0)) { + __pyx_t_25 = __pyx_t_31; } else { - __pyx_t_23 = __pyx_t_24; + __pyx_t_25 = __pyx_t_26; } /* "utils/cython_bbox.pyx":63 @@ -1972,7 +2209,7 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * max(boxes[n, 1], query_boxes[k, 1]) + 1 * ) */ - __pyx_v_ih = ((__pyx_t_20 - __pyx_t_23) + 1.0); + __pyx_v_ih = ((__pyx_t_22 - __pyx_t_25) + 1.0); /* "utils/cython_bbox.pyx":66 * max(boxes[n, 1], query_boxes[k, 1]) + 1 @@ -1981,8 +2218,8 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * ua = float( * (boxes[n, 2] - boxes[n, 0] + 1) * */ - __pyx_t_30 = ((__pyx_v_ih > 0.0) != 0); - if (__pyx_t_30) { + __pyx_t_32 = ((__pyx_v_ih > 0.0) != 0); + if (__pyx_t_32) { /* "utils/cython_bbox.pyx":68 * if ih > 0: @@ -1991,12 +2228,12 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * (boxes[n, 3] - boxes[n, 1] + 1) + * box_area - iw * ih */ - __pyx_t_39 = __pyx_v_n; - __pyx_t_40 = 2; - if (__pyx_t_40 < 0) __pyx_t_40 += __pyx_pybuffernd_boxes.diminfo[1].shape; __pyx_t_41 = __pyx_v_n; - __pyx_t_42 = 0; + __pyx_t_42 = 2; if (__pyx_t_42 < 0) __pyx_t_42 += __pyx_pybuffernd_boxes.diminfo[1].shape; + __pyx_t_43 = __pyx_v_n; + __pyx_t_44 = 0; + if (__pyx_t_44 < 0) __pyx_t_44 += __pyx_pybuffernd_boxes.diminfo[1].shape; /* "utils/cython_bbox.pyx":69 * ua = float( @@ -2005,12 +2242,12 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * box_area - iw * ih * ) */ - __pyx_t_43 = __pyx_v_n; - __pyx_t_44 = 3; - if (__pyx_t_44 < 0) __pyx_t_44 += __pyx_pybuffernd_boxes.diminfo[1].shape; __pyx_t_45 = __pyx_v_n; - __pyx_t_46 = 1; + __pyx_t_46 = 3; if (__pyx_t_46 < 0) __pyx_t_46 += __pyx_pybuffernd_boxes.diminfo[1].shape; + __pyx_t_47 = __pyx_v_n; + __pyx_t_48 = 1; + if (__pyx_t_48 < 0) __pyx_t_48 += __pyx_pybuffernd_boxes.diminfo[1].shape; /* "utils/cython_bbox.pyx":67 * ) @@ -2019,7 +2256,7 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * (boxes[n, 2] - boxes[n, 0] + 1) * * (boxes[n, 3] - boxes[n, 1] + 1) + */ - __pyx_v_ua = ((double)((((((*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_40, __pyx_pybuffernd_boxes.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_41, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_42, __pyx_pybuffernd_boxes.diminfo[1].strides))) + 1.0) * (((*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_43, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_44, __pyx_pybuffernd_boxes.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_45, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_46, __pyx_pybuffernd_boxes.diminfo[1].strides))) + 1.0)) + __pyx_v_box_area) - (__pyx_v_iw * __pyx_v_ih))); + __pyx_v_ua = ((double)((((((*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_41, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_42, __pyx_pybuffernd_boxes.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_43, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_44, __pyx_pybuffernd_boxes.diminfo[1].strides))) + 1.0) * (((*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_45, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_46, __pyx_pybuffernd_boxes.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_boxes.rcbuffer->pybuffer.buf, __pyx_t_47, __pyx_pybuffernd_boxes.diminfo[0].strides, __pyx_t_48, __pyx_pybuffernd_boxes.diminfo[1].strides))) + 1.0)) + __pyx_v_box_area) - (__pyx_v_iw * __pyx_v_ih))); /* "utils/cython_bbox.pyx":72 * box_area - iw * ih @@ -2027,7 +2264,7 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj * overlaps[n, k] = iw * ih / ua # <<<<<<<<<<<<<< * return overlaps */ - __pyx_t_23 = (__pyx_v_iw * __pyx_v_ih); + __pyx_t_25 = (__pyx_v_iw * __pyx_v_ih); if (unlikely(__pyx_v_ua == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); @@ -2038,9 +2275,9 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj #endif __PYX_ERR(0, 72, __pyx_L4_error) } - __pyx_t_47 = __pyx_v_n; - __pyx_t_48 = __pyx_v_k; - *__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_overlaps.rcbuffer->pybuffer.buf, __pyx_t_47, __pyx_pybuffernd_overlaps.diminfo[0].strides, __pyx_t_48, __pyx_pybuffernd_overlaps.diminfo[1].strides) = (__pyx_t_23 / __pyx_v_ua); + __pyx_t_49 = __pyx_v_n; + __pyx_t_50 = __pyx_v_k; + *__Pyx_BufPtrStrided2d(__pyx_t_5utils_11cython_bbox_DTYPE_t *, __pyx_pybuffernd_overlaps.rcbuffer->pybuffer.buf, __pyx_t_49, __pyx_pybuffernd_overlaps.diminfo[0].strides, __pyx_t_50, __pyx_pybuffernd_overlaps.diminfo[1].strides) = (__pyx_t_25 / __pyx_v_ua); /* "utils/cython_bbox.pyx":66 * max(boxes[n, 1], query_boxes[k, 1]) + 1 @@ -2135,12 +2372,12 @@ static PyObject *__pyx_pf_5utils_11cython_bbox_bbox_overlaps(CYTHON_UNUSED PyObj return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":197 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fullfill the PEP. + * # requirements, and does not yet fulfill the PEP. */ /* Python wrapper */ @@ -2157,7 +2394,6 @@ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx } static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_v_copy_shape; int __pyx_v_i; int __pyx_v_ndim; int __pyx_v_endian_detector; @@ -2166,7 +2402,6 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P char *__pyx_v_f; PyArray_Descr *__pyx_v_descr = 0; int __pyx_v_offset; - int __pyx_v_hasfields; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -2174,265 +2409,216 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - char *__pyx_t_7; - __Pyx_RefNannySetupContext("__getbuffer__", 0); - if (__pyx_v_info != NULL) { - __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(__pyx_v_info->obj); - } - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":203 - * # of flags - * - * if info == NULL: return # <<<<<<<<<<<<<< - * - * cdef int copy_shape, i, ndim - */ - __pyx_t_1 = ((__pyx_v_info == NULL) != 0); - if (__pyx_t_1) { - __pyx_r = 0; - goto __pyx_L0; + int __pyx_t_6; + PyArray_Descr *__pyx_t_7; + PyObject *__pyx_t_8 = NULL; + char *__pyx_t_9; + if (__pyx_v_info == NULL) { + PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete"); + return -1; } + __Pyx_RefNannySetupContext("__getbuffer__", 0); + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":206 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 * - * cdef int copy_shape, i, ndim + * cdef int i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< - * cdef bint little_endian = ((&endian_detector)[0] != 0) - * - */ - __pyx_v_endian_detector = 1; - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":207 - * cdef int copy_shape, i, ndim - * cdef int endian_detector = 1 - * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< - * - * ndim = PyArray_NDIM(self) - */ - __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":209 - * cdef bint little_endian = ((&endian_detector)[0] != 0) - * - * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< - * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - */ - __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":211 - * ndim = PyArray_NDIM(self) - * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * copy_shape = 1 - * else: - */ - __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); - if (__pyx_t_1) { - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":212 + * cdef bint little_endian = ((&endian_detector)[0] != 0) * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * copy_shape = 1 # <<<<<<<<<<<<<< - * else: - * copy_shape = 0 */ - __pyx_v_copy_shape = 1; + __pyx_v_endian_detector = 1; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":211 - * ndim = PyArray_NDIM(self) + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 + * cdef int i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * copy_shape = 1 - * else: + * ndim = PyArray_NDIM(self) */ - goto __pyx_L4; - } + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":214 - * copy_shape = 1 - * else: - * copy_shape = 0 # <<<<<<<<<<<<<< + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) */ - /*else*/ { - __pyx_v_copy_shape = 0; - } - __pyx_L4:; + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":216 - * copy_shape = 0 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * ndim = PyArray_NDIM(self) * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; - goto __pyx_L6_bool_binop_done; + goto __pyx_L4_bool_binop_done; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":217 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not C contiguous") * */ - __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_ARRAY_C_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; - __pyx_L6_bool_binop_done:; + __pyx_L4_bool_binop_done:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":216 - * copy_shape = 0 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * ndim = PyArray_NDIM(self) * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ - if (__pyx_t_1) { + if (unlikely(__pyx_t_1)) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":218 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 218, __pyx_L1_error) + __PYX_ERR(1, 272, __pyx_L1_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":216 - * copy_shape = 0 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * ndim = PyArray_NDIM(self) * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; - goto __pyx_L9_bool_binop_done; + goto __pyx_L7_bool_binop_done; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":221 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not Fortran contiguous") * */ - __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_ARRAY_F_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; - __pyx_L9_bool_binop_done:; + __pyx_L7_bool_binop_done:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ - if (__pyx_t_1) { + if (unlikely(__pyx_t_1)) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":222 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 222, __pyx_L1_error) + __PYX_ERR(1, 276, __pyx_L1_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":224 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< * info.ndim = ndim - * if copy_shape: + * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":225 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< - * if copy_shape: + * if sizeof(npy_intp) != sizeof(Py_ssize_t): * # Allocate new buffer for strides and shape info. */ __pyx_v_info->ndim = __pyx_v_ndim; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":226 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * info.buf = PyArray_DATA(self) * info.ndim = ndim - * if copy_shape: # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ - __pyx_t_1 = (__pyx_v_copy_shape != 0); + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":229 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) # <<<<<<<<<<<<<< * info.shape = info.strides + ndim * for i in range(ndim): */ - __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); + __pyx_v_info->strides = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * 2) * ((size_t)__pyx_v_ndim)))); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":230 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 * # This is allocated as one block, strides first. - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":231 - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] */ __pyx_t_4 = __pyx_v_ndim; - for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { - __pyx_v_i = __pyx_t_5; + __pyx_t_5 = __pyx_t_4; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":232 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":286 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< @@ -2441,7 +2627,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":233 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":287 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< @@ -2451,17 +2637,17 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":226 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * info.buf = PyArray_DATA(self) * info.ndim = ndim - * if copy_shape: # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ - goto __pyx_L11; + goto __pyx_L9; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":235 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":289 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< @@ -2471,7 +2657,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P /*else*/ { __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":236 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< @@ -2480,9 +2666,9 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); } - __pyx_L11:; + __pyx_L9:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":237 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< @@ -2491,7 +2677,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->suboffsets = NULL; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":238 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< @@ -2500,7 +2686,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":239 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< @@ -2509,106 +2695,54 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":242 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":296 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< - * cdef dtype descr = self.descr + * cdef dtype descr = PyArray_DESCR(self) * cdef int offset */ __pyx_v_f = NULL; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":243 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":297 * cdef int t * cdef char* f = NULL - * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef dtype descr = PyArray_DESCR(self) # <<<<<<<<<<<<<< * cdef int offset * */ - __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); + __pyx_t_7 = PyArray_DESCR(__pyx_v_self); + __pyx_t_3 = ((PyObject *)__pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":246 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":300 * cdef int offset * - * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< - * - * if not hasfields and not copy_shape: - */ - __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":248 - * cdef bint hasfields = PyDataType_HASFIELDS(descr) - * - * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< - * # do not call releasebuffer - * info.obj = None - */ - __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L15_bool_binop_done; - } - __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L15_bool_binop_done:; - if (__pyx_t_1) { - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":250 - * if not hasfields and not copy_shape: - * # do not call releasebuffer - * info.obj = None # <<<<<<<<<<<<<< - * else: - * # need to call releasebuffer - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = Py_None; - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":248 - * cdef bint hasfields = PyDataType_HASFIELDS(descr) - * - * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< - * # do not call releasebuffer - * info.obj = None - */ - goto __pyx_L14; - } - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":253 - * else: - * # need to call releasebuffer - * info.obj = self # <<<<<<<<<<<<<< + * info.obj = self # <<<<<<<<<<<<<< * - * if not hasfields: + * if not PyDataType_HASFIELDS(descr): */ - /*else*/ { - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = ((PyObject *)__pyx_v_self); - } - __pyx_L14:; + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":255 - * info.obj = self + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 + * info.obj = self * - * if not hasfields: # <<<<<<<<<<<<<< + * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ - __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); + __pyx_t_1 = ((!(PyDataType_HASFIELDS(__pyx_v_descr) != 0)) != 0); if (__pyx_t_1) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":256 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":303 * - * if not hasfields: + * if not PyDataType_HASFIELDS(descr): * t = descr.type_num # <<<<<<<<<<<<<< * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): @@ -2616,8 +2750,8 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_4 = __pyx_v_descr->type_num; __pyx_v_t = __pyx_t_4; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":257 - * if not hasfields: + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + * if not PyDataType_HASFIELDS(descr): * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): @@ -2625,18 +2759,18 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); if (!__pyx_t_2) { - goto __pyx_L20_next_or; + goto __pyx_L15_next_or; } else { } __pyx_t_2 = (__pyx_v_little_endian != 0); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; - goto __pyx_L19_bool_binop_done; + goto __pyx_L14_bool_binop_done; } - __pyx_L20_next_or:; + __pyx_L15_next_or:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":258 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":305 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -2647,36 +2781,36 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; - goto __pyx_L19_bool_binop_done; + goto __pyx_L14_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_1 = __pyx_t_2; - __pyx_L19_bool_binop_done:; + __pyx_L14_bool_binop_done:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":257 - * if not hasfields: + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + * if not PyDataType_HASFIELDS(descr): * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ - if (__pyx_t_1) { + if (unlikely(__pyx_t_1)) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":259 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 259, __pyx_L1_error) + __PYX_ERR(1, 306, __pyx_L1_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":257 - * if not hasfields: + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + * if not PyDataType_HASFIELDS(descr): * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): @@ -2684,7 +2818,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":260 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":307 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< @@ -2695,211 +2829,206 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P case NPY_BYTE: __pyx_v_f = ((char *)"b"); break; + case NPY_UBYTE: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":261 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":308 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" */ - case NPY_UBYTE: __pyx_v_f = ((char *)"B"); break; + case NPY_SHORT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":262 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":309 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" */ - case NPY_SHORT: __pyx_v_f = ((char *)"h"); break; + case NPY_USHORT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":263 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":310 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" */ - case NPY_USHORT: __pyx_v_f = ((char *)"H"); break; + case NPY_INT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":264 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":311 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" */ - case NPY_INT: __pyx_v_f = ((char *)"i"); break; + case NPY_UINT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":265 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":312 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" */ - case NPY_UINT: __pyx_v_f = ((char *)"I"); break; + case NPY_LONG: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":266 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":313 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" */ - case NPY_LONG: __pyx_v_f = ((char *)"l"); break; + case NPY_ULONG: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":267 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":314 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" */ - case NPY_ULONG: __pyx_v_f = ((char *)"L"); break; + case NPY_LONGLONG: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":268 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":315 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" */ - case NPY_LONGLONG: __pyx_v_f = ((char *)"q"); break; + case NPY_ULONGLONG: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":269 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":316 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" */ - case NPY_ULONGLONG: __pyx_v_f = ((char *)"Q"); break; + case NPY_FLOAT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":270 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":317 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" */ - case NPY_FLOAT: __pyx_v_f = ((char *)"f"); break; + case NPY_DOUBLE: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":271 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":318 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" */ - case NPY_DOUBLE: __pyx_v_f = ((char *)"d"); break; + case NPY_LONGDOUBLE: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":272 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":319 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" */ - case NPY_LONGDOUBLE: __pyx_v_f = ((char *)"g"); break; + case NPY_CFLOAT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":273 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":320 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" */ - case NPY_CFLOAT: __pyx_v_f = ((char *)"Zf"); break; + case NPY_CDOUBLE: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":274 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":321 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" */ - case NPY_CDOUBLE: __pyx_v_f = ((char *)"Zd"); break; + case NPY_CLONGDOUBLE: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":275 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":322 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f = "O" * else: */ - case NPY_CLONGDOUBLE: __pyx_v_f = ((char *)"Zg"); break; + case NPY_OBJECT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":276 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":323 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ - case NPY_OBJECT: __pyx_v_f = ((char *)"O"); break; default: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":278 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":325 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * info.format = f * return */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); + __pyx_t_8 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 325, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_Raise(__pyx_t_6, 0, 0, 0); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(1, 278, __pyx_L1_error) + __PYX_ERR(1, 325, __pyx_L1_error) break; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":279 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":326 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< @@ -2908,46 +3037,46 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->format = __pyx_v_f; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":280 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":327 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< * else: - * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format = PyObject_Malloc(_buffer_format_string_len) */ __pyx_r = 0; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":255 - * info.obj = self + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 + * info.obj = self * - * if not hasfields: # <<<<<<<<<<<<<< + * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":282 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":329 * return * else: - * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format = PyObject_Malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 */ /*else*/ { - __pyx_v_info->format = ((char *)malloc(0xFF)); + __pyx_v_info->format = ((char *)PyObject_Malloc(0xFF)); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":283 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":330 * else: - * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format = PyObject_Malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< * offset = 0 * f = _util_dtypestring(descr, info.format + 1, */ (__pyx_v_info->format[0]) = '^'; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":284 - * info.format = stdlib.malloc(_buffer_format_string_len) + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":331 + * info.format = PyObject_Malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< * f = _util_dtypestring(descr, info.format + 1, @@ -2955,17 +3084,17 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_offset = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":285 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":332 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< * info.format + _buffer_format_string_len, * &offset) */ - __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(1, 285, __pyx_L1_error) - __pyx_v_f = __pyx_t_7; + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(1, 332, __pyx_L1_error) + __pyx_v_f = __pyx_t_9; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":288 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":335 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< @@ -2975,12 +3104,12 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_f[0]) = '\x00'; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":197 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fullfill the PEP. + * # requirements, and does not yet fulfill the PEP. */ /* function exit code */ @@ -2988,18 +3117,18 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; - if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + if (__pyx_v_info->obj != NULL) { __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; } goto __pyx_L2; __pyx_L0:; - if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { - __Pyx_GOTREF(Py_None); - __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + if (__pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; } __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_descr); @@ -3007,12 +3136,12 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":290 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) + * PyObject_Free(info.format) */ /* Python wrapper */ @@ -3031,75 +3160,75 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":291 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< - * stdlib.free(info.format) + * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":292 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":339 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) # <<<<<<<<<<<<<< + * PyObject_Free(info.format) # <<<<<<<<<<<<<< * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * stdlib.free(info.strides) + * PyObject_Free(info.strides) */ - free(__pyx_v_info->format); + PyObject_Free(__pyx_v_info->format); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":291 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< - * stdlib.free(info.format) + * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":293 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) + * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * stdlib.free(info.strides) + * PyObject_Free(info.strides) * # info.shape was stored after info.strides in the same block */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":294 - * stdlib.free(info.format) + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":341 + * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * stdlib.free(info.strides) # <<<<<<<<<<<<<< + * PyObject_Free(info.strides) # <<<<<<<<<<<<<< * # info.shape was stored after info.strides in the same block * */ - free(__pyx_v_info->strides); + PyObject_Free(__pyx_v_info->strides); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":293 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) + * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * stdlib.free(info.strides) + * PyObject_Free(info.strides) * # info.shape was stored after info.strides in the same block */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":290 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) + * PyObject_Free(info.format) */ /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":770 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -3113,7 +3242,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":771 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< @@ -3121,13 +3250,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ * cdef inline object PyArray_MultiIterNew2(a, b): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 771, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":770 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -3146,7 +3275,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":773 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -3160,7 +3289,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":774 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":825 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< @@ -3168,13 +3297,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 774, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 825, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":773 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -3193,7 +3322,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":776 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -3207,7 +3336,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":777 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< @@ -3215,13 +3344,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":776 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -3240,7 +3369,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":779 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -3254,7 +3383,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":780 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< @@ -3262,13 +3391,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 831, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":779 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -3287,7 +3416,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":782 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -3301,21 +3430,21 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":783 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + * cdef inline tuple PyDataType_SHAPE(dtype d): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 834, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":782 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -3334,9 +3463,83 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":785 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); + + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< + * return d.subarray.shape + * else: + */ + __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); + if (__pyx_t_1) { + + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape # <<<<<<<<<<<<<< + * else: + * return () + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape)); + __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); + goto __pyx_L0; + + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< + * return d.subarray.shape + * else: + */ + } + + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 + * return d.subarray.shape + * else: + * return () # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_empty_tuple); + __pyx_r = __pyx_empty_tuple; + goto __pyx_L0; + } + + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 * return PyArray_MultiIterNew(5, a, b, c, d, e) * + * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 + * return () + * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. @@ -3363,7 +3566,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx char *__pyx_t_9; __Pyx_RefNannySetupContext("_util_dtypestring", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":790 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":847 * * cdef dtype child * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -3372,7 +3575,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_endian_detector = 1; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":791 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":848 * cdef dtype child * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -3381,7 +3584,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":794 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -3390,21 +3593,21 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ if (unlikely(__pyx_v_descr->names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - __PYX_ERR(1, 794, __pyx_L1_error) + __PYX_ERR(1, 851, __pyx_L1_error) } __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 794, __pyx_L1_error) + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 851, __pyx_L1_error) #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 794, __pyx_L1_error) + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 851, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":795 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":852 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< @@ -3413,15 +3616,15 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ if (unlikely(__pyx_v_descr->fields == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(1, 795, __pyx_L1_error) + __PYX_ERR(1, 852, __pyx_L1_error) } - __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 795, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 852, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 795, __pyx_L1_error) + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 852, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":796 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":853 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< @@ -3430,15 +3633,11 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ if (likely(__pyx_v_fields != Py_None)) { PyObject* sequence = __pyx_v_fields; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(1, 796, __pyx_L1_error) + __PYX_ERR(1, 853, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); @@ -3446,51 +3645,51 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else - __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 796, __pyx_L1_error) + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 796, __pyx_L1_error) + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { - __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 796, __pyx_L1_error) + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 853, __pyx_L1_error) } - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 796, __pyx_L1_error) + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 853, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":798 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ - __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 798, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 798, __pyx_L1_error) + __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 798, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 855, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); - if (__pyx_t_6) { + if (unlikely(__pyx_t_6)) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":799 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 856, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 799, __pyx_L1_error) + __PYX_ERR(1, 856, __pyx_L1_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":798 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< @@ -3499,7 +3698,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -3519,7 +3718,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L8_next_or:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":802 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":859 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -3536,29 +3735,29 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ - if (__pyx_t_6) { + if (unlikely(__pyx_t_6)) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":803 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":860 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 803, __pyx_L1_error) + __PYX_ERR(1, 860, __pyx_L1_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -3567,7 +3766,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":813 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":870 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< @@ -3575,15 +3774,15 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * f += 1 */ while (1) { - __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 813, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 870, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 813, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 870, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 813, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 870, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":814 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":871 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< @@ -3592,7 +3791,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ (__pyx_v_f[0]) = 0x78; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":815 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":872 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< @@ -3601,7 +3800,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":816 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":873 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< @@ -3612,7 +3811,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":818 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":875 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< @@ -3622,7 +3821,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":820 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -3632,19 +3831,19 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":821 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":878 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") */ - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 821, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 878, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":822 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -3652,22 +3851,22 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * */ __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); - if (__pyx_t_6) { + if (unlikely(__pyx_t_6)) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":823 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 880, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(1, 823, __pyx_L1_error) + __PYX_ERR(1, 880, __pyx_L1_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":822 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -3676,252 +3875,252 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":826 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":883 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 826, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 826, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 883, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 826, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 883, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 98; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":827 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":884 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 827, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 884, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 827, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 884, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 827, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 884, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 66; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":828 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":885 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 828, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 885, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 828, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 885, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 828, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 885, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x68; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":829 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":886 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 829, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 886, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 829, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 886, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 829, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 886, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 72; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":830 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":887 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 830, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 887, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 830, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 887, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 830, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 887, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x69; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":831 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":888 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 831, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 888, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 831, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 888, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 831, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 888, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 73; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":832 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":889 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 832, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 889, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 832, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 889, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 832, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 889, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x6C; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":833 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":890 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 833, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 890, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 833, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 890, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 833, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 890, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 76; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":834 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":891 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 834, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 834, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 891, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 834, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 891, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x71; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":835 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":892 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 835, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 892, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 835, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 892, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 835, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 892, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 81; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":836 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":893 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 893, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 836, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 893, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 836, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 893, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x66; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":837 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":894 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 837, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 894, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 894, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 837, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 894, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x64; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":838 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":895 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 895, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 838, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 895, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 838, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 895, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x67; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":839 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":896 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 839, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 896, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 839, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 896, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 839, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 896, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; @@ -3930,18 +4129,18 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":840 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":897 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 840, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 840, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 897, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 840, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 897, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; @@ -3950,18 +4149,18 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":841 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":898 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 841, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 841, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 898, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 841, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 898, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; @@ -3970,25 +4169,25 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":842 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":899 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 899, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 842, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 899, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 842, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 899, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { + if (likely(__pyx_t_6)) { (__pyx_v_f[0]) = 79; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":844 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":901 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -3996,23 +4195,18 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * else: */ /*else*/ { - __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 901, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 901, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 844, __pyx_L1_error) + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(1, 901, __pyx_L1_error) } __pyx_L15:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":845 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":902 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< @@ -4021,7 +4215,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":820 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -4031,7 +4225,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L13; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":849 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":906 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< @@ -4039,12 +4233,12 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * */ /*else*/ { - __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) __PYX_ERR(1, 849, __pyx_L1_error) + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(1, 906, __pyx_L1_error) __pyx_v_f = __pyx_t_9; } __pyx_L13:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":794 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -4054,7 +4248,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":850 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":907 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< @@ -4064,8 +4258,8 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_r = __pyx_v_f; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":785 - * return PyArray_MultiIterNew(5, a, b, c, d, e) + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 + * return () * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format @@ -4089,167 +4283,120 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":966 - * +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 + * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * cdef PyObject* baseptr - * if base is None: + * Py_INCREF(base) # important to do this before stealing the reference below! + * PyArray_SetBaseObject(arr, base) */ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { - PyObject *__pyx_v_baseptr; __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; __Pyx_RefNannySetupContext("set_array_base", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":968 - * cdef inline void set_array_base(ndarray arr, object base): - * cdef PyObject* baseptr - * if base is None: # <<<<<<<<<<<<<< - * baseptr = NULL - * else: - */ - __pyx_t_1 = (__pyx_v_base == Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":969 - * cdef PyObject* baseptr - * if base is None: - * baseptr = NULL # <<<<<<<<<<<<<< - * else: - * Py_INCREF(base) # important to do this before decref below! - */ - __pyx_v_baseptr = NULL; - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":968 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1023 + * * cdef inline void set_array_base(ndarray arr, object base): - * cdef PyObject* baseptr - * if base is None: # <<<<<<<<<<<<<< - * baseptr = NULL - * else: - */ - goto __pyx_L3; - } - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":971 - * baseptr = NULL - * else: - * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< - * baseptr = base - * Py_XDECREF(arr.base) - */ - /*else*/ { - Py_INCREF(__pyx_v_base); - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":972 - * else: - * Py_INCREF(base) # important to do this before decref below! - * baseptr = base # <<<<<<<<<<<<<< - * Py_XDECREF(arr.base) - * arr.base = baseptr - */ - __pyx_v_baseptr = ((PyObject *)__pyx_v_base); - } - __pyx_L3:; - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":973 - * Py_INCREF(base) # important to do this before decref below! - * baseptr = base - * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< - * arr.base = baseptr + * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<< + * PyArray_SetBaseObject(arr, base) * */ - Py_XDECREF(__pyx_v_arr->base); + Py_INCREF(__pyx_v_base); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":974 - * baseptr = base - * Py_XDECREF(arr.base) - * arr.base = baseptr # <<<<<<<<<<<<<< + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1024 + * cdef inline void set_array_base(ndarray arr, object base): + * Py_INCREF(base) # important to do this before stealing the reference below! + * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<< * * cdef inline object get_array_base(ndarray arr): */ - __pyx_v_arr->base = __pyx_v_baseptr; + (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base)); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":966 - * + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 + * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * cdef PyObject* baseptr - * if base is None: + * Py_INCREF(base) # important to do this before stealing the reference below! + * PyArray_SetBaseObject(arr, base) */ /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":976 - * arr.base = baseptr +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 + * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * if arr.base is NULL: - * return None + * base = PyArray_BASE(arr) + * if base is NULL: */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_v_base; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":977 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1027 * * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: # <<<<<<<<<<<<<< + * base = PyArray_BASE(arr) # <<<<<<<<<<<<<< + * if base is NULL: * return None - * else: */ - __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); - if (__pyx_t_1) { + __pyx_v_base = PyArray_BASE(__pyx_v_arr); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":978 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: + * base = PyArray_BASE(arr) + * if base is NULL: # <<<<<<<<<<<<<< + * return None + * return base + */ + __pyx_t_1 = ((__pyx_v_base == NULL) != 0); + if (__pyx_t_1) { + + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1029 + * base = PyArray_BASE(arr) + * if base is NULL: * return None # <<<<<<<<<<<<<< - * else: - * return arr.base + * return base + * */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = Py_None; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":977 - * + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: # <<<<<<<<<<<<<< + * base = PyArray_BASE(arr) + * if base is NULL: # <<<<<<<<<<<<<< * return None - * else: + * return base */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":980 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1030 + * if base is NULL: * return None - * else: - * return arr.base # <<<<<<<<<<<<<< - * + * return base # <<<<<<<<<<<<<< * + * # Versions of the import_* functions which are more suitable for */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); - __pyx_r = ((PyObject *)__pyx_v_arr->base); - goto __pyx_L0; - } + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_base)); + __pyx_r = ((PyObject *)__pyx_v_base); + goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":976 - * arr.base = baseptr + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 + * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * if arr.base is NULL: - * return None + * base = PyArray_BASE(arr) + * if base is NULL: */ /* function exit code */ @@ -4259,7 +4406,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":985 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -4280,7 +4427,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_array", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":986 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -4296,16 +4443,16 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":987 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1036 * cdef inline int import_array() except -1: * try: * _import_array() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.multiarray failed to import") */ - __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 987, __pyx_L3_error) + __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1036, __pyx_L3_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":986 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -4318,9 +4465,8 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; - __Pyx_PyThreadState_assign - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":988 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1037 * try: * _import_array() * except Exception: # <<<<<<<<<<<<<< @@ -4330,35 +4476,34 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 988, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1037, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":989 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 * _import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_umath() except -1: */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 989, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1038, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 989, __pyx_L5_except_error) + __PYX_ERR(1, 1038, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":986 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< * _import_array() * except Exception: */ - __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); @@ -4367,7 +4512,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __pyx_L8_try_end:; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":985 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -4390,7 +4535,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":991 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -4411,7 +4556,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_umath", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":992 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -4427,16 +4572,16 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":993 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1042 * cdef inline int import_umath() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.umath failed to import") */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 993, __pyx_L3_error) + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1042, __pyx_L3_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":992 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -4449,9 +4594,8 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; - __Pyx_PyThreadState_assign - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":994 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1043 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -4461,35 +4605,34 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 994, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1043, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":995 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_ufunc() except -1: */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 995, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1044, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 995, __pyx_L5_except_error) + __PYX_ERR(1, 1044, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":992 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< * _import_umath() * except Exception: */ - __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); @@ -4498,7 +4641,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __pyx_L8_try_end:; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":991 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -4521,7 +4664,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":997 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -4542,7 +4685,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_ufunc", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":998 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -4558,16 +4701,16 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":999 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1048 * cdef inline int import_ufunc() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.umath failed to import") */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 999, __pyx_L3_error) + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1048, __pyx_L3_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":998 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -4580,9 +4723,8 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; - __Pyx_PyThreadState_assign - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1000 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1049 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -4591,33 +4733,32 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1000, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1049, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1001 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1050 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1001, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1050, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 1001, __pyx_L5_except_error) + __PYX_ERR(1, 1050, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":998 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< * _import_umath() * except Exception: */ - __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); @@ -4626,7 +4767,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __pyx_L8_try_end:; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":997 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -4654,22 +4795,45 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_cython_bbox(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_cython_bbox}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "cython_bbox", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif +#ifndef CYTHON_SMALL_CODE +#if defined(__clang__) + #define CYTHON_SMALL_CODE +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) + #define CYTHON_SMALL_CODE __attribute__((cold)) +#else + #define CYTHON_SMALL_CODE +#endif +#endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_DTYPE, __pyx_k_DTYPE, sizeof(__pyx_k_DTYPE), 0, 0, 1, 1}, @@ -4693,6 +4857,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, @@ -4710,164 +4875,333 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; -static int __Pyx_InitCachedBuiltins(void) { +static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 51, __pyx_L1_error) - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 218, __pyx_L1_error) - __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 799, __pyx_L1_error) - __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 989, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 272, __pyx_L1_error) + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 856, __pyx_L1_error) + __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 1038, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } -static int __Pyx_InitCachedConstants(void) { +static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":218 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 218, __pyx_L1_error) + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 272, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":222 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 222, __pyx_L1_error) + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 276, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":259 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 259, __pyx_L1_error) + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":799 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 799, __pyx_L1_error) + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 856, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":803 - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * # One could encode it in the format string and have Cython - * # complain instead, BUT: < and > in format strings also imply - */ - __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 803, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__5); - __Pyx_GIVEREF(__pyx_tuple__5); - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":823 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 823, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 880, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":989 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 * _import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_umath() except -1: */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 989, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 1038, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":995 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_ufunc() except -1: */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 995, __pyx_L1_error) + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 1044, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + + /* "utils/cython_bbox.pyx":32 + * + * @cython.boundscheck(False) + * def bbox_overlaps( # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=2] boxes, + * np.ndarray[DTYPE_t, ndim=2] query_boxes): + */ + __pyx_tuple__8 = PyTuple_Pack(11, __pyx_n_s_boxes, __pyx_n_s_query_boxes, __pyx_n_s_N, __pyx_n_s_K, __pyx_n_s_overlaps, __pyx_n_s_iw, __pyx_n_s_ih, __pyx_n_s_box_area, __pyx_n_s_ua, __pyx_n_s_k, __pyx_n_s_n); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); + __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(2, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_utils_cython_bbox_pyx, __pyx_n_s_bbox_overlaps, 32, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 32, __pyx_L1_error) + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + return 0; + __pyx_L1_error:; + return -1; +} + +static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ + +static int __Pyx_modinit_global_init_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); + /*--- Global init code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_variable_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); + /*--- Variable export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1001 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - */ - __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 1001, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__9); - __Pyx_GIVEREF(__pyx_tuple__9); +static int __Pyx_modinit_function_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); + /*--- Function export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} - /* "utils/cython_bbox.pyx":32 - * - * @cython.boundscheck(False) - * def bbox_overlaps( # <<<<<<<<<<<<<< - * np.ndarray[DTYPE_t, ndim=2] boxes, - * np.ndarray[DTYPE_t, ndim=2] query_boxes): - */ - __pyx_tuple__10 = PyTuple_Pack(11, __pyx_n_s_boxes, __pyx_n_s_query_boxes, __pyx_n_s_N, __pyx_n_s_K, __pyx_n_s_overlaps, __pyx_n_s_iw, __pyx_n_s_ih, __pyx_n_s_box_area, __pyx_n_s_ua, __pyx_n_s_k, __pyx_n_s_n); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); - __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(2, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_utils_cython_bbox_pyx, __pyx_n_s_bbox_overlaps, 32, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 32, __pyx_L1_error) +static int __Pyx_modinit_type_init_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); + /*--- Type init code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_type_import_code(void) { + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); + /*--- Type import code ---*/ + __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", + #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 206, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore); + if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(1, 206, __pyx_L1_error) + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(1, 229, __pyx_L1_error) + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(1, 233, __pyx_L1_error) + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore); + if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(1, 242, __pyx_L1_error) + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(1, 918, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } -static int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); +static int __Pyx_modinit_variable_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); + /*--- Variable import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); + /*--- Function import code ---*/ + __Pyx_RefNannyFinishContext(); return 0; - __pyx_L1_error:; - return -1; } + +#if PY_MAJOR_VERSION < 3 +#ifdef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC void +#else +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#endif +#else +#ifdef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC PyObject * +#else +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#endif +#endif + + #if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC initcython_bbox(void); /*proto*/ -PyMODINIT_FUNC initcython_bbox(void) +__Pyx_PyMODINIT_FUNC initcython_bbox(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC initcython_bbox(void) #else -PyMODINIT_FUNC PyInit_cython_bbox(void); /*proto*/ -PyMODINIT_FUNC PyInit_cython_bbox(void) +__Pyx_PyMODINIT_FUNC PyInit_cython_bbox(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC PyInit_cython_bbox(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { + #if PY_VERSION_HEX >= 0x030700A1 + static PY_INT64_T main_interpreter_id = -1; + PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); + if (main_interpreter_id == -1) { + main_interpreter_id = current_id; + return (unlikely(current_id == -1)) ? -1 : 0; + } else if (unlikely(main_interpreter_id != current_id)) + #else + static PyInterpreterState *main_interpreter = NULL; + PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; + if (!main_interpreter) { + main_interpreter = current_interpreter; + } else if (unlikely(main_interpreter != current_interpreter)) + #endif + { + PyErr_SetString( + PyExc_ImportError, + "Interpreter change detected - this module can only be loaded into one interpreter per process."); + return -1; + } + return 0; +} +static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + if (allow_none || value != Py_None) { + result = PyDict_SetItemString(moddict, to_name, value); + } + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__Pyx_check_single_interpreter()) + return NULL; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static CYTHON_SMALL_CODE int __pyx_pymod_exec_cython_bbox(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannyDeclarations - #if CYTHON_REFNANNY - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); - if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m) { + if (__pyx_m == __pyx_pyinit_module) return 0; + PyErr_SetString(PyExc_RuntimeError, "Module 'cython_bbox' has already been imported. Re-initialisation is not supported."); + return -1; } + #elif PY_MAJOR_VERSION >= 3 + if (__pyx_m) return __Pyx_NewRef(__pyx_m); #endif - __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_cython_bbox(void)", 0); + #if CYTHON_REFNANNY +__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); +if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); +} +#endif + __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cython_bbox(void)", 0); if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pxy_PyFrame_Initialize_Offsets + __Pxy_PyFrame_Initialize_Offsets(); + #endif __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -4883,6 +5217,9 @@ PyMODINIT_FUNC PyInit_cython_bbox(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif @@ -4894,12 +5231,17 @@ PyMODINIT_FUNC PyInit_cython_bbox(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("cython_bbox", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -4914,7 +5256,7 @@ PyMODINIT_FUNC PyInit_cython_bbox(void) if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif if (__pyx_module_is_main_utils__cython_bbox) { - if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { @@ -4928,25 +5270,14 @@ PyMODINIT_FUNC PyInit_cython_bbox(void) if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global init code ---*/ - /*--- Variable export code ---*/ - /*--- Function export code ---*/ - /*--- Type init code ---*/ - /*--- Type import code ---*/ - __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", - #if CYTHON_COMPILING_IN_PYPY - sizeof(PyTypeObject), - #else - sizeof(PyHeapTypeObject), - #endif - 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(2, 9, __pyx_L1_error) - __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(1, 155, __pyx_L1_error) - __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(1, 168, __pyx_L1_error) - __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(1, 172, __pyx_L1_error) - __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(1, 181, __pyx_L1_error) - __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(1, 861, __pyx_L1_error) - /*--- Variable import code ---*/ - /*--- Function import code ---*/ + /*--- Global type/function init code ---*/ + (void)__Pyx_modinit_global_init_code(); + (void)__Pyx_modinit_variable_export_code(); + (void)__Pyx_modinit_function_export_code(); + (void)__Pyx_modinit_type_init_code(); + if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error; + (void)__Pyx_modinit_variable_import_code(); + (void)__Pyx_modinit_function_import_code(); /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) @@ -4971,7 +5302,7 @@ PyMODINIT_FUNC PyInit_cython_bbox(void) * ctypedef np.float32_t DTYPE_t * */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); @@ -4996,12 +5327,12 @@ PyMODINIT_FUNC PyInit_cython_bbox(void) * # * # Licensed under the Apache License, Version 2.0 (the "License"); */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":997 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -5017,18 +5348,20 @@ PyMODINIT_FUNC PyInit_cython_bbox(void) __Pyx_XDECREF(__pyx_t_2); if (__pyx_m) { if (__pyx_d) { - __Pyx_AddTraceback("init utils.cython_bbox", 0, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("init utils.cython_bbox", __pyx_clineno, __pyx_lineno, __pyx_filename); } - Py_DECREF(__pyx_m); __pyx_m = 0; + Py_CLEAR(__pyx_m); } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init utils.cython_bbox"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -5038,9 +5371,9 @@ PyMODINIT_FUNC PyInit_cython_bbox(void) static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; - m = PyImport_ImportModule((char *)modname); + m = PyImport_ImportModule(modname); if (!m) goto end; - p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + p = PyObject_GetAttrString(m, "RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: @@ -5050,6 +5383,20 @@ static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { } #endif +/* PyObjectGetAttrStr */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#endif + /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); @@ -5207,29 +5554,23 @@ static int __Pyx_ParseOptionalKeywords( } /* ArgTypeTest */ -static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); -} -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (none_allowed && obj == Py_None) return 1; else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; + if (likely(__Pyx_TypeCheck(obj, type))) return 1; } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; } @@ -5566,7 +5907,7 @@ static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { ctx->is_complex = 0; return 0; } -static CYTHON_INLINE PyObject * +static PyObject * __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) { const char *ts = *tsp; @@ -5704,6 +6045,7 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha __Pyx_BufFmt_RaiseUnexpectedChar('Z'); return NULL; } + CYTHON_FALLTHROUGH; case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': case 'l': case 'L': case 'q': case 'Q': case 'f': case 'd': case 'g': @@ -5716,6 +6058,7 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha ++ts; break; } + CYTHON_FALLTHROUGH; case 's': if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_count = ctx->new_count; @@ -5743,24 +6086,30 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha } } } -static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { + +/* BufferGetAndValidate */ + static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (unlikely(info->buf == NULL)) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); +} +static void __Pyx_ZeroBuffer(Py_buffer* buf) { buf->buf = NULL; buf->obj = NULL; buf->strides = __Pyx_zeros; buf->shape = __Pyx_zeros; buf->suboffsets = __Pyx_minusones; } -static CYTHON_INLINE int __Pyx_GetBufferAndValidate( +static int __Pyx__GetBufferAndValidate( Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack) { - if (obj == Py_None || obj == NULL) { + buf->buf = NULL; + if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) { __Pyx_ZeroBuffer(buf); - return 0; + return -1; } - buf->buf = NULL; - if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; - if (buf->ndim != nd) { + if (unlikely(buf->ndim != nd)) { PyErr_Format(PyExc_ValueError, "Buffer has wrong number of dimensions (expected %d, got %d)", nd, buf->ndim); @@ -5771,7 +6120,7 @@ static CYTHON_INLINE int __Pyx_GetBufferAndValidate( __Pyx_BufFmt_Init(&ctx, stack, dtype); if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; } - if ((unsigned)buf->itemsize != dtype->size) { + if (unlikely((unsigned)buf->itemsize != dtype->size)) { PyErr_Format(PyExc_ValueError, "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", buf->itemsize, (buf->itemsize > 1) ? "s" : "", @@ -5781,35 +6130,47 @@ static CYTHON_INLINE int __Pyx_GetBufferAndValidate( if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; return 0; fail:; - __Pyx_ZeroBuffer(buf); + __Pyx_SafeReleaseBuffer(buf); return -1; } -static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { - if (info->buf == NULL) return; - if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; - __Pyx_ReleaseBuffer(info); -} /* GetModuleGlobalName */ - static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + #if CYTHON_USE_DICT_VERSIONS +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) +#else +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) +#endif +{ PyObject *result; #if !CYTHON_AVOID_BORROWED_REFS +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 + result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } else if (unlikely(PyErr_Occurred())) { + return NULL; + } +#else result = PyDict_GetItem(__pyx_d, name); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { - Py_INCREF(result); - } else { + return __Pyx_NewRef(result); + } +#endif #else result = PyObject_GetItem(__pyx_d, name); - if (!result) { - PyErr_Clear(); -#endif - result = __Pyx_GetBuiltinName(name); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); } - return result; + PyErr_Clear(); +#endif + return __Pyx_GetBuiltinName(name); } /* PyObjectCall */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; @@ -5829,12 +6190,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg #endif /* ExtTypeTest */ - static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (likely(PyObject_TypeCheck(obj, type))) + if (likely(__Pyx_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); @@ -5842,7 +6203,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg } /* PyErrFetchRestore */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; @@ -5866,7 +6227,7 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject #endif /* RaiseException */ - #if PY_MAJOR_VERSION < 3 + #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { __Pyx_PyThreadState_declare @@ -5981,89 +6342,343 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } -#if PY_VERSION_HEX >= 0x03030000 - if (cause) { -#else - if (cause && cause != Py_None) { + if (cause) { + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +/* PyCFunctionFastCall */ + #if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + int flags = PyCFunction_GET_FLAGS(func); + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { + return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); + } else { + return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); + } +} +#endif + +/* PyFunctionFastCall */ + #if CYTHON_FAST_PYCALL +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = __Pyx_PyFrame_GetLocalsplus(f); + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif +#endif + +/* PyObjectCallMethO */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallOneArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } +#endif + if (likely(PyCFunction_Check(func))) { + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); #endif - PyObject *fixed_cause; - if (cause == Py_None) { - fixed_cause = NULL; - } else if (PyExceptionClass_Check(cause)) { - fixed_cause = PyObject_CallObject(cause, NULL); - if (fixed_cause == NULL) - goto bad; - } else if (PyExceptionInstance_Check(cause)) { - fixed_cause = cause; - Py_INCREF(fixed_cause); - } else { - PyErr_SetString(PyExc_TypeError, - "exception causes must derive from " - "BaseException"); - goto bad; } - PyException_SetCause(value, fixed_cause); } - PyErr_SetObject(type, value); - if (tb) { -#if CYTHON_COMPILING_IN_PYPY - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); - Py_INCREF(tb); - PyErr_Restore(tmp_type, tmp_value, tb); - Py_XDECREF(tmp_tb); + return __Pyx__PyObject_CallOneArg(func, arg); +} #else - PyThreadState *tstate = PyThreadState_GET(); - PyObject* tmp_tb = tstate->curexc_traceback; - if (tb != tmp_tb) { - Py_INCREF(tb); - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_tb); - } +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} #endif + +/* DictGetItem */ + #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + if (unlikely(PyTuple_Check(key))) { + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) { + PyErr_SetObject(PyExc_KeyError, args); + Py_DECREF(args); + } + } else { + PyErr_SetObject(PyExc_KeyError, key); + } + } + return NULL; } -bad: - Py_XDECREF(owned_instance); - return; + Py_INCREF(value); + return value; } #endif /* RaiseTooManyValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* RaiseNoneIterError */ - static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } +/* GetTopmostException */ + #if CYTHON_USE_EXC_INFO_STACK +static _PyErr_StackItem * +__Pyx_PyErr_GetTopmostException(PyThreadState *tstate) +{ + _PyErr_StackItem *exc_info = tstate->exc_info; + while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && + exc_info->previous_item != NULL) + { + exc_info = exc_info->previous_item; + } + return exc_info; +} +#endif + /* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); + *type = exc_info->exc_type; + *value = exc_info->exc_value; + *tb = exc_info->exc_traceback; + #else *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; + #endif Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); } static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = type; + exc_info->exc_value = value; + exc_info->exc_traceback = tb; + #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; + #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); @@ -6071,21 +6686,37 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject #endif /* PyErrExceptionMatches */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE +static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; icurexc_type; if (exc_type == err) return 1; if (unlikely(!exc_type)) return 0; - return PyErr_GivenExceptionMatches(exc_type, err); + if (unlikely(PyTuple_Check(err))) + return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); + return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); } #endif /* GetException */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + #if CYTHON_FAST_THREAD_STATE +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) #else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) #endif +{ PyObject *local_type, *local_value, *local_tb; #if CYTHON_FAST_THREAD_STATE PyObject *tmp_type, *tmp_value, *tmp_tb; @@ -6118,12 +6749,24 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) *value = local_value; *tb = local_tb; #if CYTHON_FAST_THREAD_STATE + #if CYTHON_USE_EXC_INFO_STACK + { + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = local_type; + exc_info->exc_value = local_value; + exc_info->exc_traceback = local_tb; + } + #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; + #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); @@ -6141,14 +6784,75 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) return -1; } +/* TypeImport */ + #ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name, + size_t size, enum __Pyx_ImportType_CheckSize check_size) +{ + PyObject *result = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + result = PyObject_GetAttrString(module, class_name); + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if ((size_t)basicsize < size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + goto bad; + } + if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + goto bad; + } + else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(result); + return NULL; +} +#endif + /* Import */ - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; - #if PY_VERSION_HEX < 0x03030000 + #if PY_MAJOR_VERSION < 3 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) @@ -6172,17 +6876,8 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_level = PyInt_FromLong(1); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); - #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; @@ -6193,12 +6888,12 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) } #endif if (!module) { - #if PY_VERSION_HEX < 0x03030000 + #if PY_MAJOR_VERSION < 3 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); + name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( @@ -6207,7 +6902,7 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) } } bad: - #if PY_VERSION_HEX < 0x03030000 + #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); @@ -6216,43 +6911,49 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) } /* CLineInTraceback */ - static int __Pyx_CLineForTraceback(int c_line) { -#ifdef CYTHON_CLINE_IN_TRACEBACK - return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; -#else + #ifndef CYTHON_CLINE_IN_TRACEBACK +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { PyObject *use_cline; + PyObject *ptype, *pvalue, *ptraceback; #if CYTHON_COMPILING_IN_CPYTHON - PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + PyObject **cython_runtime_dict; +#endif + if (unlikely(!__pyx_cython_runtime)) { + return c_line; + } + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); +#if CYTHON_COMPILING_IN_CPYTHON + cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); if (likely(cython_runtime_dict)) { - use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + __PYX_PY_DICT_LOOKUP_IF_MODIFIED( + use_cline, *cython_runtime_dict, + __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) } else #endif { - PyObject *ptype, *pvalue, *ptraceback; - PyObject *use_cline_obj; - PyErr_Fetch(&ptype, &pvalue, &ptraceback); - use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); + PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); if (use_cline_obj) { use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; Py_DECREF(use_cline_obj); } else { + PyErr_Clear(); use_cline = NULL; } - PyErr_Restore(ptype, pvalue, ptraceback); } if (!use_cline) { c_line = 0; PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); } - else if (PyObject_Not(use_cline) != 0) { + else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; -#endif } +#endif /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; @@ -6332,7 +7033,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" + #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -6391,8 +7092,9 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; + PyThreadState *tstate = __Pyx_PyThreadState_Current; if (c_line) { - c_line = __Pyx_CLineForTraceback(c_line); + c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { @@ -6402,10 +7104,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( - PyThreadState_GET(), /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __pyx_d, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ + tstate, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -6418,7 +7120,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, #if PY_MAJOR_VERSION < 3 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); - if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); + if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); return -1; } @@ -6430,16 +7132,16 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { return; } if ((0)) {} - else if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); + else if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); view->obj = NULL; Py_DECREF(obj); } #endif - /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) { - const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; + /* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) { + const unsigned int neg_one = (unsigned int) ((unsigned int) 0 - (unsigned int) 1), const_zero = (unsigned int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(unsigned int) < sizeof(long)) { @@ -6469,7 +7171,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) @@ -6491,7 +7193,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* Declarations */ - #if CYTHON_CCOMPLEX + #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return ::std::complex< float >(x, y); @@ -6511,7 +7213,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #endif /* Arithmetic */ - #if CYTHON_CCOMPLEX + #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { return (a.real == b.real) && (a.imag == b.imag); @@ -6646,7 +7348,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #endif /* Declarations */ - #if CYTHON_CCOMPLEX + #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return ::std::complex< double >(x, y); @@ -6666,7 +7368,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #endif /* Arithmetic */ - #if CYTHON_CCOMPLEX + #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { return (a.real == b.real) && (a.imag == b.imag); @@ -6801,8 +7503,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #endif /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { - const int neg_one = (int) -1, const_zero = (int) 0; + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { @@ -6832,8 +7534,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { - const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { + const enum NPY_TYPES neg_one = (enum NPY_TYPES) ((enum NPY_TYPES) 0 - (enum NPY_TYPES) 1), const_zero = (enum NPY_TYPES) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(enum NPY_TYPES) < sizeof(long)) { @@ -6863,8 +7565,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* CIntFromPy */ - static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { - const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; + static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { + const unsigned int neg_one = (unsigned int) ((unsigned int) 0 - (unsigned int) 1), const_zero = (unsigned int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { @@ -7052,8 +7754,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { - const int neg_one = (int) -1, const_zero = (int) 0; + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { @@ -7241,8 +7943,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { - const long neg_one = (long) -1, const_zero = (long) 0; + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { @@ -7272,8 +7974,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { - const long neg_one = (long) -1, const_zero = (long) 0; + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { @@ -7460,8 +8162,108 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { return (long) -1; } +/* FastTypeChecks */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + assert(PyExceptionClass_Check(exc_type)); + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; itp_basicsize; -#else - py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); - if (!py_basicsize) - goto bad; - basicsize = PyLong_AsSsize_t(py_basicsize); - Py_DECREF(py_basicsize); - py_basicsize = 0; - if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) - goto bad; -#endif - if (!strict && (size_t)basicsize > size) { - PyOS_snprintf(warning, sizeof(warning), - "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd", - module_name, class_name, basicsize, size); - if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; - } - else if ((size_t)basicsize != size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd", - module_name, class_name, basicsize, size); - goto bad; - } - return (PyTypeObject *)result; -bad: - Py_XDECREF(py_module); - Py_XDECREF(result); - return NULL; -} -#endif - /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -7586,7 +8305,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class if (!*t->p) return -1; if (PyObject_Hash(*t->p) == -1) - PyErr_Clear(); + return -1; ++t; } return 0; @@ -7599,46 +8318,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} #endif #endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -7662,6 +8388,33 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { + int retval; + if (unlikely(!x)) return -1; + retval = __Pyx_PyObject_IsTrue(x); + Py_DECREF(x); + return retval; +} +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -7669,9 +8422,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -7679,32 +8432,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { @@ -7721,7 +8472,7 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else - return PyInt_AsSsize_t(x); + return PyInt_AsSsize_t(b); } #endif if (likely(PyLong_CheckExact(b))) { @@ -7775,6 +8526,9 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_DECREF(x); return ival; } +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { + return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); +} static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } diff --git a/lib/utils/cython_nms.c b/lib/utils/cython_nms.c index 2cc8c26d..1f53fc06 100644 --- a/lib/utils/cython_nms.c +++ b/lib/utils/cython_nms.c @@ -1,13 +1,37 @@ -/* Generated by Cython 0.26.1 */ +/* Generated by Cython 0.29.2 */ + +/* BEGIN: Cython Metadata +{ + "distutils": { + "depends": [ + "/home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h", + "/home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/ufuncobject.h" + ], + "extra_compile_args": [ + "-Wno-cpp" + ], + "include_dirs": [ + "/home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/numpy/core/include" + ], + "name": "utils.cython_nms", + "sources": [ + "utils/cython_nms.pyx" + ] + }, + "module_name": "utils.cython_nms" +} +END: Cython Metadata */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26_1" +#define CYTHON_ABI "0_29_2" +#define CYTHON_HEX_VERSION 0x001D02F0 +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +55,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -49,8 +73,12 @@ #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -69,6 +97,14 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -102,6 +138,14 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -154,6 +198,18 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif + #ifndef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) + #endif + #ifndef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -163,7 +219,107 @@ #undef SHIFT #undef BASE #undef MASK + #ifdef SIZEOF_VOID_P + enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; + #endif +#endif +#ifndef __has_attribute + #define __has_attribute(x) 0 +#endif +#ifndef __has_cpp_attribute + #define __has_cpp_attribute(x) 0 +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) +#ifdef _MSC_VER + #ifndef _MSC_STDINT_H_ + #if _MSC_VER < 1300 + typedef unsigned char uint8_t; + typedef unsigned int uint32_t; + #else + typedef unsigned __int8 uint8_t; + typedef unsigned __int32 uint32_t; + #endif + #endif +#else + #include +#endif +#ifndef CYTHON_FALLTHROUGH + #if defined(__cplusplus) && __cplusplus >= 201103L + #if __has_cpp_attribute(fallthrough) + #define CYTHON_FALLTHROUGH [[fallthrough]] + #elif __has_cpp_attribute(clang::fallthrough) + #define CYTHON_FALLTHROUGH [[clang::fallthrough]] + #elif __has_cpp_attribute(gnu::fallthrough) + #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] + #endif + #endif + #ifndef CYTHON_FALLTHROUGH + #if __has_attribute(fallthrough) + #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) + #else + #define CYTHON_FALLTHROUGH + #endif + #endif + #if defined(__clang__ ) && defined(__apple_build_version__) + #if __apple_build_version__ < 7000000 + #undef CYTHON_FALLTHROUGH + #define CYTHON_FALLTHROUGH + #endif + #endif +#endif + +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #elif defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif @@ -192,12 +348,15 @@ #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif -#if PY_VERSION_HEX < 0x030700A0 || !defined(METH_FASTCALL) +#ifndef METH_STACKLESS + #define METH_STACKLESS 0 +#endif +#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs); - typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **args, + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); + typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else #define __Pyx_PyCFunctionFast _PyCFunctionFast @@ -205,10 +364,103 @@ #endif #if CYTHON_FAST_PYCCALL #define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))))) + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if CYTHON_USE_DICT_VERSIONS +#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ + (version_var) = __PYX_GET_DICT_VERSION(dict);\ + (cache_var) = (value); +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ + static PY_UINT64_T __pyx_dict_version = 0;\ + static PyObject *__pyx_dict_cached_value = NULL;\ + if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ + (VAR) = __pyx_dict_cached_value;\ + } else {\ + (VAR) = __pyx_dict_cached_value = (LOOKUP);\ + __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ + }\ + } +#else +#define __PYX_GET_DICT_VERSION(dict) (0) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 + #define PyMem_RawMalloc(n) PyMem_Malloc(n) + #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) + #define PyMem_RawFree(p) PyMem_Free(p) +#endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) +#include "pythread.h" +#define Py_tss_NEEDS_INIT 0 +typedef int Py_tss_t; +static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { + *key = PyThread_create_key(); + return 0; // PyThread_create_key reports success always +} +static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { + Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); + *key = Py_tss_NEEDS_INIT; + return key; +} +static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { + PyObject_Free(key); +} +static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { + return *key != Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { + PyThread_delete_key(*key); + *key = Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { + return PyThread_set_key_value(*key, value); +} +static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { + return PyThread_get_key_value(*key); +} +#endif // TSS (Thread Specific Storage) API +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS +#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) +#else +#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -253,20 +505,8 @@ #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) - #define PyObject_Malloc(s) PyMem_Malloc(s) - #define PyObject_Free(p) PyMem_Free(p) - #define PyObject_Realloc(p) PyMem_Realloc(p) -#endif -#if CYTHON_COMPILING_IN_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) -#else - #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) -#endif -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else @@ -281,6 +521,7 @@ #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact + #define PyObject_Unicode PyObject_Str #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) @@ -292,8 +533,11 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) +#if CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) +#else + #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) +#endif #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type @@ -328,112 +572,26 @@ #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif -#ifndef __has_cpp_attribute - #define __has_cpp_attribute(x) 0 -#endif #if CYTHON_USE_ASYNC_SLOTS #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #endif #else #define __Pyx_PyType_AsAsync(obj) NULL #endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict - #else - #define CYTHON_RESTRICT - #endif -#endif -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -#ifndef CYTHON_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) -#ifdef _MSC_VER - #ifndef _MSC_STDINT_H_ - #if _MSC_VER < 1300 - typedef unsigned char uint8_t; - typedef unsigned int uint32_t; - #else - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - #endif - #endif -#else - #include -#endif -#ifndef CYTHON_FALLTHROUGH - #ifdef __cplusplus - #if __has_cpp_attribute(fallthrough) - #define CYTHON_FALLTHROUGH [[fallthrough]] - #elif __has_cpp_attribute(clang::fallthrough) - #define CYTHON_FALLTHROUGH [[clang::fallthrough]] - #endif - #endif - #ifndef CYTHON_FALLTHROUGH - #if __has_attribute(fallthrough) || (defined(__GNUC__) && defined(__attribute__)) - #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) - #else - #define CYTHON_FALLTHROUGH - #endif - #endif -#endif - -#ifndef CYTHON_INLINE - #if defined(__clang__) - #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) - #elif defined(__GNUC__) - #define CYTHON_INLINE __inline__ - #elif defined(_MSC_VER) - #define CYTHON_INLINE __inline - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_INLINE inline - #else - #define CYTHON_INLINE - #endif +#ifndef __Pyx_PyAsyncMethodsStruct + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; #endif #if defined(WIN32) || defined(MS_WINDOWS) @@ -461,14 +619,6 @@ static CYTHON_INLINE float __PYX_NAN() { __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ } -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -479,16 +629,16 @@ static CYTHON_INLINE float __PYX_NAN() { #define __PYX_HAVE__utils__cython_nms #define __PYX_HAVE_API__utils__cython_nms +/* Early includes */ #include #include -#include #include "numpy/arrayobject.h" #include "numpy/ufuncobject.h" #ifdef _OPENMP #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -512,6 +662,9 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) +static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { + return (size_t) i < (size_t) limit; +} #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) @@ -519,8 +672,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) -#elif defined (_MSC_VER) && defined (_M_X64) - #define __Pyx_sst_abs(value) _abs64(value) +#elif defined (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -542,6 +695,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -552,24 +711,22 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -#if PY_MAJOR_VERSION < 3 -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -647,7 +804,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); @@ -670,10 +827,10 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime; +static PyObject *__pyx_cython_runtime = NULL; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static PyObject *__pyx_empty_unicode; @@ -746,8 +903,20 @@ typedef struct { char is_valid_array; } __Pyx_BufFmt_Context; +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":725 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< @@ -756,7 +925,7 @@ typedef struct { */ typedef npy_int8 __pyx_t_5numpy_int8_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":726 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< @@ -765,7 +934,7 @@ typedef npy_int8 __pyx_t_5numpy_int8_t; */ typedef npy_int16 __pyx_t_5numpy_int16_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":727 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< @@ -774,7 +943,7 @@ typedef npy_int16 __pyx_t_5numpy_int16_t; */ typedef npy_int32 __pyx_t_5numpy_int32_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":728 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< @@ -783,7 +952,7 @@ typedef npy_int32 __pyx_t_5numpy_int32_t; */ typedef npy_int64 __pyx_t_5numpy_int64_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":732 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< @@ -792,7 +961,7 @@ typedef npy_int64 __pyx_t_5numpy_int64_t; */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":733 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":784 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< @@ -801,7 +970,7 @@ typedef npy_uint8 __pyx_t_5numpy_uint8_t; */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":734 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< @@ -810,7 +979,7 @@ typedef npy_uint16 __pyx_t_5numpy_uint16_t; */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":735 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":786 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< @@ -819,7 +988,7 @@ typedef npy_uint32 __pyx_t_5numpy_uint32_t; */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":739 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< @@ -828,7 +997,7 @@ typedef npy_uint64 __pyx_t_5numpy_uint64_t; */ typedef npy_float32 __pyx_t_5numpy_float32_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":740 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< @@ -837,7 +1006,7 @@ typedef npy_float32 __pyx_t_5numpy_float32_t; */ typedef npy_float64 __pyx_t_5numpy_float64_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":749 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":800 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< @@ -846,7 +1015,7 @@ typedef npy_float64 __pyx_t_5numpy_float64_t; */ typedef npy_long __pyx_t_5numpy_int_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":750 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< @@ -855,7 +1024,7 @@ typedef npy_long __pyx_t_5numpy_int_t; */ typedef npy_longlong __pyx_t_5numpy_long_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":751 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< @@ -864,7 +1033,7 @@ typedef npy_longlong __pyx_t_5numpy_long_t; */ typedef npy_longlong __pyx_t_5numpy_longlong_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":753 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":804 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< @@ -873,7 +1042,7 @@ typedef npy_longlong __pyx_t_5numpy_longlong_t; */ typedef npy_ulong __pyx_t_5numpy_uint_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":754 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":805 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< @@ -882,7 +1051,7 @@ typedef npy_ulong __pyx_t_5numpy_uint_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":755 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":806 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< @@ -891,7 +1060,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":757 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":808 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< @@ -900,7 +1069,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; */ typedef npy_intp __pyx_t_5numpy_intp_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":758 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":809 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< @@ -909,7 +1078,7 @@ typedef npy_intp __pyx_t_5numpy_intp_t; */ typedef npy_uintp __pyx_t_5numpy_uintp_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":760 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":811 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< @@ -918,7 +1087,7 @@ typedef npy_uintp __pyx_t_5numpy_uintp_t; */ typedef npy_double __pyx_t_5numpy_float_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":761 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":812 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< @@ -927,7 +1096,7 @@ typedef npy_double __pyx_t_5numpy_float_t; */ typedef npy_double __pyx_t_5numpy_double_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":762 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< @@ -962,7 +1131,7 @@ static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(do /*--- Type declarations ---*/ -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":764 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< @@ -971,7 +1140,7 @@ static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(do */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":765 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< @@ -980,7 +1149,7 @@ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":766 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":817 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< @@ -989,7 +1158,7 @@ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":768 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":819 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< @@ -1064,16 +1233,7 @@ typedef npy_cdouble __pyx_t_5numpy_complex_t; /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro)) - return tp->tp_getattro(obj, attr_name); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif @@ -1094,21 +1254,61 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ const char* function_name); /* ArgTypeTest.proto */ -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* IsLittleEndian.proto */ static CYTHON_INLINE int __Pyx_Is_Little_Endian(void); /* BufferFormatCheck.proto */ -static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, - __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); -static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts); static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, __Pyx_BufFmt_StackElem* stack, __Pyx_TypeInfo* type); +/* BufferGetAndValidate.proto */ +#define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\ + ((obj == Py_None || obj == NULL) ?\ + (__Pyx_ZeroBuffer(buf), 0) :\ + __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)) +static int __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj, + __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +static void __Pyx_ZeroBuffer(Py_buffer* buf); +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); +static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; +static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +/* GetItemInt.proto */ +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +/* ObjectGetItem.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key); +#else +#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) +#endif + /* ExtTypeTest.proto */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); @@ -1120,13 +1320,6 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) #endif -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - /* PyFunctionFastCall.proto */ #if CYTHON_FAST_PYCALL #define __Pyx_PyFunction_FastCall(func, args, nargs)\ @@ -1136,6 +1329,18 @@ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, #else #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) #endif +#define __Pyx_BUILD_ASSERT_EXPR(cond)\ + (sizeof(char [1 - 2*!(cond)]) - 1) +#ifndef Py_MEMBER_SIZE +#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) +#endif + static size_t __pyx_pyframe_localsplus_offset = 0; + #include "frameobject.h" + #define __Pxy_PyFrame_Initialize_Offsets()\ + ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ + (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) + #define __Pyx_PyFrame_GetLocalsplus(frame)\ + (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) #endif /* PyObjectCall.proto */ @@ -1150,9 +1355,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - /* PyObjectCallNoArg.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); @@ -1160,59 +1362,73 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) #endif -/* GetModuleGlobalName.proto */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif -/* NoFastGil.proto */ -#define __Pyx_PyGILState_Ensure PyGILState_Ensure -#define __Pyx_PyGILState_Release PyGILState_Release -#define __Pyx_FastGIL_Remember() -#define __Pyx_FastGIL_Forget() -#define __Pyx_FastGilFuncInit() +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +/* GetModuleGlobalName.proto */ +#if CYTHON_USE_DICT_VERSIONS +#define __Pyx_GetModuleGlobalName(var, name) {\ + static PY_UINT64_T __pyx_dict_version = 0;\ + static PyObject *__pyx_dict_cached_value = NULL;\ + (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ + (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ + __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ +} +#define __Pyx_GetModuleGlobalNameUncached(var, name) {\ + PY_UINT64_T __pyx_dict_version;\ + PyObject *__pyx_dict_cached_value;\ + (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ +} +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); +#else +#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) +#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); +#endif #define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ - __Pyx_GetItemInt_Generic(o, to_py_func(i)))) -#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, - int is_list, int wraparound, int boundscheck); +/* PyObjectCall2Args.proto */ +static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif @@ -1223,7 +1439,7 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\ __Pyx_SetItemInt_Generic(o, to_py_func(i), v))) -static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); +static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, int wraparound, int boundscheck); @@ -1238,23 +1454,13 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY -static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { - PyObject *value; - value = PyDict_GetItemWithError(d, key); - if (unlikely(!value)) { - if (!PyErr_Occurred()) { - PyObject* args = PyTuple_Pack(1, key); - if (likely(args)) - PyErr_SetObject(PyExc_KeyError, args); - Py_XDECREF(args); - } - return NULL; - } - Py_INCREF(value); - return value; -} +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); +#define __Pyx_PyObject_Dict_GetItem(obj, name)\ + (likely(PyDict_CheckExact(obj)) ?\ + __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) #else - #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) #endif /* RaiseTooManyValuesToUnpack.proto */ @@ -1266,6 +1472,11 @@ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); /* RaiseNoneIterError.proto */ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); +/* GetTopmostException.proto */ +#if CYTHON_USE_EXC_INFO_STACK +static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); +#endif + /* SaveResetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) @@ -1293,11 +1504,26 @@ static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); #endif +/* TypeImport.proto */ +#ifndef __PYX_HAVE_RT_ImportType_proto +#define __PYX_HAVE_RT_ImportType_proto +enum __Pyx_ImportType_CheckSize { + __Pyx_ImportType_CheckSize_Error = 0, + __Pyx_ImportType_CheckSize_Warn = 1, + __Pyx_ImportType_CheckSize_Ignore = 2 +}; +static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size); +#endif + /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /* CLineInTraceback.proto */ -static int __Pyx_CLineForTraceback(int c_line); +#ifdef CYTHON_CLINE_IN_TRACEBACK +#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) +#else +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); +#endif /* CodeObjectCache.proto */ typedef struct { @@ -1341,18 +1567,9 @@ typedef struct { #endif -/* None.proto */ -static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; -static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; - /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif - /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); @@ -1469,23 +1686,21 @@ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* PyIdentifierFromString.proto */ -#if !defined(__Pyx_PyIdentifier_FromString) -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else - #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) -#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) #endif +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) -/* ModuleImport.proto */ -static PyObject *__Pyx_ImportModule(const char *name); - -/* TypeImport.proto */ -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); +/* CheckBinaryVersion.proto */ +static int __Pyx_check_binary_version(void); /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); @@ -1510,7 +1725,7 @@ static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; /* Module declarations from 'cpython.ref' */ -/* Module declarations from 'libc.stdlib' */ +/* Module declarations from 'cpython.mem' */ /* Module declarations from 'numpy' */ @@ -1529,6 +1744,7 @@ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t = { "float32_t" static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int_t = { "int_t", NULL, sizeof(__pyx_t_5numpy_int_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_int_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_int_t), 0 }; static __Pyx_TypeInfo __Pyx_TypeInfo_float = { "float", NULL, sizeof(float), { 0 }, 0, 'R', 0, 0 }; #define __Pyx_MODULE_NAME "utils.cython_nms" +extern int __pyx_module_is_main_utils__cython_nms; int __pyx_module_is_main_utils__cython_nms = 0; /* Implementation of 'utils.cython_nms' */ @@ -1578,6 +1794,7 @@ static const char __pyx_k_copy[] = "copy"; static const char __pyx_k_dets[] = "dets"; static const char __pyx_k_inds[] = "inds"; static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_areas[] = "areas"; static const char __pyx_k_boxes[] = "boxes"; @@ -1660,6 +1877,7 @@ static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_maxpos; static PyObject *__pyx_n_s_maxscore; static PyObject *__pyx_n_s_method; +static PyObject *__pyx_n_s_name; static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; static PyObject *__pyx_n_s_ndets; @@ -1715,29 +1933,24 @@ static PyObject *__pyx_int_3; static PyObject *__pyx_int_4; static PyObject *__pyx_int_neg_1; static PyObject *__pyx_slice_; -static PyObject *__pyx_slice__3; -static PyObject *__pyx_slice__5; static PyObject *__pyx_slice__7; -static PyObject *__pyx_slice__9; static PyObject *__pyx_tuple__2; +static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; +static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__8; -static PyObject *__pyx_slice__11; +static PyObject *__pyx_tuple__9; static PyObject *__pyx_tuple__10; +static PyObject *__pyx_tuple__11; static PyObject *__pyx_tuple__12; static PyObject *__pyx_tuple__13; static PyObject *__pyx_tuple__14; static PyObject *__pyx_tuple__15; -static PyObject *__pyx_tuple__16; static PyObject *__pyx_tuple__17; -static PyObject *__pyx_tuple__18; -static PyObject *__pyx_tuple__19; -static PyObject *__pyx_tuple__20; -static PyObject *__pyx_tuple__21; -static PyObject *__pyx_tuple__23; -static PyObject *__pyx_codeobj__22; -static PyObject *__pyx_codeobj__24; +static PyObject *__pyx_codeobj__16; +static PyObject *__pyx_codeobj__18; +/* Late includes */ /* "utils/cython_nms.pyx":28 * cimport numpy as np @@ -1829,7 +2042,7 @@ static CYTHON_INLINE __pyx_t_5numpy_float32_t __pyx_f_5utils_10cython_nms_min(__ /* Python wrapper */ static PyObject *__pyx_pw_5utils_10cython_nms_1nms(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5utils_10cython_nms_1nms = {"nms", (PyCFunction)__pyx_pw_5utils_10cython_nms_1nms, METH_VARARGS|METH_KEYWORDS, 0}; +static PyMethodDef __pyx_mdef_5utils_10cython_nms_1nms = {"nms", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5utils_10cython_nms_1nms, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_5utils_10cython_nms_1nms(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_dets = 0; __pyx_t_5numpy_float32_t __pyx_v_thresh; @@ -1853,11 +2066,11 @@ static PyObject *__pyx_pw_5utils_10cython_nms_1nms(PyObject *__pyx_self, PyObjec kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dets)) != 0)) kw_args--; + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dets)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_thresh)) != 0)) kw_args--; + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_thresh)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("nms", 1, 2, 2, 1); __PYX_ERR(0, 37, __pyx_L3_error) } @@ -1956,24 +2169,26 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ PyArrayObject *__pyx_t_13 = NULL; int __pyx_t_14; int __pyx_t_15; - Py_ssize_t __pyx_t_16; + int __pyx_t_16; Py_ssize_t __pyx_t_17; - int __pyx_t_18; - Py_ssize_t __pyx_t_19; + Py_ssize_t __pyx_t_18; + int __pyx_t_19; Py_ssize_t __pyx_t_20; Py_ssize_t __pyx_t_21; Py_ssize_t __pyx_t_22; Py_ssize_t __pyx_t_23; - int __pyx_t_24; + Py_ssize_t __pyx_t_24; int __pyx_t_25; - Py_ssize_t __pyx_t_26; - Py_ssize_t __pyx_t_27; + int __pyx_t_26; + int __pyx_t_27; Py_ssize_t __pyx_t_28; Py_ssize_t __pyx_t_29; Py_ssize_t __pyx_t_30; Py_ssize_t __pyx_t_31; Py_ssize_t __pyx_t_32; Py_ssize_t __pyx_t_33; + Py_ssize_t __pyx_t_34; + Py_ssize_t __pyx_t_35; __Pyx_RefNannySetupContext("nms", 0); __pyx_pybuffer_x1.pybuffer.buf = NULL; __pyx_pybuffer_x1.refcount = 0; @@ -2024,7 +2239,7 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * cdef np.ndarray[np.float32_t, ndim=1] y1 = dets[:, 1] * cdef np.ndarray[np.float32_t, ndim=1] x2 = dets[:, 2] */ - __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 38, __pyx_L1_error) __pyx_t_2 = ((PyArrayObject *)__pyx_t_1); @@ -2047,7 +2262,7 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * cdef np.ndarray[np.float32_t, ndim=1] x2 = dets[:, 2] * cdef np.ndarray[np.float32_t, ndim=1] y2 = dets[:, 3] */ - __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 39, __pyx_L1_error) __pyx_t_3 = ((PyArrayObject *)__pyx_t_1); @@ -2070,7 +2285,7 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * cdef np.ndarray[np.float32_t, ndim=1] y2 = dets[:, 3] * cdef np.ndarray[np.float32_t, ndim=1] scores = dets[:, 4] */ - __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 40, __pyx_L1_error) __pyx_t_4 = ((PyArrayObject *)__pyx_t_1); @@ -2093,7 +2308,7 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * cdef np.ndarray[np.float32_t, ndim=1] scores = dets[:, 4] * */ - __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 41, __pyx_L1_error) __pyx_t_5 = ((PyArrayObject *)__pyx_t_1); @@ -2116,7 +2331,7 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * * cdef np.ndarray[np.float32_t, ndim=1] areas = (x2 - x1 + 1) * (y2 - y1 + 1) */ - __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 42, __pyx_L1_error) __pyx_t_6 = ((PyArrayObject *)__pyx_t_1); @@ -2186,15 +2401,12 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ __Pyx_DECREF_SET(__pyx_t_8, function); } } - if (__pyx_t_7) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error) - } + __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyObject_GetItem(__pyx_t_1, __pyx_slice__11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 45, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_slice__7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 45, __pyx_L1_error) @@ -2227,7 +2439,7 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * * # nominal indices */ - __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 49, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); @@ -2239,9 +2451,9 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 49, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 49, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_int); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); @@ -2290,8 +2502,9 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * if suppressed[i] == 1: */ __pyx_t_14 = __pyx_v_ndets; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { - __pyx_v__i = __pyx_t_15; + __pyx_t_15 = __pyx_t_14; + for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { + __pyx_v__i = __pyx_t_16; /* "utils/cython_nms.pyx":64 * with nogil: @@ -2300,8 +2513,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * if suppressed[i] == 1: * continue */ - __pyx_t_16 = __pyx_v__i; - __pyx_v_i = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_order.diminfo[0].strides)); + __pyx_t_17 = __pyx_v__i; + __pyx_v_i = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_order.diminfo[0].strides)); /* "utils/cython_nms.pyx":65 * for _i in range(ndets): @@ -2310,9 +2523,9 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * continue * ix1 = x1[i] */ - __pyx_t_17 = __pyx_v_i; - __pyx_t_18 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_suppressed.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_suppressed.diminfo[0].strides)) == 1) != 0); - if (__pyx_t_18) { + __pyx_t_18 = __pyx_v_i; + __pyx_t_19 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_suppressed.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_suppressed.diminfo[0].strides)) == 1) != 0); + if (__pyx_t_19) { /* "utils/cython_nms.pyx":66 * i = order[_i] @@ -2339,8 +2552,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * iy1 = y1[i] * ix2 = x2[i] */ - __pyx_t_19 = __pyx_v_i; - __pyx_v_ix1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_x1.diminfo[0].strides)); + __pyx_t_20 = __pyx_v_i; + __pyx_v_ix1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_x1.diminfo[0].strides)); /* "utils/cython_nms.pyx":68 * continue @@ -2349,8 +2562,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * ix2 = x2[i] * iy2 = y2[i] */ - __pyx_t_20 = __pyx_v_i; - __pyx_v_iy1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_y1.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_y1.diminfo[0].strides)); + __pyx_t_21 = __pyx_v_i; + __pyx_v_iy1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_y1.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_y1.diminfo[0].strides)); /* "utils/cython_nms.pyx":69 * ix1 = x1[i] @@ -2359,8 +2572,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * iy2 = y2[i] * iarea = areas[i] */ - __pyx_t_21 = __pyx_v_i; - __pyx_v_ix2 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_x2.diminfo[0].strides)); + __pyx_t_22 = __pyx_v_i; + __pyx_v_ix2 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_x2.diminfo[0].strides)); /* "utils/cython_nms.pyx":70 * iy1 = y1[i] @@ -2369,8 +2582,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * iarea = areas[i] * for _j in range(_i + 1, ndets): */ - __pyx_t_22 = __pyx_v_i; - __pyx_v_iy2 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_y2.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_y2.diminfo[0].strides)); + __pyx_t_23 = __pyx_v_i; + __pyx_v_iy2 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_y2.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_y2.diminfo[0].strides)); /* "utils/cython_nms.pyx":71 * ix2 = x2[i] @@ -2379,8 +2592,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * for _j in range(_i + 1, ndets): * j = order[_j] */ - __pyx_t_23 = __pyx_v_i; - __pyx_v_iarea = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_areas.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_areas.diminfo[0].strides)); + __pyx_t_24 = __pyx_v_i; + __pyx_v_iarea = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_areas.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_areas.diminfo[0].strides)); /* "utils/cython_nms.pyx":72 * iy2 = y2[i] @@ -2389,9 +2602,10 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * j = order[_j] * if suppressed[j] == 1: */ - __pyx_t_24 = __pyx_v_ndets; - for (__pyx_t_25 = (__pyx_v__i + 1); __pyx_t_25 < __pyx_t_24; __pyx_t_25+=1) { - __pyx_v__j = __pyx_t_25; + __pyx_t_25 = __pyx_v_ndets; + __pyx_t_26 = __pyx_t_25; + for (__pyx_t_27 = (__pyx_v__i + 1); __pyx_t_27 < __pyx_t_26; __pyx_t_27+=1) { + __pyx_v__j = __pyx_t_27; /* "utils/cython_nms.pyx":73 * iarea = areas[i] @@ -2400,8 +2614,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * if suppressed[j] == 1: * continue */ - __pyx_t_26 = __pyx_v__j; - __pyx_v_j = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_order.diminfo[0].strides)); + __pyx_t_28 = __pyx_v__j; + __pyx_v_j = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_order.diminfo[0].strides)); /* "utils/cython_nms.pyx":74 * for _j in range(_i + 1, ndets): @@ -2410,9 +2624,9 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * continue * xx1 = max(ix1, x1[j]) */ - __pyx_t_27 = __pyx_v_j; - __pyx_t_18 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_suppressed.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_suppressed.diminfo[0].strides)) == 1) != 0); - if (__pyx_t_18) { + __pyx_t_29 = __pyx_v_j; + __pyx_t_19 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_suppressed.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_suppressed.diminfo[0].strides)) == 1) != 0); + if (__pyx_t_19) { /* "utils/cython_nms.pyx":75 * j = order[_j] @@ -2439,8 +2653,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * yy1 = max(iy1, y1[j]) * xx2 = min(ix2, x2[j]) */ - __pyx_t_28 = __pyx_v_j; - __pyx_v_xx1 = __pyx_f_5utils_10cython_nms_max(__pyx_v_ix1, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_x1.diminfo[0].strides))); + __pyx_t_30 = __pyx_v_j; + __pyx_v_xx1 = __pyx_f_5utils_10cython_nms_max(__pyx_v_ix1, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_x1.diminfo[0].strides))); /* "utils/cython_nms.pyx":77 * continue @@ -2449,8 +2663,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * xx2 = min(ix2, x2[j]) * yy2 = min(iy2, y2[j]) */ - __pyx_t_29 = __pyx_v_j; - __pyx_v_yy1 = __pyx_f_5utils_10cython_nms_max(__pyx_v_iy1, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_y1.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_y1.diminfo[0].strides))); + __pyx_t_31 = __pyx_v_j; + __pyx_v_yy1 = __pyx_f_5utils_10cython_nms_max(__pyx_v_iy1, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_y1.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_y1.diminfo[0].strides))); /* "utils/cython_nms.pyx":78 * xx1 = max(ix1, x1[j]) @@ -2459,8 +2673,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * yy2 = min(iy2, y2[j]) * w = max(0.0, xx2 - xx1 + 1) */ - __pyx_t_30 = __pyx_v_j; - __pyx_v_xx2 = __pyx_f_5utils_10cython_nms_min(__pyx_v_ix2, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_x2.diminfo[0].strides))); + __pyx_t_32 = __pyx_v_j; + __pyx_v_xx2 = __pyx_f_5utils_10cython_nms_min(__pyx_v_ix2, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_x2.diminfo[0].strides))); /* "utils/cython_nms.pyx":79 * yy1 = max(iy1, y1[j]) @@ -2469,8 +2683,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * w = max(0.0, xx2 - xx1 + 1) * h = max(0.0, yy2 - yy1 + 1) */ - __pyx_t_31 = __pyx_v_j; - __pyx_v_yy2 = __pyx_f_5utils_10cython_nms_min(__pyx_v_iy2, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_y2.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_y2.diminfo[0].strides))); + __pyx_t_33 = __pyx_v_j; + __pyx_v_yy2 = __pyx_f_5utils_10cython_nms_min(__pyx_v_iy2, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_y2.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_y2.diminfo[0].strides))); /* "utils/cython_nms.pyx":80 * xx2 = min(ix2, x2[j]) @@ -2506,8 +2720,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * if ovr >= thresh: * suppressed[j] = 1 */ - __pyx_t_32 = __pyx_v_j; - __pyx_v_ovr = (__pyx_v_inter / ((__pyx_v_iarea + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_areas.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_areas.diminfo[0].strides))) - __pyx_v_inter)); + __pyx_t_34 = __pyx_v_j; + __pyx_v_ovr = (__pyx_v_inter / ((__pyx_v_iarea + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_areas.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_areas.diminfo[0].strides))) - __pyx_v_inter)); /* "utils/cython_nms.pyx":84 * inter = w * h @@ -2516,8 +2730,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * suppressed[j] = 1 * */ - __pyx_t_18 = ((__pyx_v_ovr >= __pyx_v_thresh) != 0); - if (__pyx_t_18) { + __pyx_t_19 = ((__pyx_v_ovr >= __pyx_v_thresh) != 0); + if (__pyx_t_19) { /* "utils/cython_nms.pyx":85 * ovr = inter / (iarea + areas[j] - inter) @@ -2526,8 +2740,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * * return np.where(suppressed == 0)[0] */ - __pyx_t_33 = __pyx_v_j; - *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_suppressed.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_suppressed.diminfo[0].strides) = 1; + __pyx_t_35 = __pyx_v_j; + *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_suppressed.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_suppressed.diminfo[0].strides) = 1; /* "utils/cython_nms.pyx":84 * inter = w * h @@ -2570,7 +2784,7 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ * # ---------------------------------------------------------- */ __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_where); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); @@ -2586,41 +2800,11 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ __Pyx_DECREF_SET(__pyx_t_7, function); } } - if (!__pyx_t_1) { - __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 87, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_12); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_8}; - __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 87, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_8}; - __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 87, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } else - #endif - { - __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 87, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = NULL; - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 87, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } - } + __pyx_t_12 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_1, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_12, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); @@ -2695,7 +2879,7 @@ static PyObject *__pyx_pf_5utils_10cython_nms_nms(CYTHON_UNUSED PyObject *__pyx_ /* Python wrapper */ static PyObject *__pyx_pw_5utils_10cython_nms_3soft_nms(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5utils_10cython_nms_3soft_nms = {"soft_nms", (PyCFunction)__pyx_pw_5utils_10cython_nms_3soft_nms, METH_VARARGS|METH_KEYWORDS, 0}; +static PyMethodDef __pyx_mdef_5utils_10cython_nms_3soft_nms = {"soft_nms", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5utils_10cython_nms_3soft_nms, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_5utils_10cython_nms_3soft_nms(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_boxes_in = 0; float __pyx_v_sigma; @@ -2728,30 +2912,30 @@ static PyObject *__pyx_pw_5utils_10cython_nms_3soft_nms(PyObject *__pyx_self, Py kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_boxes_in)) != 0)) kw_args--; + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_boxes_in)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sigma); + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma); if (value) { values[1] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Nt); + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Nt); if (value) { values[2] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_threshold); + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_threshold); if (value) { values[3] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_method); + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_method); if (value) { values[4] = value; kw_args--; } } } @@ -2849,14 +3033,13 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * PyObject *__pyx_t_3 = NULL; unsigned int __pyx_t_4; PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - Py_ssize_t __pyx_t_7; - PyObject *(*__pyx_t_8)(PyObject *); - float __pyx_t_9; + Py_ssize_t __pyx_t_6; + PyObject *(*__pyx_t_7)(PyObject *); + float __pyx_t_8; + int __pyx_t_9; int __pyx_t_10; - int __pyx_t_11; - PyObject *__pyx_t_12 = NULL; - long __pyx_t_13; + PyObject *__pyx_t_11 = NULL; + long __pyx_t_12; __Pyx_RefNannySetupContext("soft_nms", 0); __pyx_pybuffer_boxes_in.pybuffer.buf = NULL; __pyx_pybuffer_boxes_in.refcount = 0; @@ -2887,12 +3070,9 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * __Pyx_DECREF_SET(__pyx_t_2, function); } } - if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) - } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_boxes = __pyx_t_1; @@ -2948,7 +3128,7 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * * for i in range(N): */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_arange); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); @@ -2965,41 +3145,11 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * __Pyx_DECREF_SET(__pyx_t_3, function); } } - if (!__pyx_t_5) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 113, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } + __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_inds = __pyx_t_2; __pyx_t_2 = 0; @@ -3013,56 +3163,51 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * */ __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_N); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { - __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0; - __pyx_t_8 = NULL; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { + __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0; + __pyx_t_7 = NULL; } else { - __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 115, __pyx_L1_error) + __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 115, __pyx_L1_error) } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { - if (likely(!__pyx_t_8)) { - if (likely(PyList_CheckExact(__pyx_t_3))) { - if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break; + if (likely(!__pyx_t_7)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 115, __pyx_L1_error) + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 115, __pyx_L1_error) #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); #endif } else { - if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 115, __pyx_L1_error) + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 115, __pyx_L1_error) #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); #endif } } else { - __pyx_t_2 = __pyx_t_8(__pyx_t_3); - if (unlikely(!__pyx_t_2)) { + __pyx_t_3 = __pyx_t_7(__pyx_t_2); + if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 115, __pyx_L1_error) } break; } - __Pyx_GOTREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_t_3); } - __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2); - __pyx_t_2 = 0; + __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3); + __pyx_t_3 = 0; /* "utils/cython_nms.pyx":116 * @@ -3071,20 +3216,20 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * maxpos = i * */ - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_4); - __pyx_t_6 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_v_maxscore = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4); + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_maxscore = __pyx_t_8; /* "utils/cython_nms.pyx":117 * for i in range(N): @@ -3093,8 +3238,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * * tx1 = boxes[i,0] */ - __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_i); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 117, __pyx_L1_error) - __pyx_v_maxpos = __pyx_t_10; + __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_i); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_v_maxpos = __pyx_t_9; /* "utils/cython_nms.pyx":119 * maxpos = i @@ -3103,20 +3248,20 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * ty1 = boxes[i,1] * tx2 = boxes[i,2] */ - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 119, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_0); - __pyx_t_2 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 119, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_tx1 = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_tx1 = __pyx_t_8; /* "utils/cython_nms.pyx":120 * @@ -3125,20 +3270,20 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * tx2 = boxes[i,2] * ty2 = boxes[i,3] */ - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 120, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_1); - __pyx_t_6 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 120, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_v_ty1 = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1); + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_ty1 = __pyx_t_8; /* "utils/cython_nms.pyx":121 * tx1 = boxes[i,0] @@ -3147,20 +3292,20 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * ty2 = boxes[i,3] * ts = boxes[i,4] */ - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 121, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_2); - __pyx_t_2 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_tx2 = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_2); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_tx2 = __pyx_t_8; /* "utils/cython_nms.pyx":122 * ty1 = boxes[i,1] @@ -3169,20 +3314,20 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * ts = boxes[i,4] * ti = inds[i] */ - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 122, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_3); - __pyx_t_6 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 122, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 122, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_v_ty2 = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_3); + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 122, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_ty2 = __pyx_t_8; /* "utils/cython_nms.pyx":123 * tx2 = boxes[i,2] @@ -3191,20 +3336,20 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * ti = inds[i] * */ - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 123, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_4); - __pyx_t_2 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 123, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_ts = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_4); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_ts = __pyx_t_8; /* "utils/cython_nms.pyx":124 * ty2 = boxes[i,3] @@ -3213,10 +3358,10 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * * pos = i + 1 */ - __pyx_t_2 = PyObject_GetItem(__pyx_v_inds, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF_SET(__pyx_v_ti, __pyx_t_2); - __pyx_t_2 = 0; + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_inds, __pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_ti, __pyx_t_3); + __pyx_t_3 = 0; /* "utils/cython_nms.pyx":126 * ti = inds[i] @@ -3225,11 +3370,11 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * # get max box * while pos < N: */ - __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_pos = __pyx_t_10; + __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_pos = __pyx_t_9; /* "utils/cython_nms.pyx":128 * pos = i + 1 @@ -3239,8 +3384,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * maxscore = boxes[pos, 4] */ while (1) { - __pyx_t_11 = ((__pyx_v_pos < __pyx_v_N) != 0); - if (!__pyx_t_11) break; + __pyx_t_10 = ((__pyx_v_pos < __pyx_v_N) != 0); + if (!__pyx_t_10) break; /* "utils/cython_nms.pyx":129 * # get max box @@ -3249,27 +3394,27 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * maxscore = boxes[pos, 4] * maxpos = pos */ - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_maxscore); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_maxscore); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_4); - __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 129, __pyx_L1_error) + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_4); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_11) { + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_10) { /* "utils/cython_nms.pyx":130 * while pos < N: @@ -3278,22 +3423,22 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * maxpos = pos * pos = pos + 1 */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 130, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_4); - __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 130, __pyx_L1_error) + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_4); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 130, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_maxscore = __pyx_t_9; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_5); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 130, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_maxscore = __pyx_t_8; /* "utils/cython_nms.pyx":131 * if maxscore < boxes[pos, 4]: @@ -3330,30 +3475,30 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[i,1] = boxes[maxpos,1] * boxes[i,2] = boxes[maxpos,2] */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 135, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_0); - __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 135, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_0); - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 135, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_1, __pyx_t_5) < 0)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "utils/cython_nms.pyx":136 * # add max box as a detection @@ -3362,30 +3507,30 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[i,2] = boxes[maxpos,2] * boxes[i,3] = boxes[maxpos,3] */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1); - __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_1); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1); - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_1); + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_1, __pyx_t_5) < 0)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "utils/cython_nms.pyx":137 * boxes[i,0] = boxes[maxpos,0] @@ -3394,30 +3539,30 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[i,3] = boxes[maxpos,3] * boxes[i,4] = boxes[maxpos,4] */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_2); - __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_2); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_2); - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_2); + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_1, __pyx_t_5) < 0)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "utils/cython_nms.pyx":138 * boxes[i,1] = boxes[maxpos,1] @@ -3426,30 +3571,30 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[i,4] = boxes[maxpos,4] * inds[i] = inds[maxpos] */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 138, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_3); - __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_3); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 138, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_3); - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_3); + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_1, __pyx_t_5) < 0)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "utils/cython_nms.pyx":139 * boxes[i,2] = boxes[maxpos,2] @@ -3458,30 +3603,30 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * inds[i] = inds[maxpos] * */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 139, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 139, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_4); - __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_4); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 139, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 139, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_4); - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 139, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_4); + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_1, __pyx_t_5) < 0)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "utils/cython_nms.pyx":140 * boxes[i,3] = boxes[maxpos,3] @@ -3490,10 +3635,10 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * * # swap ith box with position of max box */ - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_inds, __pyx_v_maxpos, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (unlikely(PyObject_SetItem(__pyx_v_inds, __pyx_v_i, __pyx_t_1) < 0)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_inds, __pyx_v_maxpos, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 140, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(PyObject_SetItem(__pyx_v_inds, __pyx_v_i, __pyx_t_5) < 0)) __PYX_ERR(0, 140, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "utils/cython_nms.pyx":143 * @@ -3502,21 +3647,21 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[maxpos,1] = ty1 * boxes[maxpos,2] = tx2 */ - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_tx1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_tx1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 143, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_0); - __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_2, __pyx_t_1) < 0)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0); + __pyx_t_1 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_3, __pyx_t_5) < 0)) __PYX_ERR(0, 143, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "utils/cython_nms.pyx":144 * # swap ith box with position of max box @@ -3525,21 +3670,21 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[maxpos,2] = tx2 * boxes[maxpos,3] = ty2 */ - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_ty1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_ty1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 144, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 144, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1); - __pyx_t_2 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 144, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_1); + __pyx_t_3 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_1, __pyx_t_5) < 0)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "utils/cython_nms.pyx":145 * boxes[maxpos,0] = tx1 @@ -3548,21 +3693,21 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[maxpos,3] = ty2 * boxes[maxpos,4] = ts */ - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_tx2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_tx2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 145, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 145, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_2); - __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_2, __pyx_t_1) < 0)) __PYX_ERR(0, 145, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_2); + __pyx_t_1 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_3, __pyx_t_5) < 0)) __PYX_ERR(0, 145, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "utils/cython_nms.pyx":146 * boxes[maxpos,1] = ty1 @@ -3571,21 +3716,21 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[maxpos,4] = ts * inds[maxpos] = ti */ - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_ty2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_ty2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_3); - __pyx_t_2 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_3); + __pyx_t_3 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_1, __pyx_t_5) < 0)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "utils/cython_nms.pyx":147 * boxes[maxpos,2] = tx2 @@ -3594,21 +3739,21 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * inds[maxpos] = ti * */ - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_ts); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_ts); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 147, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_4); - __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_2, __pyx_t_1) < 0)) __PYX_ERR(0, 147, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4); + __pyx_t_1 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_3, __pyx_t_5) < 0)) __PYX_ERR(0, 147, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "utils/cython_nms.pyx":148 * boxes[maxpos,3] = ty2 @@ -3626,20 +3771,20 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * ty1 = boxes[i,1] * tx2 = boxes[i,2] */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); - __pyx_t_2 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 150, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_tx1 = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_0); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_tx1 = __pyx_t_8; /* "utils/cython_nms.pyx":151 * @@ -3648,20 +3793,20 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * tx2 = boxes[i,2] * ty2 = boxes[i,3] */ - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_1); - __pyx_t_1 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 151, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_ty1 = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1); + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_5); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_ty1 = __pyx_t_8; /* "utils/cython_nms.pyx":152 * tx1 = boxes[i,0] @@ -3670,20 +3815,20 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * ty2 = boxes[i,3] * ts = boxes[i,4] */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_2); - __pyx_t_2 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_tx2 = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_2); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_tx2 = __pyx_t_8; /* "utils/cython_nms.pyx":153 * ty1 = boxes[i,1] @@ -3692,20 +3837,20 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * ts = boxes[i,4] * */ - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_3); - __pyx_t_1 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_ty2 = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_3); + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_5); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_ty2 = __pyx_t_8; /* "utils/cython_nms.pyx":154 * tx2 = boxes[i,2] @@ -3714,20 +3859,20 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * * pos = i + 1 */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_i); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_4); - __pyx_t_2 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 154, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 154, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_ts = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_4); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_ts = __pyx_t_8; /* "utils/cython_nms.pyx":156 * ts = boxes[i,4] @@ -3736,11 +3881,11 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * # NMS iterations, note that N changes if detection boxes fall below * # threshold */ - __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_pos = __pyx_t_10; + __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 156, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_pos = __pyx_t_9; /* "utils/cython_nms.pyx":159 * # NMS iterations, note that N changes if detection boxes fall below @@ -3750,8 +3895,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * y1 = boxes[pos, 1] */ while (1) { - __pyx_t_11 = ((__pyx_v_pos < __pyx_v_N) != 0); - if (!__pyx_t_11) break; + __pyx_t_10 = ((__pyx_v_pos < __pyx_v_N) != 0); + if (!__pyx_t_10) break; /* "utils/cython_nms.pyx":160 * # threshold @@ -3760,22 +3905,22 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * y1 = boxes[pos, 1] * x2 = boxes[pos, 2] */ - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 160, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); - __pyx_t_2 = 0; - __pyx_t_2 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_x1 = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_0); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 160, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_x1 = __pyx_t_8; /* "utils/cython_nms.pyx":161 * while pos < N: @@ -3784,22 +3929,22 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * x2 = boxes[pos, 2] * y2 = boxes[pos, 3] */ - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_1); - __pyx_t_2 = 0; - __pyx_t_2 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_y1 = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_1); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_y1 = __pyx_t_8; /* "utils/cython_nms.pyx":162 * x1 = boxes[pos, 0] @@ -3808,22 +3953,22 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * y2 = boxes[pos, 3] * s = boxes[pos, 4] */ - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_2); - __pyx_t_2 = 0; - __pyx_t_2 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_x2 = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_2); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_x2 = __pyx_t_8; /* "utils/cython_nms.pyx":163 * y1 = boxes[pos, 1] @@ -3832,22 +3977,22 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * s = boxes[pos, 4] * */ - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 163, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_3); - __pyx_t_2 = 0; - __pyx_t_2 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_y2 = __pyx_t_9; + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_y2 = __pyx_t_8; /* "utils/cython_nms.pyx":164 * x2 = boxes[pos, 2] @@ -3856,21 +4001,21 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * * area = (x2 - x1 + 1) * (y2 - y1 + 1) */ - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 164, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 164, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 164, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 164, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_4); - __pyx_t_2 = 0; - __pyx_t_2 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 164, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_2); - __pyx_t_2 = 0; + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_4); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 164, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_3); + __pyx_t_3 = 0; /* "utils/cython_nms.pyx":166 * s = boxes[pos, 4] @@ -3897,8 +4042,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * ih = (min(ty2, y2) - max(ty1, y1) + 1) * if ih > 0: */ - __pyx_t_11 = ((__pyx_v_iw > 0.0) != 0); - if (__pyx_t_11) { + __pyx_t_10 = ((__pyx_v_iw > 0.0) != 0); + if (__pyx_t_10) { /* "utils/cython_nms.pyx":169 * iw = (min(tx2, x2) - max(tx1, x1) + 1) @@ -3916,8 +4061,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * ua = float((tx2 - tx1 + 1) * (ty2 - ty1 + 1) + area - iw * ih) * ov = iw * ih / ua #iou between max box and detection box */ - __pyx_t_11 = ((__pyx_v_ih > 0.0) != 0); - if (__pyx_t_11) { + __pyx_t_10 = ((__pyx_v_ih > 0.0) != 0); + if (__pyx_t_10) { /* "utils/cython_nms.pyx":171 * ih = (min(ty2, y2) - max(ty1, y1) + 1) @@ -3954,8 +4099,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * weight = 1 - ov * else: */ - __pyx_t_11 = ((__pyx_v_ov > __pyx_v_Nt) != 0); - if (__pyx_t_11) { + __pyx_t_10 = ((__pyx_v_ov > __pyx_v_Nt) != 0); + if (__pyx_t_10) { /* "utils/cython_nms.pyx":176 * if method == 1: # linear @@ -3996,14 +4141,6 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * weight = 1 - ov */ break; - - /* "utils/cython_nms.pyx":179 - * else: - * weight = 1 - * elif method == 2: # gaussian # <<<<<<<<<<<<<< - * weight = np.exp(-(ov * ov)/sigma) - * else: # original NMS - */ case 2: /* "utils/cython_nms.pyx":180 @@ -4013,62 +4150,32 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * else: # original NMS * if ov > Nt: */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_exp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyFloat_FromDouble(((-(__pyx_v_ov * __pyx_v_ov)) / __pyx_v_sigma)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_exp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyFloat_FromDouble(((-(__pyx_v_ov * __pyx_v_ov)) / __pyx_v_sigma)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_11 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); + __Pyx_DECREF_SET(__pyx_t_1, function); } } - if (!__pyx_t_5) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - { - __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - } - } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_weight = __pyx_t_9; + __pyx_t_3 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_11, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_weight = __pyx_t_8; /* "utils/cython_nms.pyx":179 * else: @@ -4087,8 +4194,8 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * weight = 0 * else: */ - __pyx_t_11 = ((__pyx_v_ov > __pyx_v_Nt) != 0); - if (__pyx_t_11) { + __pyx_t_10 = ((__pyx_v_ov > __pyx_v_Nt) != 0); + if (__pyx_t_10) { /* "utils/cython_nms.pyx":183 * else: # original NMS @@ -4130,38 +4237,38 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * * # if box score falls below threshold, discard the box by */ - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_weight); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_weight); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_int_4); - __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_12 = PyNumber_Multiply(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_4); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_4); - __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_2, __pyx_t_12) < 0)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4); + __pyx_t_1 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_3, __pyx_t_5) < 0)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "utils/cython_nms.pyx":191 * # if box score falls below threshold, discard the box by @@ -4170,27 +4277,27 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[pos,0] = boxes[N-1, 0] * boxes[pos,1] = boxes[N-1, 1] */ - __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_12); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12); + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_4); - __pyx_t_12 = 0; - __pyx_t_12 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_threshold); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyObject_RichCompare(__pyx_t_12, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (__pyx_t_11) { + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_threshold); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyObject_RichCompare(__pyx_t_5, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 191, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_10) { /* "utils/cython_nms.pyx":192 * # swapping with last box update N @@ -4199,32 +4306,32 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[pos,1] = boxes[N-1, 1] * boxes[pos,2] = boxes[N-1, 2] */ - __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); + __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_0); - __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 192, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_int_0); - __pyx_t_2 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_12, __pyx_t_6) < 0)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_0); + __pyx_t_3 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_5, __pyx_t_1) < 0)) __PYX_ERR(0, 192, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "utils/cython_nms.pyx":193 * if boxes[pos, 4] < threshold: @@ -4233,32 +4340,32 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[pos,2] = boxes[N-1, 2] * boxes[pos,3] = boxes[N-1, 3] */ - __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); + __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_int_1); - __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_12); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_1); - __pyx_t_12 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_2, __pyx_t_6) < 0)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1); + __pyx_t_5 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_3, __pyx_t_1) < 0)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "utils/cython_nms.pyx":194 * boxes[pos,0] = boxes[N-1, 0] @@ -4267,32 +4374,32 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[pos,3] = boxes[N-1, 3] * boxes[pos,4] = boxes[N-1, 4] */ - __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 194, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); + __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_2); - __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 194, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 194, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_2); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_int_2); - __pyx_t_2 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_12, __pyx_t_6) < 0)) __PYX_ERR(0, 194, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_2); + __pyx_t_3 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_5, __pyx_t_1) < 0)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "utils/cython_nms.pyx":195 * boxes[pos,1] = boxes[N-1, 1] @@ -4301,32 +4408,32 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * boxes[pos,4] = boxes[N-1, 4] * inds[pos] = inds[N-1] */ - __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); + __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 195, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); - PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_int_3); - __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_12); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_3); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 195, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_3); - __pyx_t_12 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_2, __pyx_t_6) < 0)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_3); + __pyx_t_5 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_3, __pyx_t_1) < 0)) __PYX_ERR(0, 195, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "utils/cython_nms.pyx":196 * boxes[pos,2] = boxes[N-1, 2] @@ -4335,32 +4442,32 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * inds[pos] = inds[N-1] * N = N - 1 */ - __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); + __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_4); - __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(__pyx_v_boxes, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 196, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_int_4); - __pyx_t_2 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_12, __pyx_t_6) < 0)) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_4); + __pyx_t_3 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_5, __pyx_t_1) < 0)) __PYX_ERR(0, 196, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "utils/cython_nms.pyx":197 * boxes[pos,3] = boxes[N-1, 3] @@ -4369,11 +4476,11 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * N = N - 1 * pos = pos - 1 */ - __pyx_t_13 = (__pyx_v_N - 1); - __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_inds, __pyx_t_13, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (unlikely(__Pyx_SetItemInt(__pyx_v_inds, __pyx_v_pos, __pyx_t_6, int, 1, __Pyx_PyInt_From_int, 0, 0, 0) < 0)) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_12 = (__pyx_v_N - 1); + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_inds, __pyx_t_12, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (unlikely(__Pyx_SetItemInt(__pyx_v_inds, __pyx_v_pos, __pyx_t_1, int, 1, __Pyx_PyInt_From_int, 0, 0, 0) < 0)) __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "utils/cython_nms.pyx":198 * boxes[pos,4] = boxes[N-1, 4] @@ -4438,7 +4545,7 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * maxpos = i */ } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "utils/cython_nms.pyx":203 * pos = pos + 1 @@ -4446,20 +4553,20 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * * return boxes[:N], inds[:N] # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_boxes, 0, __pyx_v_N, NULL, NULL, NULL, 0, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_v_inds, 0, __pyx_v_N, NULL, NULL, NULL, 0, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 203, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 203, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_6); - __pyx_t_3 = 0; - __pyx_t_6 = 0; - __pyx_r = __pyx_t_12; - __pyx_t_12 = 0; + __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_boxes, 0, __pyx_v_N, NULL, NULL, NULL, 0, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_inds, 0, __pyx_v_N, NULL, NULL, NULL, 0, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 203, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); + __pyx_t_2 = 0; + __pyx_t_1 = 0; + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; goto __pyx_L0; /* "utils/cython_nms.pyx":98 @@ -4476,8 +4583,7 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_11); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign @@ -4500,12 +4606,12 @@ static PyObject *__pyx_pf_5utils_10cython_nms_2soft_nms(CYTHON_UNUSED PyObject * return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":197 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fullfill the PEP. + * # requirements, and does not yet fulfill the PEP. */ /* Python wrapper */ @@ -4522,7 +4628,6 @@ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx } static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_v_copy_shape; int __pyx_v_i; int __pyx_v_ndim; int __pyx_v_endian_detector; @@ -4531,7 +4636,6 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P char *__pyx_v_f; PyArray_Descr *__pyx_v_descr = 0; int __pyx_v_offset; - int __pyx_v_hasfields; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -4539,38 +4643,29 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - char *__pyx_t_7; - __Pyx_RefNannySetupContext("__getbuffer__", 0); - if (__pyx_v_info != NULL) { - __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(__pyx_v_info->obj); - } - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":203 - * # of flags - * - * if info == NULL: return # <<<<<<<<<<<<<< - * - * cdef int copy_shape, i, ndim - */ - __pyx_t_1 = ((__pyx_v_info == NULL) != 0); - if (__pyx_t_1) { - __pyx_r = 0; - goto __pyx_L0; + int __pyx_t_6; + PyArray_Descr *__pyx_t_7; + PyObject *__pyx_t_8 = NULL; + char *__pyx_t_9; + if (__pyx_v_info == NULL) { + PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete"); + return -1; } + __Pyx_RefNannySetupContext("__getbuffer__", 0); + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":206 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 * - * cdef int copy_shape, i, ndim + * cdef int i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((&endian_detector)[0] != 0) * */ __pyx_v_endian_detector = 1; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":207 - * cdef int copy_shape, i, ndim + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 + * cdef int i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * @@ -4578,226 +4673,186 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":209 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 * cdef bint little_endian = ((&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) */ __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":211 - * ndim = PyArray_NDIM(self) - * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * copy_shape = 1 - * else: - */ - __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); - if (__pyx_t_1) { - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":212 - * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * copy_shape = 1 # <<<<<<<<<<<<<< - * else: - * copy_shape = 0 - */ - __pyx_v_copy_shape = 1; - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":211 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * ndim = PyArray_NDIM(self) * - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * copy_shape = 1 - * else: - */ - goto __pyx_L4; - } - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":214 - * copy_shape = 1 - * else: - * copy_shape = 0 # <<<<<<<<<<<<<< - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - */ - /*else*/ { - __pyx_v_copy_shape = 0; - } - __pyx_L4:; - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":216 - * copy_shape = 0 - * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; - goto __pyx_L6_bool_binop_done; + goto __pyx_L4_bool_binop_done; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":217 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not C contiguous") * */ - __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_ARRAY_C_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; - __pyx_L6_bool_binop_done:; + __pyx_L4_bool_binop_done:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":216 - * copy_shape = 0 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * ndim = PyArray_NDIM(self) * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ - if (__pyx_t_1) { + if (unlikely(__pyx_t_1)) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":218 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 218, __pyx_L1_error) + __PYX_ERR(1, 272, __pyx_L1_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":216 - * copy_shape = 0 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * ndim = PyArray_NDIM(self) * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; - goto __pyx_L9_bool_binop_done; + goto __pyx_L7_bool_binop_done; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":221 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not Fortran contiguous") * */ - __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_ARRAY_F_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; - __pyx_L9_bool_binop_done:; + __pyx_L7_bool_binop_done:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ - if (__pyx_t_1) { + if (unlikely(__pyx_t_1)) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":222 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 222, __pyx_L1_error) + __PYX_ERR(1, 276, __pyx_L1_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":224 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< * info.ndim = ndim - * if copy_shape: + * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":225 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< - * if copy_shape: + * if sizeof(npy_intp) != sizeof(Py_ssize_t): * # Allocate new buffer for strides and shape info. */ __pyx_v_info->ndim = __pyx_v_ndim; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":226 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * info.buf = PyArray_DATA(self) * info.ndim = ndim - * if copy_shape: # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ - __pyx_t_1 = (__pyx_v_copy_shape != 0); + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":229 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) # <<<<<<<<<<<<<< * info.shape = info.strides + ndim * for i in range(ndim): */ - __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); + __pyx_v_info->strides = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * 2) * ((size_t)__pyx_v_ndim)))); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":230 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 * # This is allocated as one block, strides first. - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":231 - * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] */ __pyx_t_4 = __pyx_v_ndim; - for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { - __pyx_v_i = __pyx_t_5; + __pyx_t_5 = __pyx_t_4; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":232 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":286 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< @@ -4806,7 +4861,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":233 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":287 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< @@ -4816,17 +4871,17 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":226 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * info.buf = PyArray_DATA(self) * info.ndim = ndim - * if copy_shape: # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ - goto __pyx_L11; + goto __pyx_L9; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":235 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":289 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< @@ -4836,7 +4891,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P /*else*/ { __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":236 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< @@ -4845,9 +4900,9 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); } - __pyx_L11:; + __pyx_L9:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":237 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< @@ -4856,7 +4911,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->suboffsets = NULL; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":238 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< @@ -4865,7 +4920,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":239 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< @@ -4874,115 +4929,63 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":242 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":296 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< - * cdef dtype descr = self.descr + * cdef dtype descr = PyArray_DESCR(self) * cdef int offset */ __pyx_v_f = NULL; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":243 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":297 * cdef int t * cdef char* f = NULL - * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef dtype descr = PyArray_DESCR(self) # <<<<<<<<<<<<<< * cdef int offset * */ - __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); + __pyx_t_7 = PyArray_DESCR(__pyx_v_self); + __pyx_t_3 = ((PyObject *)__pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":246 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":300 * cdef int offset * - * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< + * info.obj = self # <<<<<<<<<<<<<< * - * if not hasfields and not copy_shape: + * if not PyDataType_HASFIELDS(descr): */ - __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":248 - * cdef bint hasfields = PyDataType_HASFIELDS(descr) + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 + * info.obj = self * - * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< - * # do not call releasebuffer - * info.obj = None + * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or */ - __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L15_bool_binop_done; - } - __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L15_bool_binop_done:; + __pyx_t_1 = ((!(PyDataType_HASFIELDS(__pyx_v_descr) != 0)) != 0); if (__pyx_t_1) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":250 - * if not hasfields and not copy_shape: - * # do not call releasebuffer - * info.obj = None # <<<<<<<<<<<<<< - * else: - * # need to call releasebuffer - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = Py_None; - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":248 - * cdef bint hasfields = PyDataType_HASFIELDS(descr) + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":303 * - * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< - * # do not call releasebuffer - * info.obj = None + * if not PyDataType_HASFIELDS(descr): + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): */ - goto __pyx_L14; - } + __pyx_t_4 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_4; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":253 - * else: - * # need to call releasebuffer - * info.obj = self # <<<<<<<<<<<<<< - * - * if not hasfields: - */ - /*else*/ { - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = ((PyObject *)__pyx_v_self); - } - __pyx_L14:; - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":255 - * info.obj = self - * - * if not hasfields: # <<<<<<<<<<<<<< - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or - */ - __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); - if (__pyx_t_1) { - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":256 - * - * if not hasfields: - * t = descr.type_num # <<<<<<<<<<<<<< - * if ((descr.byteorder == c'>' and little_endian) or - * (descr.byteorder == c'<' and not little_endian)): - */ - __pyx_t_4 = __pyx_v_descr->type_num; - __pyx_v_t = __pyx_t_4; - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":257 - * if not hasfields: + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + * if not PyDataType_HASFIELDS(descr): * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): @@ -4990,18 +4993,18 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); if (!__pyx_t_2) { - goto __pyx_L20_next_or; + goto __pyx_L15_next_or; } else { } __pyx_t_2 = (__pyx_v_little_endian != 0); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; - goto __pyx_L19_bool_binop_done; + goto __pyx_L14_bool_binop_done; } - __pyx_L20_next_or:; + __pyx_L15_next_or:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":258 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":305 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -5012,36 +5015,36 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; - goto __pyx_L19_bool_binop_done; + goto __pyx_L14_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_1 = __pyx_t_2; - __pyx_L19_bool_binop_done:; + __pyx_L14_bool_binop_done:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":257 - * if not hasfields: + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + * if not PyDataType_HASFIELDS(descr): * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ - if (__pyx_t_1) { + if (unlikely(__pyx_t_1)) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":259 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 259, __pyx_L1_error) + __PYX_ERR(1, 306, __pyx_L1_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":257 - * if not hasfields: + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + * if not PyDataType_HASFIELDS(descr): * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): @@ -5049,7 +5052,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":260 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":307 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< @@ -5060,211 +5063,206 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P case NPY_BYTE: __pyx_v_f = ((char *)"b"); break; + case NPY_UBYTE: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":261 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":308 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" */ - case NPY_UBYTE: __pyx_v_f = ((char *)"B"); break; + case NPY_SHORT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":262 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":309 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" */ - case NPY_SHORT: __pyx_v_f = ((char *)"h"); break; + case NPY_USHORT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":263 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":310 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" */ - case NPY_USHORT: __pyx_v_f = ((char *)"H"); break; + case NPY_INT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":264 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":311 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" */ - case NPY_INT: __pyx_v_f = ((char *)"i"); break; + case NPY_UINT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":265 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":312 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" */ - case NPY_UINT: __pyx_v_f = ((char *)"I"); break; + case NPY_LONG: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":266 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":313 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" */ - case NPY_LONG: __pyx_v_f = ((char *)"l"); break; + case NPY_ULONG: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":267 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":314 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" */ - case NPY_ULONG: __pyx_v_f = ((char *)"L"); break; + case NPY_LONGLONG: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":268 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":315 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" */ - case NPY_LONGLONG: __pyx_v_f = ((char *)"q"); break; + case NPY_ULONGLONG: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":269 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":316 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" */ - case NPY_ULONGLONG: __pyx_v_f = ((char *)"Q"); break; + case NPY_FLOAT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":270 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":317 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" */ - case NPY_FLOAT: __pyx_v_f = ((char *)"f"); break; + case NPY_DOUBLE: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":271 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":318 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" */ - case NPY_DOUBLE: __pyx_v_f = ((char *)"d"); break; + case NPY_LONGDOUBLE: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":272 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":319 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" */ - case NPY_LONGDOUBLE: __pyx_v_f = ((char *)"g"); break; + case NPY_CFLOAT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":273 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":320 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" */ - case NPY_CFLOAT: __pyx_v_f = ((char *)"Zf"); break; + case NPY_CDOUBLE: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":274 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":321 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" */ - case NPY_CDOUBLE: __pyx_v_f = ((char *)"Zd"); break; + case NPY_CLONGDOUBLE: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":275 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":322 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f = "O" * else: */ - case NPY_CLONGDOUBLE: __pyx_v_f = ((char *)"Zg"); break; + case NPY_OBJECT: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":276 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":323 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ - case NPY_OBJECT: __pyx_v_f = ((char *)"O"); break; default: - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":278 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":325 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * info.format = f * return */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); + __pyx_t_8 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 325, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_Raise(__pyx_t_6, 0, 0, 0); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(1, 278, __pyx_L1_error) + __PYX_ERR(1, 325, __pyx_L1_error) break; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":279 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":326 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< @@ -5273,46 +5271,46 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->format = __pyx_v_f; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":280 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":327 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< * else: - * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format = PyObject_Malloc(_buffer_format_string_len) */ __pyx_r = 0; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":255 - * info.obj = self + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 + * info.obj = self * - * if not hasfields: # <<<<<<<<<<<<<< + * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":282 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":329 * return * else: - * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format = PyObject_Malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 */ /*else*/ { - __pyx_v_info->format = ((char *)malloc(0xFF)); + __pyx_v_info->format = ((char *)PyObject_Malloc(0xFF)); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":283 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":330 * else: - * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format = PyObject_Malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< * offset = 0 * f = _util_dtypestring(descr, info.format + 1, */ (__pyx_v_info->format[0]) = '^'; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":284 - * info.format = stdlib.malloc(_buffer_format_string_len) + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":331 + * info.format = PyObject_Malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< * f = _util_dtypestring(descr, info.format + 1, @@ -5320,17 +5318,17 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_offset = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":285 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":332 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< * info.format + _buffer_format_string_len, * &offset) */ - __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(1, 285, __pyx_L1_error) - __pyx_v_f = __pyx_t_7; + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(1, 332, __pyx_L1_error) + __pyx_v_f = __pyx_t_9; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":288 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":335 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< @@ -5340,12 +5338,12 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_f[0]) = '\x00'; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":197 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fullfill the PEP. + * # requirements, and does not yet fulfill the PEP. */ /* function exit code */ @@ -5353,18 +5351,18 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; - if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + if (__pyx_v_info->obj != NULL) { __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; } goto __pyx_L2; __pyx_L0:; - if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { - __Pyx_GOTREF(Py_None); - __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + if (__pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; } __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_descr); @@ -5372,12 +5370,12 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":290 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) + * PyObject_Free(info.format) */ /* Python wrapper */ @@ -5396,75 +5394,75 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":291 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< - * stdlib.free(info.format) + * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":292 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":339 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) # <<<<<<<<<<<<<< + * PyObject_Free(info.format) # <<<<<<<<<<<<<< * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * stdlib.free(info.strides) + * PyObject_Free(info.strides) */ - free(__pyx_v_info->format); + PyObject_Free(__pyx_v_info->format); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":291 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< - * stdlib.free(info.format) + * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":293 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) + * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * stdlib.free(info.strides) + * PyObject_Free(info.strides) * # info.shape was stored after info.strides in the same block */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":294 - * stdlib.free(info.format) + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":341 + * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * stdlib.free(info.strides) # <<<<<<<<<<<<<< + * PyObject_Free(info.strides) # <<<<<<<<<<<<<< * # info.shape was stored after info.strides in the same block * */ - free(__pyx_v_info->strides); + PyObject_Free(__pyx_v_info->strides); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":293 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) + * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * stdlib.free(info.strides) + * PyObject_Free(info.strides) * # info.shape was stored after info.strides in the same block */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":290 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): - * stdlib.free(info.format) + * PyObject_Free(info.format) */ /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":770 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -5478,7 +5476,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":771 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< @@ -5486,13 +5484,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ * cdef inline object PyArray_MultiIterNew2(a, b): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 771, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":770 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -5511,7 +5509,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":773 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -5525,7 +5523,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":774 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":825 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< @@ -5533,13 +5531,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 774, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 825, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":773 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -5558,7 +5556,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":776 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -5572,7 +5570,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":777 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< @@ -5580,13 +5578,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":776 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -5605,7 +5603,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":779 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -5619,7 +5617,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":780 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< @@ -5627,13 +5625,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 831, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":779 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -5652,7 +5650,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":782 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -5666,21 +5664,21 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":783 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + * cdef inline tuple PyDataType_SHAPE(dtype d): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 834, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":782 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -5699,9 +5697,83 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":785 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); + + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< + * return d.subarray.shape + * else: + */ + __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); + if (__pyx_t_1) { + + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape # <<<<<<<<<<<<<< + * else: + * return () + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape)); + __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); + goto __pyx_L0; + + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< + * return d.subarray.shape + * else: + */ + } + + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 + * return d.subarray.shape + * else: + * return () # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_empty_tuple); + __pyx_r = __pyx_empty_tuple; + goto __pyx_L0; + } + + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 * return PyArray_MultiIterNew(5, a, b, c, d, e) * + * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 + * return () + * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. @@ -5728,7 +5800,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx char *__pyx_t_9; __Pyx_RefNannySetupContext("_util_dtypestring", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":790 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":847 * * cdef dtype child * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -5737,7 +5809,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_endian_detector = 1; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":791 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":848 * cdef dtype child * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -5746,7 +5818,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":794 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -5755,21 +5827,21 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ if (unlikely(__pyx_v_descr->names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - __PYX_ERR(1, 794, __pyx_L1_error) + __PYX_ERR(1, 851, __pyx_L1_error) } __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 794, __pyx_L1_error) + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 851, __pyx_L1_error) #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 794, __pyx_L1_error) + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 851, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":795 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":852 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< @@ -5778,15 +5850,15 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ if (unlikely(__pyx_v_descr->fields == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(1, 795, __pyx_L1_error) + __PYX_ERR(1, 852, __pyx_L1_error) } - __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 795, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 852, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 795, __pyx_L1_error) + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 852, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":796 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":853 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< @@ -5795,15 +5867,11 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ if (likely(__pyx_v_fields != Py_None)) { PyObject* sequence = __pyx_v_fields; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(1, 796, __pyx_L1_error) + __PYX_ERR(1, 853, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); @@ -5811,51 +5879,51 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else - __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 796, __pyx_L1_error) + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 796, __pyx_L1_error) + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { - __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 796, __pyx_L1_error) + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 853, __pyx_L1_error) } - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 796, __pyx_L1_error) + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 853, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":798 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ - __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 798, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 798, __pyx_L1_error) + __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 798, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 855, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); - if (__pyx_t_6) { + if (unlikely(__pyx_t_6)) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":799 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 856, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 799, __pyx_L1_error) + __PYX_ERR(1, 856, __pyx_L1_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":798 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< @@ -5864,7 +5932,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -5884,7 +5952,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L8_next_or:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":802 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":859 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -5901,29 +5969,29 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ - if (__pyx_t_6) { + if (unlikely(__pyx_t_6)) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":803 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":860 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 803, __pyx_L1_error) + __PYX_ERR(1, 860, __pyx_L1_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -5932,7 +6000,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":813 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":870 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< @@ -5940,15 +6008,15 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * f += 1 */ while (1) { - __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 813, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 870, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 813, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 870, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 813, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 870, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":814 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":871 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< @@ -5957,7 +6025,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ (__pyx_v_f[0]) = 0x78; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":815 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":872 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< @@ -5966,7 +6034,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":816 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":873 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< @@ -5977,7 +6045,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":818 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":875 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< @@ -5987,7 +6055,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":820 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -5997,19 +6065,19 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":821 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":878 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") */ - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 821, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 878, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":822 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -6017,22 +6085,22 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * */ __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); - if (__pyx_t_6) { + if (unlikely(__pyx_t_6)) { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":823 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 880, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(1, 823, __pyx_L1_error) + __PYX_ERR(1, 880, __pyx_L1_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":822 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -6041,252 +6109,252 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":826 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":883 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 826, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 826, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 883, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 826, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 883, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 98; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":827 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":884 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 827, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 884, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 827, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 884, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 827, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 884, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 66; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":828 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":885 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 828, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 885, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 828, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 885, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 828, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 885, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x68; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":829 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":886 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 829, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 886, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 829, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 886, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 829, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 886, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 72; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":830 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":887 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 830, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 887, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 830, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 887, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 830, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 887, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x69; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":831 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":888 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 831, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 888, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 831, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 888, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 831, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 888, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 73; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":832 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":889 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 832, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 889, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 832, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 889, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 832, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 889, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x6C; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":833 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":890 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 833, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 890, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 833, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 890, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 833, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 890, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 76; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":834 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":891 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 834, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 834, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 891, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 834, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 891, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x71; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":835 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":892 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 835, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 892, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 835, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 892, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 835, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 892, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 81; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":836 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":893 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 893, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 836, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 893, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 836, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 893, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x66; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":837 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":894 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 837, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 894, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 894, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 837, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 894, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x64; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":838 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":895 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 895, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 838, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 895, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 838, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 895, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x67; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":839 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":896 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 839, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 896, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 839, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 896, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 839, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 896, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; @@ -6295,18 +6363,18 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":840 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":897 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 840, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 840, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 897, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 840, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 897, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; @@ -6315,18 +6383,18 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":841 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":898 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 841, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 841, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 898, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 841, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 898, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; @@ -6335,25 +6403,25 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":842 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":899 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 899, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 842, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 899, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 842, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 899, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { + if (likely(__pyx_t_6)) { (__pyx_v_f[0]) = 79; goto __pyx_L15; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":844 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":901 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -6361,23 +6429,18 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * else: */ /*else*/ { - __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 901, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 901, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 844, __pyx_L1_error) + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(1, 901, __pyx_L1_error) } __pyx_L15:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":845 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":902 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< @@ -6386,7 +6449,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":820 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -6396,7 +6459,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L13; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":849 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":906 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< @@ -6404,12 +6467,12 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * */ /*else*/ { - __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) __PYX_ERR(1, 849, __pyx_L1_error) + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(1, 906, __pyx_L1_error) __pyx_v_f = __pyx_t_9; } __pyx_L13:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":794 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -6419,7 +6482,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":850 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":907 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< @@ -6429,8 +6492,8 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_r = __pyx_v_f; goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":785 - * return PyArray_MultiIterNew(5, a, b, c, d, e) + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 + * return () * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format @@ -6454,167 +6517,120 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":966 - * +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 + * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * cdef PyObject* baseptr - * if base is None: + * Py_INCREF(base) # important to do this before stealing the reference below! + * PyArray_SetBaseObject(arr, base) */ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { - PyObject *__pyx_v_baseptr; __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; __Pyx_RefNannySetupContext("set_array_base", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":968 - * cdef inline void set_array_base(ndarray arr, object base): - * cdef PyObject* baseptr - * if base is None: # <<<<<<<<<<<<<< - * baseptr = NULL - * else: - */ - __pyx_t_1 = (__pyx_v_base == Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":969 - * cdef PyObject* baseptr - * if base is None: - * baseptr = NULL # <<<<<<<<<<<<<< - * else: - * Py_INCREF(base) # important to do this before decref below! - */ - __pyx_v_baseptr = NULL; - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":968 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1023 + * * cdef inline void set_array_base(ndarray arr, object base): - * cdef PyObject* baseptr - * if base is None: # <<<<<<<<<<<<<< - * baseptr = NULL - * else: - */ - goto __pyx_L3; - } - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":971 - * baseptr = NULL - * else: - * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< - * baseptr = base - * Py_XDECREF(arr.base) - */ - /*else*/ { - Py_INCREF(__pyx_v_base); - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":972 - * else: - * Py_INCREF(base) # important to do this before decref below! - * baseptr = base # <<<<<<<<<<<<<< - * Py_XDECREF(arr.base) - * arr.base = baseptr - */ - __pyx_v_baseptr = ((PyObject *)__pyx_v_base); - } - __pyx_L3:; - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":973 - * Py_INCREF(base) # important to do this before decref below! - * baseptr = base - * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< - * arr.base = baseptr + * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<< + * PyArray_SetBaseObject(arr, base) * */ - Py_XDECREF(__pyx_v_arr->base); + Py_INCREF(__pyx_v_base); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":974 - * baseptr = base - * Py_XDECREF(arr.base) - * arr.base = baseptr # <<<<<<<<<<<<<< + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1024 + * cdef inline void set_array_base(ndarray arr, object base): + * Py_INCREF(base) # important to do this before stealing the reference below! + * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<< * * cdef inline object get_array_base(ndarray arr): */ - __pyx_v_arr->base = __pyx_v_baseptr; + (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base)); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":966 - * + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 + * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * cdef PyObject* baseptr - * if base is None: + * Py_INCREF(base) # important to do this before stealing the reference below! + * PyArray_SetBaseObject(arr, base) */ /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":976 - * arr.base = baseptr +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 + * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * if arr.base is NULL: - * return None + * base = PyArray_BASE(arr) + * if base is NULL: */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_v_base; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":977 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1027 * * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: # <<<<<<<<<<<<<< + * base = PyArray_BASE(arr) # <<<<<<<<<<<<<< + * if base is NULL: * return None - * else: */ - __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); - if (__pyx_t_1) { + __pyx_v_base = PyArray_BASE(__pyx_v_arr); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":978 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: + * base = PyArray_BASE(arr) + * if base is NULL: # <<<<<<<<<<<<<< + * return None + * return base + */ + __pyx_t_1 = ((__pyx_v_base == NULL) != 0); + if (__pyx_t_1) { + + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1029 + * base = PyArray_BASE(arr) + * if base is NULL: * return None # <<<<<<<<<<<<<< - * else: - * return arr.base + * return base + * */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = Py_None; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":977 - * + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: # <<<<<<<<<<<<<< + * base = PyArray_BASE(arr) + * if base is NULL: # <<<<<<<<<<<<<< * return None - * else: + * return base */ } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":980 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1030 + * if base is NULL: * return None - * else: - * return arr.base # <<<<<<<<<<<<<< - * + * return base # <<<<<<<<<<<<<< * + * # Versions of the import_* functions which are more suitable for */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); - __pyx_r = ((PyObject *)__pyx_v_arr->base); - goto __pyx_L0; - } + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_base)); + __pyx_r = ((PyObject *)__pyx_v_base); + goto __pyx_L0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":976 - * arr.base = baseptr + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 + * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * if arr.base is NULL: - * return None + * base = PyArray_BASE(arr) + * if base is NULL: */ /* function exit code */ @@ -6624,7 +6640,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":985 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -6645,7 +6661,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_array", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":986 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -6661,16 +6677,16 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":987 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1036 * cdef inline int import_array() except -1: * try: * _import_array() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.multiarray failed to import") */ - __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 987, __pyx_L3_error) + __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1036, __pyx_L3_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":986 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -6683,9 +6699,8 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; - __Pyx_PyThreadState_assign - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":988 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1037 * try: * _import_array() * except Exception: # <<<<<<<<<<<<<< @@ -6695,35 +6710,34 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 988, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1037, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":989 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 * _import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_umath() except -1: */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 989, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1038, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 989, __pyx_L5_except_error) + __PYX_ERR(1, 1038, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":986 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< * _import_array() * except Exception: */ - __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); @@ -6732,7 +6746,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __pyx_L8_try_end:; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":985 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -6755,7 +6769,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":991 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -6776,7 +6790,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_umath", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":992 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -6792,16 +6806,16 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":993 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1042 * cdef inline int import_umath() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.umath failed to import") */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 993, __pyx_L3_error) + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1042, __pyx_L3_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":992 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -6814,9 +6828,8 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; - __Pyx_PyThreadState_assign - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":994 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1043 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -6826,35 +6839,34 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 994, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1043, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":995 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_ufunc() except -1: */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 995, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1044, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 995, __pyx_L5_except_error) + __PYX_ERR(1, 1044, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":992 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< * _import_umath() * except Exception: */ - __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); @@ -6863,7 +6875,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __pyx_L8_try_end:; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":991 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -6886,7 +6898,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { return __pyx_r; } -/* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":997 +/* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -6907,7 +6919,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_ufunc", 0); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":998 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -6923,16 +6935,16 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":999 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1048 * cdef inline int import_ufunc() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.umath failed to import") */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 999, __pyx_L3_error) + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1048, __pyx_L3_error) - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":998 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -6945,9 +6957,8 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; - __Pyx_PyThreadState_assign - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1000 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1049 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -6956,33 +6967,32 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1000, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1049, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1001 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1050 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1001, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1050, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 1001, __pyx_L5_except_error) + __PYX_ERR(1, 1050, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":998 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< * _import_umath() * except Exception: */ - __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); @@ -6991,7 +7001,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __pyx_L8_try_end:; } - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":997 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -7019,22 +7029,45 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_cython_nms(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_cython_nms}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "cython_nms", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif +#ifndef CYTHON_SMALL_CODE +#if defined(__clang__) + #define CYTHON_SMALL_CODE +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) + #define CYTHON_SMALL_CODE __attribute__((cold)) +#else + #define CYTHON_SMALL_CODE +#endif +#endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, @@ -7077,6 +7110,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_maxpos, __pyx_k_maxpos, sizeof(__pyx_k_maxpos), 0, 0, 1, 1}, {&__pyx_n_s_maxscore, __pyx_k_maxscore, sizeof(__pyx_k_maxscore), 0, 0, 1, 1}, {&__pyx_n_s_method, __pyx_k_method, sizeof(__pyx_k_method), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, {&__pyx_n_s_ndets, __pyx_k_ndets, sizeof(__pyx_k_ndets), 0, 0, 1, 1}, @@ -7123,17 +7157,17 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; -static int __Pyx_InitCachedBuiltins(void) { +static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 63, __pyx_L1_error) - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 218, __pyx_L1_error) - __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 799, __pyx_L1_error) - __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 989, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 272, __pyx_L1_error) + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 856, __pyx_L1_error) + __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 1038, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } -static int __Pyx_InitCachedConstants(void) { +static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); @@ -7158,12 +7192,9 @@ static int __Pyx_InitCachedConstants(void) { * cdef np.ndarray[np.float32_t, ndim=1] x2 = dets[:, 2] * cdef np.ndarray[np.float32_t, ndim=1] y2 = dets[:, 3] */ - __pyx_slice__3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 39, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__3); - __Pyx_GIVEREF(__pyx_slice__3); - __pyx_tuple__4 = PyTuple_Pack(2, __pyx_slice__3, __pyx_int_1); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 39, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); + __pyx_tuple__3 = PyTuple_Pack(2, __pyx_slice_, __pyx_int_1); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 39, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); /* "utils/cython_nms.pyx":40 * cdef np.ndarray[np.float32_t, ndim=1] x1 = dets[:, 0] @@ -7172,12 +7203,9 @@ static int __Pyx_InitCachedConstants(void) { * cdef np.ndarray[np.float32_t, ndim=1] y2 = dets[:, 3] * cdef np.ndarray[np.float32_t, ndim=1] scores = dets[:, 4] */ - __pyx_slice__5 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__5)) __PYX_ERR(0, 40, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__5); - __Pyx_GIVEREF(__pyx_slice__5); - __pyx_tuple__6 = PyTuple_Pack(2, __pyx_slice__5, __pyx_int_2); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 40, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); + __pyx_tuple__4 = PyTuple_Pack(2, __pyx_slice_, __pyx_int_2); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 40, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); /* "utils/cython_nms.pyx":41 * cdef np.ndarray[np.float32_t, ndim=1] y1 = dets[:, 1] @@ -7186,12 +7214,9 @@ static int __Pyx_InitCachedConstants(void) { * cdef np.ndarray[np.float32_t, ndim=1] scores = dets[:, 4] * */ - __pyx_slice__7 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__7)) __PYX_ERR(0, 41, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__7); - __Pyx_GIVEREF(__pyx_slice__7); - __pyx_tuple__8 = PyTuple_Pack(2, __pyx_slice__7, __pyx_int_3); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 41, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); + __pyx_tuple__5 = PyTuple_Pack(2, __pyx_slice_, __pyx_int_3); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 41, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); /* "utils/cython_nms.pyx":42 * cdef np.ndarray[np.float32_t, ndim=1] x2 = dets[:, 2] @@ -7200,12 +7225,9 @@ static int __Pyx_InitCachedConstants(void) { * * cdef np.ndarray[np.float32_t, ndim=1] areas = (x2 - x1 + 1) * (y2 - y1 + 1) */ - __pyx_slice__9 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__9)) __PYX_ERR(0, 42, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__9); - __Pyx_GIVEREF(__pyx_slice__9); - __pyx_tuple__10 = PyTuple_Pack(2, __pyx_slice__9, __pyx_int_4); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 42, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); + __pyx_tuple__6 = PyTuple_Pack(2, __pyx_slice_, __pyx_int_4); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 42, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); /* "utils/cython_nms.pyx":45 * @@ -7214,106 +7236,86 @@ static int __Pyx_InitCachedConstants(void) { * * cdef int ndets = dets.shape[0] */ - __pyx_slice__11 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__11)) __PYX_ERR(0, 45, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__11); - __Pyx_GIVEREF(__pyx_slice__11); + __pyx_slice__7 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__7)) __PYX_ERR(0, 45, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__7); + __Pyx_GIVEREF(__pyx_slice__7); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":218 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 218, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__12); - __Pyx_GIVEREF(__pyx_tuple__12); + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 272, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":222 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ - __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 222, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__13); - __Pyx_GIVEREF(__pyx_tuple__13); + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 276, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":259 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 259, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__14); - __Pyx_GIVEREF(__pyx_tuple__14); + __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 306, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":799 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ - __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(1, 799, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__15); - __Pyx_GIVEREF(__pyx_tuple__15); - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":803 - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * # One could encode it in the format string and have Cython - * # complain instead, BUT: < and > in format strings also imply - */ - __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 803, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__16); - __Pyx_GIVEREF(__pyx_tuple__16); + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 856, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":823 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 823, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__17); - __Pyx_GIVEREF(__pyx_tuple__17); + __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 880, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_GIVEREF(__pyx_tuple__12); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":989 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 * _import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_umath() except -1: */ - __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 989, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__18); - __Pyx_GIVEREF(__pyx_tuple__18); + __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 1038, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":995 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_ufunc() except -1: */ - __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(1, 995, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__19); - __Pyx_GIVEREF(__pyx_tuple__19); - - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1001 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - */ - __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(1, 1001, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__20); - __Pyx_GIVEREF(__pyx_tuple__20); + __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 1044, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__14); + __Pyx_GIVEREF(__pyx_tuple__14); /* "utils/cython_nms.pyx":37 * @cython.cdivision(True) @@ -7322,10 +7324,10 @@ static int __Pyx_InitCachedConstants(void) { * cdef np.ndarray[np.float32_t, ndim=1] x1 = dets[:, 0] * cdef np.ndarray[np.float32_t, ndim=1] y1 = dets[:, 1] */ - __pyx_tuple__21 = PyTuple_Pack(28, __pyx_n_s_dets, __pyx_n_s_thresh, __pyx_n_s_x1, __pyx_n_s_y1, __pyx_n_s_x2, __pyx_n_s_y2, __pyx_n_s_scores, __pyx_n_s_areas, __pyx_n_s_order, __pyx_n_s_ndets, __pyx_n_s_suppressed, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_i_2, __pyx_n_s_j_2, __pyx_n_s_ix1, __pyx_n_s_iy1, __pyx_n_s_ix2, __pyx_n_s_iy2, __pyx_n_s_iarea, __pyx_n_s_xx1, __pyx_n_s_yy1, __pyx_n_s_xx2, __pyx_n_s_yy2, __pyx_n_s_w, __pyx_n_s_h, __pyx_n_s_inter, __pyx_n_s_ovr); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 37, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__21); - __Pyx_GIVEREF(__pyx_tuple__21); - __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(2, 0, 28, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_utils_cython_nms_pyx, __pyx_n_s_nms, 37, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 37, __pyx_L1_error) + __pyx_tuple__15 = PyTuple_Pack(28, __pyx_n_s_dets, __pyx_n_s_thresh, __pyx_n_s_x1, __pyx_n_s_y1, __pyx_n_s_x2, __pyx_n_s_y2, __pyx_n_s_scores, __pyx_n_s_areas, __pyx_n_s_order, __pyx_n_s_ndets, __pyx_n_s_suppressed, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_i_2, __pyx_n_s_j_2, __pyx_n_s_ix1, __pyx_n_s_iy1, __pyx_n_s_ix2, __pyx_n_s_iy2, __pyx_n_s_iarea, __pyx_n_s_xx1, __pyx_n_s_yy1, __pyx_n_s_xx2, __pyx_n_s_yy2, __pyx_n_s_w, __pyx_n_s_h, __pyx_n_s_inter, __pyx_n_s_ovr); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__15); + __Pyx_GIVEREF(__pyx_tuple__15); + __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(2, 0, 28, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_utils_cython_nms_pyx, __pyx_n_s_nms, 37, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 37, __pyx_L1_error) /* "utils/cython_nms.pyx":98 * @cython.cdivision(True) @@ -7334,10 +7336,10 @@ static int __Pyx_InitCachedConstants(void) { * np.ndarray[float, ndim=2] boxes_in, * float sigma=0.5, */ - __pyx_tuple__23 = PyTuple_Pack(30, __pyx_n_s_boxes_in, __pyx_n_s_sigma, __pyx_n_s_Nt, __pyx_n_s_threshold, __pyx_n_s_method, __pyx_n_s_boxes, __pyx_n_s_N, __pyx_n_s_iw, __pyx_n_s_ih, __pyx_n_s_box_area, __pyx_n_s_ua, __pyx_n_s_pos, __pyx_n_s_maxscore, __pyx_n_s_maxpos, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_y1, __pyx_n_s_y2, __pyx_n_s_tx1, __pyx_n_s_tx2, __pyx_n_s_ty1, __pyx_n_s_ty2, __pyx_n_s_ts, __pyx_n_s_area, __pyx_n_s_weight, __pyx_n_s_ov, __pyx_n_s_inds, __pyx_n_s_i_2, __pyx_n_s_ti, __pyx_n_s_s); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 98, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__23); - __Pyx_GIVEREF(__pyx_tuple__23); - __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(5, 0, 30, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_utils_cython_nms_pyx, __pyx_n_s_soft_nms, 98, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 98, __pyx_L1_error) + __pyx_tuple__17 = PyTuple_Pack(30, __pyx_n_s_boxes_in, __pyx_n_s_sigma, __pyx_n_s_Nt, __pyx_n_s_threshold, __pyx_n_s_method, __pyx_n_s_boxes, __pyx_n_s_N, __pyx_n_s_iw, __pyx_n_s_ih, __pyx_n_s_box_area, __pyx_n_s_ua, __pyx_n_s_pos, __pyx_n_s_maxscore, __pyx_n_s_maxpos, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_y1, __pyx_n_s_y2, __pyx_n_s_tx1, __pyx_n_s_tx2, __pyx_n_s_ty1, __pyx_n_s_ty2, __pyx_n_s_ts, __pyx_n_s_area, __pyx_n_s_weight, __pyx_n_s_ov, __pyx_n_s_inds, __pyx_n_s_i_2, __pyx_n_s_ti, __pyx_n_s_s); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 98, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__17); + __Pyx_GIVEREF(__pyx_tuple__17); + __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(5, 0, 30, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_utils_cython_nms_pyx, __pyx_n_s_soft_nms, 98, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -7345,7 +7347,7 @@ static int __Pyx_InitCachedConstants(void) { return -1; } -static int __Pyx_InitGlobals(void) { +static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -7358,59 +7360,256 @@ static int __Pyx_InitGlobals(void) { return -1; } -#if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC initcython_nms(void); /*proto*/ -PyMODINIT_FUNC initcython_nms(void) -#else -PyMODINIT_FUNC PyInit_cython_nms(void); /*proto*/ -PyMODINIT_FUNC PyInit_cython_nms(void) -#endif -{ - PyObject *__pyx_t_1 = NULL; +static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ + +static int __Pyx_modinit_global_init_code(void) { __Pyx_RefNannyDeclarations - #if CYTHON_REFNANNY - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); - if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); - } - #endif - __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_cython_nms(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); + /*--- Global init code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_variable_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); + /*--- Variable export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); + /*--- Function export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_type_init_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); + /*--- Type init code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_type_import_code(void) { + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); + /*--- Type import code ---*/ + __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", + #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 206, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore); + if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(1, 206, __pyx_L1_error) + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(1, 229, __pyx_L1_error) + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(1, 233, __pyx_L1_error) + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore); + if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(1, 242, __pyx_L1_error) + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(1, 918, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_modinit_variable_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); + /*--- Variable import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); + /*--- Function import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + + +#if PY_MAJOR_VERSION < 3 +#ifdef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC void +#else +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#endif +#else +#ifdef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC PyObject * +#else +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#endif +#endif + + +#if PY_MAJOR_VERSION < 3 +__Pyx_PyMODINIT_FUNC initcython_nms(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC initcython_nms(void) +#else +__Pyx_PyMODINIT_FUNC PyInit_cython_nms(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC PyInit_cython_nms(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { + #if PY_VERSION_HEX >= 0x030700A1 + static PY_INT64_T main_interpreter_id = -1; + PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); + if (main_interpreter_id == -1) { + main_interpreter_id = current_id; + return (unlikely(current_id == -1)) ? -1 : 0; + } else if (unlikely(main_interpreter_id != current_id)) + #else + static PyInterpreterState *main_interpreter = NULL; + PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; + if (!main_interpreter) { + main_interpreter = current_interpreter; + } else if (unlikely(main_interpreter != current_interpreter)) + #endif + { + PyErr_SetString( + PyExc_ImportError, + "Interpreter change detected - this module can only be loaded into one interpreter per process."); + return -1; + } + return 0; +} +static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + if (allow_none || value != Py_None) { + result = PyDict_SetItemString(moddict, to_name, value); + } + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__Pyx_check_single_interpreter()) + return NULL; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static CYTHON_SMALL_CODE int __pyx_pymod_exec_cython_nms(PyObject *__pyx_pyinit_module) +#endif +#endif +{ + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m) { + if (__pyx_m == __pyx_pyinit_module) return 0; + PyErr_SetString(PyExc_RuntimeError, "Module 'cython_nms' has already been imported. Re-initialisation is not supported."); + return -1; + } + #elif PY_MAJOR_VERSION >= 3 + if (__pyx_m) return __Pyx_NewRef(__pyx_m); + #endif + #if CYTHON_REFNANNY +__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); +if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); +} +#endif + __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cython_nms(void)", 0); + if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pxy_PyFrame_Initialize_Offsets + __Pxy_PyFrame_Initialize_Offsets(); + #endif + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pyx_CyFunction_USED + if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS #ifdef WITH_THREAD /* Python build with threading support? */ PyEval_InitThreads(); #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("cython_nms", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -7425,7 +7624,7 @@ PyMODINIT_FUNC PyInit_cython_nms(void) if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif if (__pyx_module_is_main_utils__cython_nms) { - if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { @@ -7439,25 +7638,14 @@ PyMODINIT_FUNC PyInit_cython_nms(void) if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global init code ---*/ - /*--- Variable export code ---*/ - /*--- Function export code ---*/ - /*--- Type init code ---*/ - /*--- Type import code ---*/ - __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", - #if CYTHON_COMPILING_IN_PYPY - sizeof(PyTypeObject), - #else - sizeof(PyHeapTypeObject), - #endif - 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(2, 9, __pyx_L1_error) - __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(1, 155, __pyx_L1_error) - __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(1, 168, __pyx_L1_error) - __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(1, 172, __pyx_L1_error) - __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(1, 181, __pyx_L1_error) - __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(1, 861, __pyx_L1_error) - /*--- Variable import code ---*/ - /*--- Function import code ---*/ + /*--- Global type/function init code ---*/ + (void)__Pyx_modinit_global_init_code(); + (void)__Pyx_modinit_variable_export_code(); + (void)__Pyx_modinit_function_export_code(); + (void)__Pyx_modinit_type_init_code(); + if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error; + (void)__Pyx_modinit_variable_import_code(); + (void)__Pyx_modinit_function_import_code(); /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) @@ -7504,12 +7692,12 @@ PyMODINIT_FUNC PyInit_cython_nms(void) * # * # Licensed under the Apache License, Version 2.0 (the "License"); */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":997 + /* "../../../../../home/aditya.a/Libraries/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -7524,18 +7712,20 @@ PyMODINIT_FUNC PyInit_cython_nms(void) __Pyx_XDECREF(__pyx_t_1); if (__pyx_m) { if (__pyx_d) { - __Pyx_AddTraceback("init utils.cython_nms", 0, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("init utils.cython_nms", __pyx_clineno, __pyx_lineno, __pyx_filename); } - Py_DECREF(__pyx_m); __pyx_m = 0; + Py_CLEAR(__pyx_m); } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init utils.cython_nms"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -7545,9 +7735,9 @@ PyMODINIT_FUNC PyInit_cython_nms(void) static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; - m = PyImport_ImportModule((char *)modname); + m = PyImport_ImportModule(modname); if (!m) goto end; - p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + p = PyObject_GetAttrString(m, "RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: @@ -7557,6 +7747,20 @@ static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { } #endif +/* PyObjectGetAttrStr */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#endif + /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); @@ -7714,29 +7918,23 @@ static int __Pyx_ParseOptionalKeywords( } /* ArgTypeTest */ -static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); -} -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (none_allowed && obj == Py_None) return 1; else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; + if (likely(__Pyx_TypeCheck(obj, type))) return 1; } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; } @@ -8073,7 +8271,7 @@ static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { ctx->is_complex = 0; return 0; } -static CYTHON_INLINE PyObject * +static PyObject * __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) { const char *ts = *tsp; @@ -8211,6 +8409,7 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha __Pyx_BufFmt_RaiseUnexpectedChar('Z'); return NULL; } + CYTHON_FALLTHROUGH; case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': case 'l': case 'L': case 'q': case 'Q': case 'f': case 'd': case 'g': @@ -8223,6 +8422,7 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha ++ts; break; } + CYTHON_FALLTHROUGH; case 's': if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_count = ctx->new_count; @@ -8250,24 +8450,30 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha } } } -static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { + +/* BufferGetAndValidate */ + static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (unlikely(info->buf == NULL)) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); +} +static void __Pyx_ZeroBuffer(Py_buffer* buf) { buf->buf = NULL; buf->obj = NULL; buf->strides = __Pyx_zeros; buf->shape = __Pyx_zeros; buf->suboffsets = __Pyx_minusones; } -static CYTHON_INLINE int __Pyx_GetBufferAndValidate( +static int __Pyx__GetBufferAndValidate( Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack) { - if (obj == Py_None || obj == NULL) { + buf->buf = NULL; + if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) { __Pyx_ZeroBuffer(buf); - return 0; + return -1; } - buf->buf = NULL; - if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; - if (buf->ndim != nd) { + if (unlikely(buf->ndim != nd)) { PyErr_Format(PyExc_ValueError, "Buffer has wrong number of dimensions (expected %d, got %d)", nd, buf->ndim); @@ -8278,7 +8484,7 @@ static CYTHON_INLINE int __Pyx_GetBufferAndValidate( __Pyx_BufFmt_Init(&ctx, stack, dtype); if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; } - if ((unsigned)buf->itemsize != dtype->size) { + if (unlikely((unsigned)buf->itemsize != dtype->size)) { PyErr_Format(PyExc_ValueError, "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", buf->itemsize, (buf->itemsize > 1) ? "s" : "", @@ -8288,22 +8494,133 @@ static CYTHON_INLINE int __Pyx_GetBufferAndValidate( if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; return 0; fail:; - __Pyx_ZeroBuffer(buf); + __Pyx_SafeReleaseBuffer(buf); return -1; } -static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { - if (info->buf == NULL) return; - if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; - __Pyx_ReleaseBuffer(info); + +/* GetItemInt */ + static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyList_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyTuple_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return NULL; + PyErr_Clear(); + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } +/* ObjectGetItem */ + #if CYTHON_USE_TYPE_SLOTS +static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { + PyObject *runerr; + Py_ssize_t key_value; + PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; + if (unlikely(!(m && m->sq_item))) { + PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); + return NULL; + } + key_value = __Pyx_PyIndex_AsSsize_t(index); + if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { + return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); + } + if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { + PyErr_Clear(); + PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); + } + return NULL; +} +static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { + PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; + if (likely(m && m->mp_subscript)) { + return m->mp_subscript(obj, key); + } + return __Pyx_PyObject_GetIndex(obj, key); +} +#endif + /* ExtTypeTest */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (likely(PyObject_TypeCheck(obj, type))) + if (likely(__Pyx_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); @@ -8349,6 +8666,7 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED goto long_long; #endif } + CYTHON_FALLTHROUGH; case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); @@ -8359,6 +8677,7 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED goto long_long; #endif } + CYTHON_FALLTHROUGH; case -3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); @@ -8369,6 +8688,7 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED goto long_long; #endif } + CYTHON_FALLTHROUGH; case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); @@ -8379,6 +8699,7 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED goto long_long; #endif } + CYTHON_FALLTHROUGH; case -4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); @@ -8389,6 +8710,7 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED goto long_long; #endif } + CYTHON_FALLTHROUGH; case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); @@ -8399,6 +8721,7 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED goto long_long; #endif } + CYTHON_FALLTHROUGH; default: return PyLong_Type.tp_as_number->nb_add(op1, op2); } } @@ -8426,36 +8749,12 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED } #endif -/* PyCFunctionFastCall */ - #if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { - return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL); - } else { - return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs); - } -} -#endif - /* PyFunctionFastCall */ #if CYTHON_FAST_PYCALL -#include "frameobject.h" static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, PyObject *globals) { PyFrameObject *f; - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject **fastlocals; Py_ssize_t i; PyObject *result; @@ -8469,7 +8768,7 @@ static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args if (f == NULL) { return NULL; } - fastlocals = f->f_localsplus; + fastlocals = __Pyx_PyFrame_GetLocalsplus(f); for (i = 0; i < na; i++) { Py_INCREF(*args); fastlocals[i] = *args++; @@ -8609,6 +8908,51 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject } #endif +/* PyObjectCallNoArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, NULL, 0); + } +#endif +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func))) +#else + if (likely(PyCFunction_Check(func))) +#endif + { + if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { + return __Pyx_PyObject_CallMethO(func, NULL); + } + } + return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); +} +#endif + +/* PyCFunctionFastCall */ + #if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + int flags = PyCFunction_GET_FLAGS(func); + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { + return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); + } else { + return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); + } +} +#endif + /* PyObjectCallOneArg */ #if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { @@ -8647,136 +8991,74 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec Py_DECREF(args); return result; } -#endif - -/* PyObjectCallNoArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, NULL, 0); - } -#endif -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { -#endif - if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { - return __Pyx_PyObject_CallMethO(func, NULL); - } - } - return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); -} -#endif - -/* GetModuleGlobalName */ - static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS - result = PyDict_GetItem(__pyx_d, name); - if (likely(result)) { - Py_INCREF(result); - } else { -#else - result = PyObject_GetItem(__pyx_d, name); - if (!result) { - PyErr_Clear(); -#endif - result = __Pyx_GetBuiltinName(name); - } - return result; -} - -/* GetItemInt */ - static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!j) return NULL; - r = PyObject_GetItem(o, j); - Py_DECREF(j); - return r; -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyList_GET_SIZE(o); - } - if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyTuple_GET_SIZE(o); - } - if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } +#endif + +/* GetModuleGlobalName */ + #if CYTHON_USE_DICT_VERSIONS +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) +#else +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) +#endif +{ + PyObject *result; +#if !CYTHON_AVOID_BORROWED_REFS +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 + result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } else if (unlikely(PyErr_Occurred())) { + return NULL; } #else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); + result = PyDict_GetItem(__pyx_d, name); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); } #endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + result = PyObject_GetItem(__pyx_d, name); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } + PyErr_Clear(); +#endif + return __Pyx_GetBuiltinName(name); +} + +/* PyObjectCall2Args */ + static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { + PyObject *args, *result = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(function)) { + PyObject *args[2] = {arg1, arg2}; + return __Pyx_PyFunction_FastCall(function, args, 2); + } + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(function)) { + PyObject *args[2] = {arg1, arg2}; + return __Pyx_PyCFunction_FastCall(function, args, 2); + } + #endif + args = PyTuple_New(2); + if (unlikely(!args)) goto done; + Py_INCREF(arg1); + PyTuple_SET_ITEM(args, 0, arg1); + Py_INCREF(arg2); + PyTuple_SET_ITEM(args, 1, arg2); + Py_INCREF(function); + result = __Pyx_PyObject_Call(function, args, NULL); + Py_DECREF(args); + Py_DECREF(function); +done: + return result; } /* PyErrFetchRestore */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; @@ -8800,7 +9082,7 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject #endif /* SetItemInt */ - static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { + static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { int r; if (!j) return -1; r = PyObject_SetItem(o, j, v); @@ -8812,7 +9094,7 @@ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObje #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); - if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) { + if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) { PyObject* old = PyList_GET_ITEM(o, n); Py_INCREF(v); PyList_SET_ITEM(o, n, v); @@ -8837,10 +9119,11 @@ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObje } #else #if CYTHON_COMPILING_IN_PYPY - if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) { + if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) #else - if (is_list || PySequence_Check(o)) { + if (is_list || PySequence_Check(o)) #endif + { return PySequence_SetItem(o, i, v); } #endif @@ -8848,7 +9131,7 @@ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObje } /* SliceObject */ - static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj, + static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { @@ -8945,7 +9228,7 @@ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObje } /* RaiseException */ - #if PY_MAJOR_VERSION < 3 + #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { __Pyx_PyThreadState_declare @@ -9060,11 +9343,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } -#if PY_VERSION_HEX >= 0x03030000 if (cause) { -#else - if (cause && cause != Py_None) { -#endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; @@ -9092,7 +9371,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); @@ -9107,42 +9386,98 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } #endif +/* DictGetItem */ + #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + if (unlikely(PyTuple_Check(key))) { + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) { + PyErr_SetObject(PyExc_KeyError, args); + Py_DECREF(args); + } + } else { + PyErr_SetObject(PyExc_KeyError, key); + } + } + return NULL; + } + Py_INCREF(value); + return value; +} +#endif + /* RaiseTooManyValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* RaiseNoneIterError */ - static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } +/* GetTopmostException */ + #if CYTHON_USE_EXC_INFO_STACK +static _PyErr_StackItem * +__Pyx_PyErr_GetTopmostException(PyThreadState *tstate) +{ + _PyErr_StackItem *exc_info = tstate->exc_info; + while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && + exc_info->previous_item != NULL) + { + exc_info = exc_info->previous_item; + } + return exc_info; +} +#endif + /* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); + *type = exc_info->exc_type; + *value = exc_info->exc_value; + *tb = exc_info->exc_traceback; + #else *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; + #endif Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); } static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = type; + exc_info->exc_value = value; + exc_info->exc_traceback = tb; + #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; + #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); @@ -9150,21 +9485,37 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject #endif /* PyErrExceptionMatches */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE +static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; icurexc_type; if (exc_type == err) return 1; if (unlikely(!exc_type)) return 0; - return PyErr_GivenExceptionMatches(exc_type, err); + if (unlikely(PyTuple_Check(err))) + return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); + return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); } #endif /* GetException */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + #if CYTHON_FAST_THREAD_STATE +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) #else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) #endif +{ PyObject *local_type, *local_value, *local_tb; #if CYTHON_FAST_THREAD_STATE PyObject *tmp_type, *tmp_value, *tmp_tb; @@ -9197,12 +9548,24 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) *value = local_value; *tb = local_tb; #if CYTHON_FAST_THREAD_STATE + #if CYTHON_USE_EXC_INFO_STACK + { + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = local_type; + exc_info->exc_value = local_value; + exc_info->exc_traceback = local_tb; + } + #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; + #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); @@ -9220,14 +9583,75 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) return -1; } +/* TypeImport */ + #ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name, + size_t size, enum __Pyx_ImportType_CheckSize check_size) +{ + PyObject *result = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + result = PyObject_GetAttrString(module, class_name); + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if ((size_t)basicsize < size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + goto bad; + } + if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + goto bad; + } + else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(result); + return NULL; +} +#endif + /* Import */ - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; - #if PY_VERSION_HEX < 0x03030000 + #if PY_MAJOR_VERSION < 3 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) @@ -9251,17 +9675,8 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_level = PyInt_FromLong(1); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); - #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; @@ -9272,12 +9687,12 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) } #endif if (!module) { - #if PY_VERSION_HEX < 0x03030000 + #if PY_MAJOR_VERSION < 3 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); + name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( @@ -9286,7 +9701,7 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) } } bad: - #if PY_VERSION_HEX < 0x03030000 + #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); @@ -9295,43 +9710,49 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) } /* CLineInTraceback */ - static int __Pyx_CLineForTraceback(int c_line) { -#ifdef CYTHON_CLINE_IN_TRACEBACK - return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; -#else + #ifndef CYTHON_CLINE_IN_TRACEBACK +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { PyObject *use_cline; + PyObject *ptype, *pvalue, *ptraceback; +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict; +#endif + if (unlikely(!__pyx_cython_runtime)) { + return c_line; + } + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); #if CYTHON_COMPILING_IN_CPYTHON - PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); if (likely(cython_runtime_dict)) { - use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + __PYX_PY_DICT_LOOKUP_IF_MODIFIED( + use_cline, *cython_runtime_dict, + __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) } else #endif { - PyObject *ptype, *pvalue, *ptraceback; - PyObject *use_cline_obj; - PyErr_Fetch(&ptype, &pvalue, &ptraceback); - use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); + PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); if (use_cline_obj) { use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; Py_DECREF(use_cline_obj); } else { + PyErr_Clear(); use_cline = NULL; } - PyErr_Restore(ptype, pvalue, ptraceback); } if (!use_cline) { c_line = 0; PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); } - else if (PyObject_Not(use_cline) != 0) { + else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; -#endif } +#endif /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; @@ -9411,7 +9832,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" + #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -9470,8 +9891,9 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; + PyThreadState *tstate = __Pyx_PyThreadState_Current; if (c_line) { - c_line = __Pyx_CLineForTraceback(c_line); + c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { @@ -9481,10 +9903,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( - PyThreadState_GET(), /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __pyx_d, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ + tstate, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -9497,7 +9919,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, #if PY_MAJOR_VERSION < 3 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); - if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); + if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); return -1; } @@ -9509,15 +9931,15 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { return; } if ((0)) {} - else if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); + else if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); view->obj = NULL; Py_DECREF(obj); } #endif - /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + /* CIntFromPyVerify */ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) @@ -9539,8 +9961,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { - const int neg_one = (int) -1, const_zero = (int) 0; + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { @@ -9570,8 +9992,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { - const long neg_one = (long) -1, const_zero = (long) 0; + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { @@ -9601,8 +10023,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) { - const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) { + const unsigned int neg_one = (unsigned int) ((unsigned int) 0 - (unsigned int) 1), const_zero = (unsigned int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(unsigned int) < sizeof(long)) { @@ -9632,7 +10054,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* Declarations */ - #if CYTHON_CCOMPLEX + #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return ::std::complex< float >(x, y); @@ -9652,7 +10074,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #endif /* Arithmetic */ - #if CYTHON_CCOMPLEX + #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { return (a.real == b.real) && (a.imag == b.imag); @@ -9787,7 +10209,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #endif /* Declarations */ - #if CYTHON_CCOMPLEX + #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return ::std::complex< double >(x, y); @@ -9807,7 +10229,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #endif /* Arithmetic */ - #if CYTHON_CCOMPLEX + #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { return (a.real == b.real) && (a.imag == b.imag); @@ -9942,8 +10364,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #endif /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { - const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { + const enum NPY_TYPES neg_one = (enum NPY_TYPES) ((enum NPY_TYPES) 0 - (enum NPY_TYPES) 1), const_zero = (enum NPY_TYPES) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(enum NPY_TYPES) < sizeof(long)) { @@ -9973,8 +10395,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* CIntFromPy */ - static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { - const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; + static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { + const unsigned int neg_one = (unsigned int) ((unsigned int) 0 - (unsigned int) 1), const_zero = (unsigned int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { @@ -10162,8 +10584,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { - const int neg_one = (int) -1, const_zero = (int) 0; + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { @@ -10351,8 +10773,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { - const long neg_one = (long) -1, const_zero = (long) 0; + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { @@ -10539,8 +10961,108 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { return (long) -1; } +/* FastTypeChecks */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + assert(PyExceptionClass_Check(exc_type)); + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; itp_basicsize; -#else - py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); - if (!py_basicsize) - goto bad; - basicsize = PyLong_AsSsize_t(py_basicsize); - Py_DECREF(py_basicsize); - py_basicsize = 0; - if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) - goto bad; -#endif - if (!strict && (size_t)basicsize > size) { - PyOS_snprintf(warning, sizeof(warning), - "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd", - module_name, class_name, basicsize, size); - if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; - } - else if ((size_t)basicsize != size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd", - module_name, class_name, basicsize, size); - goto bad; - } - return (PyTypeObject *)result; -bad: - Py_XDECREF(py_module); - Py_XDECREF(result); - return NULL; -} -#endif - /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -10665,7 +11104,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class if (!*t->p) return -1; if (PyObject_Hash(*t->p) == -1) - PyErr_Clear(); + return -1; ++t; } return 0; @@ -10678,46 +11117,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} +#endif #endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && #endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -10741,6 +11187,33 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { + int retval; + if (unlikely(!x)) return -1; + retval = __Pyx_PyObject_IsTrue(x); + Py_DECREF(x); + return retval; +} +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -10748,9 +11221,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -10758,32 +11231,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { @@ -10800,7 +11271,7 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else - return PyInt_AsSsize_t(x); + return PyInt_AsSsize_t(b); } #endif if (likely(PyLong_CheckExact(b))) { @@ -10854,6 +11325,9 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_DECREF(x); return ival; } +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { + return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); +} static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } diff --git a/lib/utils/logging.py b/lib/utils/logging.py index 518426c2..d33a08e3 100644 --- a/lib/utils/logging.py +++ b/lib/utils/logging.py @@ -14,7 +14,6 @@ ############################################################################## """Utilities for logging.""" - from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/lib/utils/training_stats.py b/lib/utils/training_stats.py index 8cae8a18..4f68cbe8 100644 --- a/lib/utils/training_stats.py +++ b/lib/utils/training_stats.py @@ -22,6 +22,7 @@ from __future__ import print_function from __future__ import unicode_literals +import pdb from collections import defaultdict, OrderedDict import datetime import numpy as np @@ -83,7 +84,7 @@ def UpdateIterStats(self, model_out, inner_iter=None): assert loss.shape[0] == cfg.NUM_GPUS loss = loss.mean(dim=0, keepdim=True) total_loss += loss - loss_data = loss.data[0] + loss_data = loss.item() model_out['losses'][k] = loss if cfg.FPN.FPN_ON: if k.startswith('loss_rpn_cls_'): @@ -93,14 +94,14 @@ def UpdateIterStats(self, model_out, inner_iter=None): self.smoothed_losses[k].AddValue(loss_data) model_out['total_loss'] = total_loss # Add the total loss for back propagation - self.smoothed_total_loss.AddValue(total_loss.data[0]) + self.smoothed_total_loss.AddValue(total_loss.item()) if cfg.FPN.FPN_ON: self.smoothed_losses['loss_rpn_cls'].AddValue(loss_rpn_cls_data) self.smoothed_losses['loss_rpn_bbox'].AddValue(loss_rpn_bbox_data) for k, metric in model_out['metrics'].items(): metric = metric.mean(dim=0, keepdim=True) - self.smoothed_metrics[k].AddValue(metric.data[0]) + self.smoothed_metrics[k].AddValue(metric.item()) def _UpdateIterStats_inner(self, model_out, inner_iter): """Update tracked iteration statistics for the case of iter_size > 1""" @@ -125,7 +126,7 @@ def _UpdateIterStats_inner(self, model_out, inner_iter): assert loss.shape[0] == cfg.NUM_GPUS loss = loss.mean(dim=0, keepdim=True) total_loss += loss - loss_data = loss.data[0] + loss_data = loss.item() model_out['losses'][k] = loss if cfg.FPN.FPN_ON: From 9c204adceb35748da22f357ec438981385d2b63e Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Wed, 16 Jan 2019 22:35:44 +0530 Subject: [PATCH 45/52] update compilation script --- lib/make.sh | 56 ++--------------------------------- lib/modeling/model_builder.py | 3 -- lib/setup_layers.py | 4 +-- lib/utils/training_stats.py | 1 - 4 files changed, 4 insertions(+), 60 deletions(-) diff --git a/lib/make.sh b/lib/make.sh index 15ee1c38..dcae6e36 100755 --- a/lib/make.sh +++ b/lib/make.sh @@ -1,60 +1,8 @@ #!/usr/bin/env bash -# CUDA_PATH=/usr/local/cuda/ -python setup.py build_ext --inplace +python setup_bbox.py build_ext --inplace rm -rf build -# # Choose cuda arch as you need -# CUDA_ARCH="-gencode arch=compute_30,code=sm_30 \ -# -gencode arch=compute_35,code=sm_35 \ -# -gencode arch=compute_50,code=sm_50 \ -# -gencode arch=compute_52,code=sm_52 \ -# -gencode arch=compute_60,code=sm_60 \ -# -gencode arch=compute_61,code=sm_61 " -# # -gencode arch=compute_70,code=sm_70 " +python setup_layers.py build develop -# # compile NMS -# cd model/nms/src -# echo "Compiling nms kernels by nvcc..." -# nvcc -c -o nms_cuda_kernel.cu.o nms_cuda_kernel.cu \ -# -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH - -# cd ../ -# python build.py - -# # compile roi_pooling -# cd ../../ -# cd model/roi_pooling/src -# echo "Compiling roi pooling kernels by nvcc..." -# nvcc -c -o roi_pooling.cu.o roi_pooling_kernel.cu \ -# -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH -# cd ../ -# python build.py - -# # # compile roi_align -# # cd ../../ -# # cd model/roi_align/src -# # echo "Compiling roi align kernels by nvcc..." -# # nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu \ -# # -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH -# # cd ../ -# # python build.py - -# # compile roi_crop -# cd ../../ -# cd model/roi_crop/src -# echo "Compiling roi crop kernels by nvcc..." -# nvcc -c -o roi_crop_cuda_kernel.cu.o roi_crop_cuda_kernel.cu \ -# -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH -# cd ../ -# python build.py - -# # compile roi_align (based on Caffe2's implementation) -# cd ../../ -# cd modeling/roi_xfrom/roi_align/src -# echo "Compiling roi align kernels by nvcc..." -# nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu \ -# -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH -# cd ../ -# python build.py diff --git a/lib/modeling/model_builder.py b/lib/modeling/model_builder.py index a2578bca..f1f5c023 100644 --- a/lib/modeling/model_builder.py +++ b/lib/modeling/model_builder.py @@ -8,9 +8,6 @@ from torch.autograd import Variable from core.config import cfg -# from model.roi_pooling.functions.roi_pool import RoIPoolFunction -# from model.roi_crop.functions.roi_crop import RoICropFunction -# from modeling.roi_xfrom.roi_align.functions.roi_align import RoIAlignFunction from model.roi_layers import ROIPool, ROIAlign import modeling.rpn_heads as rpn_heads import modeling.fast_rcnn_heads as fast_rcnn_heads diff --git a/lib/setup_layers.py b/lib/setup_layers.py index 7e7e2001..32f029a4 100644 --- a/lib/setup_layers.py +++ b/lib/setup_layers.py @@ -57,9 +57,9 @@ def get_extensions(): setup( - name="faster_rcnn", + name="detectron_pytorch", version="0.1", - description="object detection in pytorch", + description="detectron in pytorch", packages=find_packages(exclude=("configs", "tests",)), # install_requires=requirements, ext_modules=get_extensions(), diff --git a/lib/utils/training_stats.py b/lib/utils/training_stats.py index 4f68cbe8..371456b7 100644 --- a/lib/utils/training_stats.py +++ b/lib/utils/training_stats.py @@ -22,7 +22,6 @@ from __future__ import print_function from __future__ import unicode_literals -import pdb from collections import defaultdict, OrderedDict import datetime import numpy as np From 3166c97a58a87ca9bd0d256154ad64fd3fb59291 Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 17 Jan 2019 12:50:10 +0530 Subject: [PATCH 46/52] fix deprecation warnings --- lib/modeling/rpn_heads.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/modeling/rpn_heads.py b/lib/modeling/rpn_heads.py index 5edcf3a7..b98333ce 100644 --- a/lib/modeling/rpn_heads.py +++ b/lib/modeling/rpn_heads.py @@ -1,3 +1,4 @@ +import torch from torch import nn from torch.nn import init import torch.nn.functional as F @@ -107,7 +108,7 @@ def forward(self, x, im_info, roidb=None): rpn_cls_logits.view(B, 2, C // 2, H, W), dim=1) rpn_cls_prob = rpn_cls_prob[:, 1].squeeze(dim=1) else: - rpn_cls_prob = F.sigmoid(rpn_cls_logits) + rpn_cls_prob = torch.sigmoid(rpn_cls_logits) rpn_rois, rpn_rois_prob = self.RPN_GenerateProposals( rpn_cls_prob, rpn_bbox_pred, im_info) @@ -150,7 +151,7 @@ def single_scale_rpn_losses( else: weight = (rpn_labels_int32 >= 0).float() loss_rpn_cls = F.binary_cross_entropy_with_logits( - rpn_cls_logits, rpn_labels_int32.float(), weight, size_average=False) + rpn_cls_logits, rpn_labels_int32.float(), weight, reduction='sum') loss_rpn_cls /= weight.sum() loss_rpn_bbox = net_utils.smooth_l1_loss( From 75793bffce8e507dc995fbe07707cd9ee924dabf Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 17 Jan 2019 14:45:31 +0530 Subject: [PATCH 47/52] fix mynn.dataparallel issue --- lib/nn/parallel/replicate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nn/parallel/replicate.py b/lib/nn/parallel/replicate.py index 673ab006..248771f2 100644 --- a/lib/nn/parallel/replicate.py +++ b/lib/nn/parallel/replicate.py @@ -14,7 +14,7 @@ def replicate(network, devices): param_copies = [param_copies[i:i + len(params)] for i in range(0, len(param_copies), len(params))] - buffers = list(network._all_buffers()) + buffers = list(network.buffers()) buffer_indices = {buf: idx for idx, buf in enumerate(buffers)} buffer_copies = comm.broadcast_coalesced(buffers, devices) From 6bf70602e0e918c13c774828e60d73e5449dc96a Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 17 Jan 2019 15:05:02 +0530 Subject: [PATCH 48/52] update README --- .gitignore | 2 +- README.md | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index ac1bfde2..9470b282 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ notebooks/*.pkl /Outputs lib/build -lib/faster_rcnn.egg-info +lib/detectron_pytorch.egg-info # ------------------------------ diff --git a/README.md b/README.md index eda4796d..47d8f01b 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ -**This code follows the implementation architecture of Detectron.** Only part of the functionality is supported. Check [this section](#supported-network-modules) for more information. +**This code follows the implementation architecture of Detectron.** Only part of the functionality is supported. Check [this section](#supported-network-modules) for more information. This code now supports **PyTorch 1.0** With this code, you can... @@ -35,7 +35,7 @@ This implementation has the following features: - **It supports multiple GPUs training**. -- **It supports three pooling methods**. Notice that only **roi align** is revised to match the implementation in Caffe2. So, use it. +- **It supports two pooling methods**. Notice that only **roi align** is revised to match the implementation in Caffe2. So, use it. - **It is memory efficient**. For data batching, there are two techiniques available to reduce memory usage: 1) *Aspect grouping*: group images with similar aspect ratio in a batch 2) *Aspect cropping*: crop images that are too long. Aspect grouping is implemented in Detectron, so it's used for default. Aspect cropping is the idea from [jwyang/faster-rcnn.pytorch](https://github.com/jwyang/faster-rcnn.pytorch), and it's not used for default. @@ -46,6 +46,8 @@ This implementation has the following features: - (2018/05/25) Support ResNeXt backbones. - (2018/05/22) Add group normalization baselines. - (2018/05/15) PyTorch0.4 is supported now ! +- (2019/08/28) Support PASCAL VOC and Custom Dataset +- (2019/01/17) **PyTorch 1.0 Supported now!** ## Getting Started Clone the repo: @@ -59,9 +61,9 @@ git clone https://github.com/roytseng-tw/mask-rcnn.pytorch.git Tested under python3. - python packages - - pytorch>=0.3.1 + - pytorch>=1.0.0 - torchvision>=0.2.0 - - cython + - cython>=0.29.2 - matplotlib - numpy - scipy @@ -82,9 +84,7 @@ cd lib # please change to this directory sh make.sh ``` -If your are using Volta GPUs, uncomment this [line](https://github.com/roytseng-tw/mask-rcnn.pytorch/tree/master/lib/make.sh#L15) in `lib/mask.sh` and remember to postpend a backslash at the line above. `CUDA_PATH` defaults to `/usr/loca/cuda`. If you want to use a CUDA library on different path, change this [line](https://github.com/roytseng-tw/mask-rcnn.pytorch/tree/master/lib/make.sh#L3) accordingly. - -It will compile all the modules you need, including NMS, ROI_Pooing, ROI_Crop and ROI_Align. (Actually gpu nms is never used ...) +It will compile all the modules you need, including NMS, ROI_Pooing and ROI_Align. (Actually gpu nms is never used ...) Note that, If you use `CUDA_VISIBLE_DEVICES` to set gpus, **make sure at least one gpu is visible when compile the code.** From 6a37ce5ff2b5f5f5898269905584f4d2b162fe03 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Thu, 17 Jan 2019 15:25:15 +0530 Subject: [PATCH 49/52] minor bugfix --- lib/modeling/model_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modeling/model_builder.py b/lib/modeling/model_builder.py index f1f5c023..e8c1279f 100644 --- a/lib/modeling/model_builder.py +++ b/lib/modeling/model_builder.py @@ -276,7 +276,7 @@ def roi_feature_transform(self, blobs_in, rpn_ret, blob_rois='rois', method='RoI # Warning!: Not check if implementation matches Detectron xform_out = ROIPool((resolution, resolution), sc)(bl_in, rois) elif method == 'RoIAlign': - xform_out = RoIAlignFunction( + xform_out = ROIAlign( (resolution, resolution), sc, sampling_ratio)(bl_in, rois) bl_out_list.append(xform_out) From 842183b0125d73bb52ddc76ef1089a12cd27673d Mon Sep 17 00:00:00 2001 From: adityaarun1 Date: Thu, 30 May 2019 12:16:22 +0530 Subject: [PATCH 50/52] modifide code base for torchvision 0.3 --- lib/make.sh | 4 +- lib/model/__init__.py | 0 lib/model/csrc/ROIAlign.h | 46 --- lib/model/csrc/ROIPool.h | 48 --- lib/model/csrc/cpu/ROIAlign_cpu.cpp | 257 ------------- lib/model/csrc/cpu/nms_cpu.cpp | 75 ---- lib/model/csrc/cpu/vision.h | 16 - lib/model/csrc/cuda/ROIAlign_cuda.cu | 346 ------------------ lib/model/csrc/cuda/ROIPool_cuda.cu | 202 ---------- lib/model/csrc/cuda/nms.cu | 131 ------- lib/model/csrc/cuda/vision.h | 48 --- lib/model/csrc/nms.h | 28 -- lib/model/csrc/vision.cpp | 13 - lib/model/roi_layers/__init__.py | 9 - lib/model/roi_layers/nms.py | 8 - lib/model/roi_layers/roi_align.py | 67 ---- lib/model/roi_layers/roi_pool.py | 62 ---- lib/model/utils/.gitignore | 3 - lib/model/utils/__init__.py | 0 lib/modeling/model_builder.py | 10 +- lib/modeling/roi_xfrom/__init__.py | 0 lib/modeling/roi_xfrom/roi_align/__init__.py | 0 .../roi_xfrom/roi_align/_ext/__init__.py | 0 .../roi_align/_ext/roi_align/__init__.py | 15 - lib/modeling/roi_xfrom/roi_align/build.py | 36 -- .../roi_xfrom/roi_align/functions/__init__.py | 0 .../roi_align/functions/roi_align.py | 48 --- lib/modeling/roi_xfrom/roi_align/make.sh | 10 - .../roi_xfrom/roi_align/modules/__init__.py | 0 .../roi_xfrom/roi_align/modules/roi_align.py | 45 --- .../roi_xfrom/roi_align/src/roi_align_cuda.c | 76 ---- .../roi_xfrom/roi_align/src/roi_align_cuda.h | 5 - .../roi_align/src/roi_align_kernel.cu | 295 --------------- .../roi_align/src/roi_align_kernel.h | 34 -- lib/{setup_bbox.py => setup.py} | 0 lib/setup_layers.py | 67 ---- lib/{model => }/utils/net_utils.py | 0 37 files changed, 6 insertions(+), 1998 deletions(-) delete mode 100644 lib/model/__init__.py delete mode 100644 lib/model/csrc/ROIAlign.h delete mode 100644 lib/model/csrc/ROIPool.h delete mode 100644 lib/model/csrc/cpu/ROIAlign_cpu.cpp delete mode 100644 lib/model/csrc/cpu/nms_cpu.cpp delete mode 100644 lib/model/csrc/cpu/vision.h delete mode 100644 lib/model/csrc/cuda/ROIAlign_cuda.cu delete mode 100644 lib/model/csrc/cuda/ROIPool_cuda.cu delete mode 100644 lib/model/csrc/cuda/nms.cu delete mode 100644 lib/model/csrc/cuda/vision.h delete mode 100644 lib/model/csrc/nms.h delete mode 100644 lib/model/csrc/vision.cpp delete mode 100644 lib/model/roi_layers/__init__.py delete mode 100644 lib/model/roi_layers/nms.py delete mode 100644 lib/model/roi_layers/roi_align.py delete mode 100644 lib/model/roi_layers/roi_pool.py delete mode 100644 lib/model/utils/.gitignore delete mode 100644 lib/model/utils/__init__.py delete mode 100644 lib/modeling/roi_xfrom/__init__.py delete mode 100644 lib/modeling/roi_xfrom/roi_align/__init__.py delete mode 100644 lib/modeling/roi_xfrom/roi_align/_ext/__init__.py delete mode 100644 lib/modeling/roi_xfrom/roi_align/_ext/roi_align/__init__.py delete mode 100644 lib/modeling/roi_xfrom/roi_align/build.py delete mode 100644 lib/modeling/roi_xfrom/roi_align/functions/__init__.py delete mode 100644 lib/modeling/roi_xfrom/roi_align/functions/roi_align.py delete mode 100644 lib/modeling/roi_xfrom/roi_align/make.sh delete mode 100644 lib/modeling/roi_xfrom/roi_align/modules/__init__.py delete mode 100644 lib/modeling/roi_xfrom/roi_align/modules/roi_align.py delete mode 100644 lib/modeling/roi_xfrom/roi_align/src/roi_align_cuda.c delete mode 100644 lib/modeling/roi_xfrom/roi_align/src/roi_align_cuda.h delete mode 100644 lib/modeling/roi_xfrom/roi_align/src/roi_align_kernel.cu delete mode 100644 lib/modeling/roi_xfrom/roi_align/src/roi_align_kernel.h rename lib/{setup_bbox.py => setup.py} (100%) delete mode 100644 lib/setup_layers.py rename lib/{model => }/utils/net_utils.py (100%) diff --git a/lib/make.sh b/lib/make.sh index dcae6e36..826d5972 100755 --- a/lib/make.sh +++ b/lib/make.sh @@ -1,8 +1,6 @@ #!/usr/bin/env bash -python setup_bbox.py build_ext --inplace +python setup.py build_ext --inplace rm -rf build -python setup_layers.py build develop - diff --git a/lib/model/__init__.py b/lib/model/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/model/csrc/ROIAlign.h b/lib/model/csrc/ROIAlign.h deleted file mode 100644 index 3907deab..00000000 --- a/lib/model/csrc/ROIAlign.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#pragma once - -#include "cpu/vision.h" - -#ifdef WITH_CUDA -#include "cuda/vision.h" -#endif - -// Interface for Python -at::Tensor ROIAlign_forward(const at::Tensor& input, - const at::Tensor& rois, - const float spatial_scale, - const int pooled_height, - const int pooled_width, - const int sampling_ratio) { - if (input.type().is_cuda()) { -#ifdef WITH_CUDA - return ROIAlign_forward_cuda(input, rois, spatial_scale, pooled_height, pooled_width, sampling_ratio); -#else - AT_ERROR("Not compiled with GPU support"); -#endif - } - return ROIAlign_forward_cpu(input, rois, spatial_scale, pooled_height, pooled_width, sampling_ratio); -} - -at::Tensor ROIAlign_backward(const at::Tensor& grad, - const at::Tensor& rois, - const float spatial_scale, - const int pooled_height, - const int pooled_width, - const int batch_size, - const int channels, - const int height, - const int width, - const int sampling_ratio) { - if (grad.type().is_cuda()) { -#ifdef WITH_CUDA - return ROIAlign_backward_cuda(grad, rois, spatial_scale, pooled_height, pooled_width, batch_size, channels, height, width, sampling_ratio); -#else - AT_ERROR("Not compiled with GPU support"); -#endif - } - AT_ERROR("Not implemented on the CPU"); -} - diff --git a/lib/model/csrc/ROIPool.h b/lib/model/csrc/ROIPool.h deleted file mode 100644 index 200fd739..00000000 --- a/lib/model/csrc/ROIPool.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#pragma once - -#include "cpu/vision.h" - -#ifdef WITH_CUDA -#include "cuda/vision.h" -#endif - - -std::tuple ROIPool_forward(const at::Tensor& input, - const at::Tensor& rois, - const float spatial_scale, - const int pooled_height, - const int pooled_width) { - if (input.type().is_cuda()) { -#ifdef WITH_CUDA - return ROIPool_forward_cuda(input, rois, spatial_scale, pooled_height, pooled_width); -#else - AT_ERROR("Not compiled with GPU support"); -#endif - } - AT_ERROR("Not implemented on the CPU"); -} - -at::Tensor ROIPool_backward(const at::Tensor& grad, - const at::Tensor& input, - const at::Tensor& rois, - const at::Tensor& argmax, - const float spatial_scale, - const int pooled_height, - const int pooled_width, - const int batch_size, - const int channels, - const int height, - const int width) { - if (grad.type().is_cuda()) { -#ifdef WITH_CUDA - return ROIPool_backward_cuda(grad, input, rois, argmax, spatial_scale, pooled_height, pooled_width, batch_size, channels, height, width); -#else - AT_ERROR("Not compiled with GPU support"); -#endif - } - AT_ERROR("Not implemented on the CPU"); -} - - - diff --git a/lib/model/csrc/cpu/ROIAlign_cpu.cpp b/lib/model/csrc/cpu/ROIAlign_cpu.cpp deleted file mode 100644 index d35aedf2..00000000 --- a/lib/model/csrc/cpu/ROIAlign_cpu.cpp +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#include "cpu/vision.h" - -// implementation taken from Caffe2 -template -struct PreCalc { - int pos1; - int pos2; - int pos3; - int pos4; - T w1; - T w2; - T w3; - T w4; -}; - -template -void pre_calc_for_bilinear_interpolate( - const int height, - const int width, - const int pooled_height, - const int pooled_width, - const int iy_upper, - const int ix_upper, - T roi_start_h, - T roi_start_w, - T bin_size_h, - T bin_size_w, - int roi_bin_grid_h, - int roi_bin_grid_w, - std::vector>& pre_calc) { - int pre_calc_index = 0; - for (int ph = 0; ph < pooled_height; ph++) { - for (int pw = 0; pw < pooled_width; pw++) { - for (int iy = 0; iy < iy_upper; iy++) { - const T yy = roi_start_h + ph * bin_size_h + - static_cast(iy + .5f) * bin_size_h / - static_cast(roi_bin_grid_h); // e.g., 0.5, 1.5 - for (int ix = 0; ix < ix_upper; ix++) { - const T xx = roi_start_w + pw * bin_size_w + - static_cast(ix + .5f) * bin_size_w / - static_cast(roi_bin_grid_w); - - T x = xx; - T y = yy; - // deal with: inverse elements are out of feature map boundary - if (y < -1.0 || y > height || x < -1.0 || x > width) { - // empty - PreCalc pc; - pc.pos1 = 0; - pc.pos2 = 0; - pc.pos3 = 0; - pc.pos4 = 0; - pc.w1 = 0; - pc.w2 = 0; - pc.w3 = 0; - pc.w4 = 0; - pre_calc[pre_calc_index] = pc; - pre_calc_index += 1; - continue; - } - - if (y <= 0) { - y = 0; - } - if (x <= 0) { - x = 0; - } - - int y_low = (int)y; - int x_low = (int)x; - int y_high; - int x_high; - - if (y_low >= height - 1) { - y_high = y_low = height - 1; - y = (T)y_low; - } else { - y_high = y_low + 1; - } - - if (x_low >= width - 1) { - x_high = x_low = width - 1; - x = (T)x_low; - } else { - x_high = x_low + 1; - } - - T ly = y - y_low; - T lx = x - x_low; - T hy = 1. - ly, hx = 1. - lx; - T w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; - - // save weights and indeces - PreCalc pc; - pc.pos1 = y_low * width + x_low; - pc.pos2 = y_low * width + x_high; - pc.pos3 = y_high * width + x_low; - pc.pos4 = y_high * width + x_high; - pc.w1 = w1; - pc.w2 = w2; - pc.w3 = w3; - pc.w4 = w4; - pre_calc[pre_calc_index] = pc; - - pre_calc_index += 1; - } - } - } - } -} - -template -void ROIAlignForward_cpu_kernel( - const int nthreads, - const T* bottom_data, - const T& spatial_scale, - const int channels, - const int height, - const int width, - const int pooled_height, - const int pooled_width, - const int sampling_ratio, - const T* bottom_rois, - //int roi_cols, - T* top_data) { - //AT_ASSERT(roi_cols == 4 || roi_cols == 5); - int roi_cols = 5; - - int n_rois = nthreads / channels / pooled_width / pooled_height; - // (n, c, ph, pw) is an element in the pooled output - // can be parallelized using omp - // #pragma omp parallel for num_threads(32) - for (int n = 0; n < n_rois; n++) { - int index_n = n * channels * pooled_width * pooled_height; - - // roi could have 4 or 5 columns - const T* offset_bottom_rois = bottom_rois + n * roi_cols; - int roi_batch_ind = 0; - if (roi_cols == 5) { - roi_batch_ind = offset_bottom_rois[0]; - offset_bottom_rois++; - } - - // Do not using rounding; this implementation detail is critical - T roi_start_w = offset_bottom_rois[0] * spatial_scale; - T roi_start_h = offset_bottom_rois[1] * spatial_scale; - T roi_end_w = offset_bottom_rois[2] * spatial_scale; - T roi_end_h = offset_bottom_rois[3] * spatial_scale; - // T roi_start_w = round(offset_bottom_rois[0] * spatial_scale); - // T roi_start_h = round(offset_bottom_rois[1] * spatial_scale); - // T roi_end_w = round(offset_bottom_rois[2] * spatial_scale); - // T roi_end_h = round(offset_bottom_rois[3] * spatial_scale); - - // Force malformed ROIs to be 1x1 - T roi_width = std::max(roi_end_w - roi_start_w, (T)1.); - T roi_height = std::max(roi_end_h - roi_start_h, (T)1.); - T bin_size_h = static_cast(roi_height) / static_cast(pooled_height); - T bin_size_w = static_cast(roi_width) / static_cast(pooled_width); - - // We use roi_bin_grid to sample the grid and mimic integral - int roi_bin_grid_h = (sampling_ratio > 0) - ? sampling_ratio - : ceil(roi_height / pooled_height); // e.g., = 2 - int roi_bin_grid_w = - (sampling_ratio > 0) ? sampling_ratio : ceil(roi_width / pooled_width); - - // We do average (integral) pooling inside a bin - const T count = roi_bin_grid_h * roi_bin_grid_w; // e.g. = 4 - - // we want to precalculate indeces and weights shared by all chanels, - // this is the key point of optimiation - std::vector> pre_calc( - roi_bin_grid_h * roi_bin_grid_w * pooled_width * pooled_height); - pre_calc_for_bilinear_interpolate( - height, - width, - pooled_height, - pooled_width, - roi_bin_grid_h, - roi_bin_grid_w, - roi_start_h, - roi_start_w, - bin_size_h, - bin_size_w, - roi_bin_grid_h, - roi_bin_grid_w, - pre_calc); - - for (int c = 0; c < channels; c++) { - int index_n_c = index_n + c * pooled_width * pooled_height; - const T* offset_bottom_data = - bottom_data + (roi_batch_ind * channels + c) * height * width; - int pre_calc_index = 0; - - for (int ph = 0; ph < pooled_height; ph++) { - for (int pw = 0; pw < pooled_width; pw++) { - int index = index_n_c + ph * pooled_width + pw; - - T output_val = 0.; - for (int iy = 0; iy < roi_bin_grid_h; iy++) { - for (int ix = 0; ix < roi_bin_grid_w; ix++) { - PreCalc pc = pre_calc[pre_calc_index]; - output_val += pc.w1 * offset_bottom_data[pc.pos1] + - pc.w2 * offset_bottom_data[pc.pos2] + - pc.w3 * offset_bottom_data[pc.pos3] + - pc.w4 * offset_bottom_data[pc.pos4]; - - pre_calc_index += 1; - } - } - output_val /= count; - - top_data[index] = output_val; - } // for pw - } // for ph - } // for c - } // for n -} - -at::Tensor ROIAlign_forward_cpu(const at::Tensor& input, - const at::Tensor& rois, - const float spatial_scale, - const int pooled_height, - const int pooled_width, - const int sampling_ratio) { - AT_ASSERTM(!input.type().is_cuda(), "input must be a CPU tensor"); - AT_ASSERTM(!rois.type().is_cuda(), "rois must be a CPU tensor"); - - auto num_rois = rois.size(0); - auto channels = input.size(1); - auto height = input.size(2); - auto width = input.size(3); - - auto output = at::empty({num_rois, channels, pooled_height, pooled_width}, input.options()); - auto output_size = num_rois * pooled_height * pooled_width * channels; - - if (output.numel() == 0) { - return output; - } - - AT_DISPATCH_FLOATING_TYPES(input.type(), "ROIAlign_forward", [&] { - ROIAlignForward_cpu_kernel( - output_size, - input.data(), - spatial_scale, - channels, - height, - width, - pooled_height, - pooled_width, - sampling_ratio, - rois.data(), - output.data()); - }); - return output; -} diff --git a/lib/model/csrc/cpu/nms_cpu.cpp b/lib/model/csrc/cpu/nms_cpu.cpp deleted file mode 100644 index 1153dea0..00000000 --- a/lib/model/csrc/cpu/nms_cpu.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#include "cpu/vision.h" - - -template -at::Tensor nms_cpu_kernel(const at::Tensor& dets, - const at::Tensor& scores, - const float threshold) { - AT_ASSERTM(!dets.type().is_cuda(), "dets must be a CPU tensor"); - AT_ASSERTM(!scores.type().is_cuda(), "scores must be a CPU tensor"); - AT_ASSERTM(dets.type() == scores.type(), "dets should have the same type as scores"); - - if (dets.numel() == 0) { - return at::empty({0}, dets.options().dtype(at::kLong).device(at::kCPU)); - } - - auto x1_t = dets.select(1, 0).contiguous(); - auto y1_t = dets.select(1, 1).contiguous(); - auto x2_t = dets.select(1, 2).contiguous(); - auto y2_t = dets.select(1, 3).contiguous(); - - at::Tensor areas_t = (x2_t - x1_t + 1) * (y2_t - y1_t + 1); - - auto order_t = std::get<1>(scores.sort(0, /* descending=*/true)); - - auto ndets = dets.size(0); - at::Tensor suppressed_t = at::zeros({ndets}, dets.options().dtype(at::kByte).device(at::kCPU)); - - auto suppressed = suppressed_t.data(); - auto order = order_t.data(); - auto x1 = x1_t.data(); - auto y1 = y1_t.data(); - auto x2 = x2_t.data(); - auto y2 = y2_t.data(); - auto areas = areas_t.data(); - - for (int64_t _i = 0; _i < ndets; _i++) { - auto i = order[_i]; - if (suppressed[i] == 1) - continue; - auto ix1 = x1[i]; - auto iy1 = y1[i]; - auto ix2 = x2[i]; - auto iy2 = y2[i]; - auto iarea = areas[i]; - - for (int64_t _j = _i + 1; _j < ndets; _j++) { - auto j = order[_j]; - if (suppressed[j] == 1) - continue; - auto xx1 = std::max(ix1, x1[j]); - auto yy1 = std::max(iy1, y1[j]); - auto xx2 = std::min(ix2, x2[j]); - auto yy2 = std::min(iy2, y2[j]); - - auto w = std::max(static_cast(0), xx2 - xx1 + 1); - auto h = std::max(static_cast(0), yy2 - yy1 + 1); - auto inter = w * h; - auto ovr = inter / (iarea + areas[j] - inter); - if (ovr >= threshold) - suppressed[j] = 1; - } - } - return at::nonzero(suppressed_t == 0).squeeze(1); -} - -at::Tensor nms_cpu(const at::Tensor& dets, - const at::Tensor& scores, - const float threshold) { - at::Tensor result; - AT_DISPATCH_FLOATING_TYPES(dets.type(), "nms", [&] { - result = nms_cpu_kernel(dets, scores, threshold); - }); - return result; -} diff --git a/lib/model/csrc/cpu/vision.h b/lib/model/csrc/cpu/vision.h deleted file mode 100644 index 92611253..00000000 --- a/lib/model/csrc/cpu/vision.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#pragma once -#include - - -at::Tensor ROIAlign_forward_cpu(const at::Tensor& input, - const at::Tensor& rois, - const float spatial_scale, - const int pooled_height, - const int pooled_width, - const int sampling_ratio); - - -at::Tensor nms_cpu(const at::Tensor& dets, - const at::Tensor& scores, - const float threshold); diff --git a/lib/model/csrc/cuda/ROIAlign_cuda.cu b/lib/model/csrc/cuda/ROIAlign_cuda.cu deleted file mode 100644 index 5fe97ca9..00000000 --- a/lib/model/csrc/cuda/ROIAlign_cuda.cu +++ /dev/null @@ -1,346 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#include -#include - -#include -#include -#include - -// TODO make it in a common file -#define CUDA_1D_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ - i += blockDim.x * gridDim.x) - - -template -__device__ T bilinear_interpolate(const T* bottom_data, - const int height, const int width, - T y, T x, - const int index /* index for debug only*/) { - - // deal with cases that inverse elements are out of feature map boundary - if (y < -1.0 || y > height || x < -1.0 || x > width) { - //empty - return 0; - } - - if (y <= 0) y = 0; - if (x <= 0) x = 0; - - int y_low = (int) y; - int x_low = (int) x; - int y_high; - int x_high; - - if (y_low >= height - 1) { - y_high = y_low = height - 1; - y = (T) y_low; - } else { - y_high = y_low + 1; - } - - if (x_low >= width - 1) { - x_high = x_low = width - 1; - x = (T) x_low; - } else { - x_high = x_low + 1; - } - - T ly = y - y_low; - T lx = x - x_low; - T hy = 1. - ly, hx = 1. - lx; - // do bilinear interpolation - T v1 = bottom_data[y_low * width + x_low]; - T v2 = bottom_data[y_low * width + x_high]; - T v3 = bottom_data[y_high * width + x_low]; - T v4 = bottom_data[y_high * width + x_high]; - T w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; - - T val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); - - return val; -} - -template -__global__ void RoIAlignForward(const int nthreads, const T* bottom_data, - const T spatial_scale, const int channels, - const int height, const int width, - const int pooled_height, const int pooled_width, - const int sampling_ratio, - const T* bottom_rois, T* top_data) { - CUDA_1D_KERNEL_LOOP(index, nthreads) { - // (n, c, ph, pw) is an element in the pooled output - int pw = index % pooled_width; - int ph = (index / pooled_width) % pooled_height; - int c = (index / pooled_width / pooled_height) % channels; - int n = index / pooled_width / pooled_height / channels; - - const T* offset_bottom_rois = bottom_rois + n * 5; - int roi_batch_ind = offset_bottom_rois[0]; - - // Do not using rounding; this implementation detail is critical - T roi_start_w = offset_bottom_rois[1] * spatial_scale; - T roi_start_h = offset_bottom_rois[2] * spatial_scale; - T roi_end_w = offset_bottom_rois[3] * spatial_scale; - T roi_end_h = offset_bottom_rois[4] * spatial_scale; - // T roi_start_w = round(offset_bottom_rois[1] * spatial_scale); - // T roi_start_h = round(offset_bottom_rois[2] * spatial_scale); - // T roi_end_w = round(offset_bottom_rois[3] * spatial_scale); - // T roi_end_h = round(offset_bottom_rois[4] * spatial_scale); - - // Force malformed ROIs to be 1x1 - T roi_width = max(roi_end_w - roi_start_w, (T)1.); - T roi_height = max(roi_end_h - roi_start_h, (T)1.); - T bin_size_h = static_cast(roi_height) / static_cast(pooled_height); - T bin_size_w = static_cast(roi_width) / static_cast(pooled_width); - - const T* offset_bottom_data = bottom_data + (roi_batch_ind * channels + c) * height * width; - - // We use roi_bin_grid to sample the grid and mimic integral - int roi_bin_grid_h = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_height / pooled_height); // e.g., = 2 - int roi_bin_grid_w = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_width / pooled_width); - - // We do average (integral) pooling inside a bin - const T count = roi_bin_grid_h * roi_bin_grid_w; // e.g. = 4 - - T output_val = 0.; - for (int iy = 0; iy < roi_bin_grid_h; iy ++) // e.g., iy = 0, 1 - { - const T y = roi_start_h + ph * bin_size_h + static_cast(iy + .5f) * bin_size_h / static_cast(roi_bin_grid_h); // e.g., 0.5, 1.5 - for (int ix = 0; ix < roi_bin_grid_w; ix ++) - { - const T x = roi_start_w + pw * bin_size_w + static_cast(ix + .5f) * bin_size_w / static_cast(roi_bin_grid_w); - - T val = bilinear_interpolate(offset_bottom_data, height, width, y, x, index); - output_val += val; - } - } - output_val /= count; - - top_data[index] = output_val; - } -} - - -template -__device__ void bilinear_interpolate_gradient( - const int height, const int width, - T y, T x, - T & w1, T & w2, T & w3, T & w4, - int & x_low, int & x_high, int & y_low, int & y_high, - const int index /* index for debug only*/) { - - // deal with cases that inverse elements are out of feature map boundary - if (y < -1.0 || y > height || x < -1.0 || x > width) { - //empty - w1 = w2 = w3 = w4 = 0.; - x_low = x_high = y_low = y_high = -1; - return; - } - - if (y <= 0) y = 0; - if (x <= 0) x = 0; - - y_low = (int) y; - x_low = (int) x; - - if (y_low >= height - 1) { - y_high = y_low = height - 1; - y = (T) y_low; - } else { - y_high = y_low + 1; - } - - if (x_low >= width - 1) { - x_high = x_low = width - 1; - x = (T) x_low; - } else { - x_high = x_low + 1; - } - - T ly = y - y_low; - T lx = x - x_low; - T hy = 1. - ly, hx = 1. - lx; - - // reference in forward - // T v1 = bottom_data[y_low * width + x_low]; - // T v2 = bottom_data[y_low * width + x_high]; - // T v3 = bottom_data[y_high * width + x_low]; - // T v4 = bottom_data[y_high * width + x_high]; - // T val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); - - w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; - - return; -} - -template -__global__ void RoIAlignBackwardFeature(const int nthreads, const T* top_diff, - const int num_rois, const T spatial_scale, - const int channels, const int height, const int width, - const int pooled_height, const int pooled_width, - const int sampling_ratio, - T* bottom_diff, - const T* bottom_rois) { - CUDA_1D_KERNEL_LOOP(index, nthreads) { - // (n, c, ph, pw) is an element in the pooled output - int pw = index % pooled_width; - int ph = (index / pooled_width) % pooled_height; - int c = (index / pooled_width / pooled_height) % channels; - int n = index / pooled_width / pooled_height / channels; - - const T* offset_bottom_rois = bottom_rois + n * 5; - int roi_batch_ind = offset_bottom_rois[0]; - - // Do not using rounding; this implementation detail is critical - T roi_start_w = offset_bottom_rois[1] * spatial_scale; - T roi_start_h = offset_bottom_rois[2] * spatial_scale; - T roi_end_w = offset_bottom_rois[3] * spatial_scale; - T roi_end_h = offset_bottom_rois[4] * spatial_scale; - // T roi_start_w = round(offset_bottom_rois[1] * spatial_scale); - // T roi_start_h = round(offset_bottom_rois[2] * spatial_scale); - // T roi_end_w = round(offset_bottom_rois[3] * spatial_scale); - // T roi_end_h = round(offset_bottom_rois[4] * spatial_scale); - - // Force malformed ROIs to be 1x1 - T roi_width = max(roi_end_w - roi_start_w, (T)1.); - T roi_height = max(roi_end_h - roi_start_h, (T)1.); - T bin_size_h = static_cast(roi_height) / static_cast(pooled_height); - T bin_size_w = static_cast(roi_width) / static_cast(pooled_width); - - T* offset_bottom_diff = bottom_diff + (roi_batch_ind * channels + c) * height * width; - - int top_offset = (n * channels + c) * pooled_height * pooled_width; - const T* offset_top_diff = top_diff + top_offset; - const T top_diff_this_bin = offset_top_diff[ph * pooled_width + pw]; - - // We use roi_bin_grid to sample the grid and mimic integral - int roi_bin_grid_h = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_height / pooled_height); // e.g., = 2 - int roi_bin_grid_w = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_width / pooled_width); - - // We do average (integral) pooling inside a bin - const T count = roi_bin_grid_h * roi_bin_grid_w; // e.g. = 4 - - for (int iy = 0; iy < roi_bin_grid_h; iy ++) // e.g., iy = 0, 1 - { - const T y = roi_start_h + ph * bin_size_h + static_cast(iy + .5f) * bin_size_h / static_cast(roi_bin_grid_h); // e.g., 0.5, 1.5 - for (int ix = 0; ix < roi_bin_grid_w; ix ++) - { - const T x = roi_start_w + pw * bin_size_w + static_cast(ix + .5f) * bin_size_w / static_cast(roi_bin_grid_w); - - T w1, w2, w3, w4; - int x_low, x_high, y_low, y_high; - - bilinear_interpolate_gradient(height, width, y, x, - w1, w2, w3, w4, - x_low, x_high, y_low, y_high, - index); - - T g1 = top_diff_this_bin * w1 / count; - T g2 = top_diff_this_bin * w2 / count; - T g3 = top_diff_this_bin * w3 / count; - T g4 = top_diff_this_bin * w4 / count; - - if (x_low >= 0 && x_high >= 0 && y_low >= 0 && y_high >= 0) - { - atomicAdd(offset_bottom_diff + y_low * width + x_low, static_cast(g1)); - atomicAdd(offset_bottom_diff + y_low * width + x_high, static_cast(g2)); - atomicAdd(offset_bottom_diff + y_high * width + x_low, static_cast(g3)); - atomicAdd(offset_bottom_diff + y_high * width + x_high, static_cast(g4)); - } // if - } // ix - } // iy - } // CUDA_1D_KERNEL_LOOP -} // RoIAlignBackward - - -at::Tensor ROIAlign_forward_cuda(const at::Tensor& input, - const at::Tensor& rois, - const float spatial_scale, - const int pooled_height, - const int pooled_width, - const int sampling_ratio) { - AT_ASSERTM(input.type().is_cuda(), "input must be a CUDA tensor"); - AT_ASSERTM(rois.type().is_cuda(), "rois must be a CUDA tensor"); - - auto num_rois = rois.size(0); - auto channels = input.size(1); - auto height = input.size(2); - auto width = input.size(3); - - auto output = at::empty({num_rois, channels, pooled_height, pooled_width}, input.options()); - auto output_size = num_rois * pooled_height * pooled_width * channels; - cudaStream_t stream = at::cuda::getCurrentCUDAStream(); - - dim3 grid(std::min(THCCeilDiv(output_size, 512L), 4096L)); - dim3 block(512); - - if (output.numel() == 0) { - THCudaCheck(cudaGetLastError()); - return output; - } - - AT_DISPATCH_FLOATING_TYPES(input.type(), "ROIAlign_forward", [&] { - RoIAlignForward<<>>( - output_size, - input.contiguous().data(), - spatial_scale, - channels, - height, - width, - pooled_height, - pooled_width, - sampling_ratio, - rois.contiguous().data(), - output.data()); - }); - THCudaCheck(cudaGetLastError()); - return output; -} - -// TODO remove the dependency on input and use instead its sizes -> save memory -at::Tensor ROIAlign_backward_cuda(const at::Tensor& grad, - const at::Tensor& rois, - const float spatial_scale, - const int pooled_height, - const int pooled_width, - const int batch_size, - const int channels, - const int height, - const int width, - const int sampling_ratio) { - AT_ASSERTM(grad.type().is_cuda(), "grad must be a CUDA tensor"); - AT_ASSERTM(rois.type().is_cuda(), "rois must be a CUDA tensor"); - - auto num_rois = rois.size(0); - auto grad_input = at::zeros({batch_size, channels, height, width}, grad.options()); - - cudaStream_t stream = at::cuda::getCurrentCUDAStream(); - - dim3 grid(std::min(THCCeilDiv(grad.numel(), 512L), 4096L)); - dim3 block(512); - - // handle possibly empty gradients - if (grad.numel() == 0) { - THCudaCheck(cudaGetLastError()); - return grad_input; - } - - AT_DISPATCH_FLOATING_TYPES(grad.type(), "ROIAlign_backward", [&] { - RoIAlignBackwardFeature<<>>( - grad.numel(), - grad.contiguous().data(), - num_rois, - spatial_scale, - channels, - height, - width, - pooled_height, - pooled_width, - sampling_ratio, - grad_input.data(), - rois.contiguous().data()); - }); - THCudaCheck(cudaGetLastError()); - return grad_input; -} diff --git a/lib/model/csrc/cuda/ROIPool_cuda.cu b/lib/model/csrc/cuda/ROIPool_cuda.cu deleted file mode 100644 index b826dd9b..00000000 --- a/lib/model/csrc/cuda/ROIPool_cuda.cu +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#include -#include - -#include -#include -#include - - -// TODO make it in a common file -#define CUDA_1D_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ - i += blockDim.x * gridDim.x) - - -template -__global__ void RoIPoolFForward(const int nthreads, const T* bottom_data, - const T spatial_scale, const int channels, const int height, - const int width, const int pooled_height, const int pooled_width, - const T* bottom_rois, T* top_data, int* argmax_data) { - CUDA_1D_KERNEL_LOOP(index, nthreads) { - // (n, c, ph, pw) is an element in the pooled output - int pw = index % pooled_width; - int ph = (index / pooled_width) % pooled_height; - int c = (index / pooled_width / pooled_height) % channels; - int n = index / pooled_width / pooled_height / channels; - - const T* offset_bottom_rois = bottom_rois + n * 5; - int roi_batch_ind = offset_bottom_rois[0]; - int roi_start_w = round(offset_bottom_rois[1] * spatial_scale); - int roi_start_h = round(offset_bottom_rois[2] * spatial_scale); - int roi_end_w = round(offset_bottom_rois[3] * spatial_scale); - int roi_end_h = round(offset_bottom_rois[4] * spatial_scale); - - // Force malformed ROIs to be 1x1 - int roi_width = max(roi_end_w - roi_start_w + 1, 1); - int roi_height = max(roi_end_h - roi_start_h + 1, 1); - T bin_size_h = static_cast(roi_height) - / static_cast(pooled_height); - T bin_size_w = static_cast(roi_width) - / static_cast(pooled_width); - - int hstart = static_cast(floor(static_cast(ph) - * bin_size_h)); - int wstart = static_cast(floor(static_cast(pw) - * bin_size_w)); - int hend = static_cast(ceil(static_cast(ph + 1) - * bin_size_h)); - int wend = static_cast(ceil(static_cast(pw + 1) - * bin_size_w)); - - // Add roi offsets and clip to input boundaries - hstart = min(max(hstart + roi_start_h, 0), height); - hend = min(max(hend + roi_start_h, 0), height); - wstart = min(max(wstart + roi_start_w, 0), width); - wend = min(max(wend + roi_start_w, 0), width); - bool is_empty = (hend <= hstart) || (wend <= wstart); - - // Define an empty pooling region to be zero - T maxval = is_empty ? 0 : -FLT_MAX; - // If nothing is pooled, argmax = -1 causes nothing to be backprop'd - int maxidx = -1; - const T* offset_bottom_data = - bottom_data + (roi_batch_ind * channels + c) * height * width; - for (int h = hstart; h < hend; ++h) { - for (int w = wstart; w < wend; ++w) { - int bottom_index = h * width + w; - if (offset_bottom_data[bottom_index] > maxval) { - maxval = offset_bottom_data[bottom_index]; - maxidx = bottom_index; - } - } - } - top_data[index] = maxval; - argmax_data[index] = maxidx; - } -} - -template -__global__ void RoIPoolFBackward(const int nthreads, const T* top_diff, - const int* argmax_data, const int num_rois, const T spatial_scale, - const int channels, const int height, const int width, - const int pooled_height, const int pooled_width, T* bottom_diff, - const T* bottom_rois) { - CUDA_1D_KERNEL_LOOP(index, nthreads) { - // (n, c, ph, pw) is an element in the pooled output - int pw = index % pooled_width; - int ph = (index / pooled_width) % pooled_height; - int c = (index / pooled_width / pooled_height) % channels; - int n = index / pooled_width / pooled_height / channels; - - const T* offset_bottom_rois = bottom_rois + n * 5; - int roi_batch_ind = offset_bottom_rois[0]; - int bottom_offset = (roi_batch_ind * channels + c) * height * width; - int top_offset = (n * channels + c) * pooled_height * pooled_width; - const T* offset_top_diff = top_diff + top_offset; - T* offset_bottom_diff = bottom_diff + bottom_offset; - const int* offset_argmax_data = argmax_data + top_offset; - - int argmax = offset_argmax_data[ph * pooled_width + pw]; - if (argmax != -1) { - atomicAdd( - offset_bottom_diff + argmax, - static_cast(offset_top_diff[ph * pooled_width + pw])); - - } - } -} - -std::tuple ROIPool_forward_cuda(const at::Tensor& input, - const at::Tensor& rois, - const float spatial_scale, - const int pooled_height, - const int pooled_width) { - AT_ASSERTM(input.type().is_cuda(), "input must be a CUDA tensor"); - AT_ASSERTM(rois.type().is_cuda(), "rois must be a CUDA tensor"); - - auto num_rois = rois.size(0); - auto channels = input.size(1); - auto height = input.size(2); - auto width = input.size(3); - - auto output = at::empty({num_rois, channels, pooled_height, pooled_width}, input.options()); - auto output_size = num_rois * pooled_height * pooled_width * channels; - auto argmax = at::zeros({num_rois, channels, pooled_height, pooled_width}, input.options().dtype(at::kInt)); - - cudaStream_t stream = at::cuda::getCurrentCUDAStream(); - - dim3 grid(std::min(THCCeilDiv(output_size, 512L), 4096L)); - dim3 block(512); - - if (output.numel() == 0) { - THCudaCheck(cudaGetLastError()); - return std::make_tuple(output, argmax); - } - - AT_DISPATCH_FLOATING_TYPES(input.type(), "ROIPool_forward", [&] { - RoIPoolFForward<<>>( - output_size, - input.contiguous().data(), - spatial_scale, - channels, - height, - width, - pooled_height, - pooled_width, - rois.contiguous().data(), - output.data(), - argmax.data()); - }); - THCudaCheck(cudaGetLastError()); - return std::make_tuple(output, argmax); -} - -// TODO remove the dependency on input and use instead its sizes -> save memory -at::Tensor ROIPool_backward_cuda(const at::Tensor& grad, - const at::Tensor& input, - const at::Tensor& rois, - const at::Tensor& argmax, - const float spatial_scale, - const int pooled_height, - const int pooled_width, - const int batch_size, - const int channels, - const int height, - const int width) { - AT_ASSERTM(grad.type().is_cuda(), "grad must be a CUDA tensor"); - AT_ASSERTM(rois.type().is_cuda(), "rois must be a CUDA tensor"); - // TODO add more checks - - auto num_rois = rois.size(0); - auto grad_input = at::zeros({batch_size, channels, height, width}, grad.options()); - - cudaStream_t stream = at::cuda::getCurrentCUDAStream(); - - dim3 grid(std::min(THCCeilDiv(grad.numel(), 512L), 4096L)); - dim3 block(512); - - // handle possibly empty gradients - if (grad.numel() == 0) { - THCudaCheck(cudaGetLastError()); - return grad_input; - } - - AT_DISPATCH_FLOATING_TYPES(grad.type(), "ROIPool_backward", [&] { - RoIPoolFBackward<<>>( - grad.numel(), - grad.contiguous().data(), - argmax.data(), - num_rois, - spatial_scale, - channels, - height, - width, - pooled_height, - pooled_width, - grad_input.data(), - rois.contiguous().data()); - }); - THCudaCheck(cudaGetLastError()); - return grad_input; -} diff --git a/lib/model/csrc/cuda/nms.cu b/lib/model/csrc/cuda/nms.cu deleted file mode 100644 index 833d8523..00000000 --- a/lib/model/csrc/cuda/nms.cu +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#include -#include - -#include -#include - -#include -#include - -int const threadsPerBlock = sizeof(unsigned long long) * 8; - -__device__ inline float devIoU(float const * const a, float const * const b) { - float left = max(a[0], b[0]), right = min(a[2], b[2]); - float top = max(a[1], b[1]), bottom = min(a[3], b[3]); - float width = max(right - left + 1, 0.f), height = max(bottom - top + 1, 0.f); - float interS = width * height; - float Sa = (a[2] - a[0] + 1) * (a[3] - a[1] + 1); - float Sb = (b[2] - b[0] + 1) * (b[3] - b[1] + 1); - return interS / (Sa + Sb - interS); -} - -__global__ void nms_kernel(const int n_boxes, const float nms_overlap_thresh, - const float *dev_boxes, unsigned long long *dev_mask) { - const int row_start = blockIdx.y; - const int col_start = blockIdx.x; - - // if (row_start > col_start) return; - - const int row_size = - min(n_boxes - row_start * threadsPerBlock, threadsPerBlock); - const int col_size = - min(n_boxes - col_start * threadsPerBlock, threadsPerBlock); - - __shared__ float block_boxes[threadsPerBlock * 5]; - if (threadIdx.x < col_size) { - block_boxes[threadIdx.x * 5 + 0] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 0]; - block_boxes[threadIdx.x * 5 + 1] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 1]; - block_boxes[threadIdx.x * 5 + 2] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 2]; - block_boxes[threadIdx.x * 5 + 3] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 3]; - block_boxes[threadIdx.x * 5 + 4] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 4]; - } - __syncthreads(); - - if (threadIdx.x < row_size) { - const int cur_box_idx = threadsPerBlock * row_start + threadIdx.x; - const float *cur_box = dev_boxes + cur_box_idx * 5; - int i = 0; - unsigned long long t = 0; - int start = 0; - if (row_start == col_start) { - start = threadIdx.x + 1; - } - for (i = start; i < col_size; i++) { - if (devIoU(cur_box, block_boxes + i * 5) > nms_overlap_thresh) { - t |= 1ULL << i; - } - } - const int col_blocks = THCCeilDiv(n_boxes, threadsPerBlock); - dev_mask[cur_box_idx * col_blocks + col_start] = t; - } -} - -// boxes is a N x 5 tensor -at::Tensor nms_cuda(const at::Tensor boxes, float nms_overlap_thresh) { - using scalar_t = float; - AT_ASSERTM(boxes.type().is_cuda(), "boxes must be a CUDA tensor"); - auto scores = boxes.select(1, 4); - auto order_t = std::get<1>(scores.sort(0, /* descending=*/true)); - auto boxes_sorted = boxes.index_select(0, order_t); - - int boxes_num = boxes.size(0); - - const int col_blocks = THCCeilDiv(boxes_num, threadsPerBlock); - - scalar_t* boxes_dev = boxes_sorted.data(); - - THCState *state = at::globalContext().lazyInitCUDA(); // TODO replace with getTHCState - - unsigned long long* mask_dev = NULL; - //THCudaCheck(THCudaMalloc(state, (void**) &mask_dev, - // boxes_num * col_blocks * sizeof(unsigned long long))); - - mask_dev = (unsigned long long*) THCudaMalloc(state, boxes_num * col_blocks * sizeof(unsigned long long)); - - dim3 blocks(THCCeilDiv(boxes_num, threadsPerBlock), - THCCeilDiv(boxes_num, threadsPerBlock)); - dim3 threads(threadsPerBlock); - nms_kernel<<>>(boxes_num, - nms_overlap_thresh, - boxes_dev, - mask_dev); - - std::vector mask_host(boxes_num * col_blocks); - THCudaCheck(cudaMemcpy(&mask_host[0], - mask_dev, - sizeof(unsigned long long) * boxes_num * col_blocks, - cudaMemcpyDeviceToHost)); - - std::vector remv(col_blocks); - memset(&remv[0], 0, sizeof(unsigned long long) * col_blocks); - - at::Tensor keep = at::empty({boxes_num}, boxes.options().dtype(at::kLong).device(at::kCPU)); - int64_t* keep_out = keep.data(); - - int num_to_keep = 0; - for (int i = 0; i < boxes_num; i++) { - int nblock = i / threadsPerBlock; - int inblock = i % threadsPerBlock; - - if (!(remv[nblock] & (1ULL << inblock))) { - keep_out[num_to_keep++] = i; - unsigned long long *p = &mask_host[0] + i * col_blocks; - for (int j = nblock; j < col_blocks; j++) { - remv[j] |= p[j]; - } - } - } - - THCudaFree(state, mask_dev); - // TODO improve this part - return std::get<0>(order_t.index({ - keep.narrow(/*dim=*/0, /*start=*/0, /*length=*/num_to_keep).to( - order_t.device(), keep.scalar_type()) - }).sort(0, false)); -} diff --git a/lib/model/csrc/cuda/vision.h b/lib/model/csrc/cuda/vision.h deleted file mode 100644 index 977cef7b..00000000 --- a/lib/model/csrc/cuda/vision.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#pragma once -#include - - -at::Tensor ROIAlign_forward_cuda(const at::Tensor& input, - const at::Tensor& rois, - const float spatial_scale, - const int pooled_height, - const int pooled_width, - const int sampling_ratio); - -at::Tensor ROIAlign_backward_cuda(const at::Tensor& grad, - const at::Tensor& rois, - const float spatial_scale, - const int pooled_height, - const int pooled_width, - const int batch_size, - const int channels, - const int height, - const int width, - const int sampling_ratio); - - -std::tuple ROIPool_forward_cuda(const at::Tensor& input, - const at::Tensor& rois, - const float spatial_scale, - const int pooled_height, - const int pooled_width); - -at::Tensor ROIPool_backward_cuda(const at::Tensor& grad, - const at::Tensor& input, - const at::Tensor& rois, - const at::Tensor& argmax, - const float spatial_scale, - const int pooled_height, - const int pooled_width, - const int batch_size, - const int channels, - const int height, - const int width); - -at::Tensor nms_cuda(const at::Tensor boxes, float nms_overlap_thresh); - - -at::Tensor compute_flow_cuda(const at::Tensor& boxes, - const int height, - const int width); diff --git a/lib/model/csrc/nms.h b/lib/model/csrc/nms.h deleted file mode 100644 index 312fed4a..00000000 --- a/lib/model/csrc/nms.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#pragma once -#include "cpu/vision.h" - -#ifdef WITH_CUDA -#include "cuda/vision.h" -#endif - - -at::Tensor nms(const at::Tensor& dets, - const at::Tensor& scores, - const float threshold) { - - if (dets.type().is_cuda()) { -#ifdef WITH_CUDA - // TODO raise error if not compiled with CUDA - if (dets.numel() == 0) - return at::empty({0}, dets.options().dtype(at::kLong).device(at::kCPU)); - auto b = at::cat({dets, scores.unsqueeze(1)}, 1); - return nms_cuda(b, threshold); -#else - AT_ERROR("Not compiled with GPU support"); -#endif - } - - at::Tensor result = nms_cpu(dets, scores, threshold); - return result; -} diff --git a/lib/model/csrc/vision.cpp b/lib/model/csrc/vision.cpp deleted file mode 100644 index ff002584..00000000 --- a/lib/model/csrc/vision.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#include "nms.h" -#include "ROIAlign.h" -#include "ROIPool.h" - - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("nms", &nms, "non-maximum suppression"); - m.def("roi_align_forward", &ROIAlign_forward, "ROIAlign_forward"); - m.def("roi_align_backward", &ROIAlign_backward, "ROIAlign_backward"); - m.def("roi_pool_forward", &ROIPool_forward, "ROIPool_forward"); - m.def("roi_pool_backward", &ROIPool_backward, "ROIPool_backward"); -} diff --git a/lib/model/roi_layers/__init__.py b/lib/model/roi_layers/__init__.py deleted file mode 100644 index dbd59b50..00000000 --- a/lib/model/roi_layers/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -import torch -from .nms import nms -from .roi_align import ROIAlign -from .roi_align import roi_align -from .roi_pool import ROIPool -from .roi_pool import roi_pool - -__all__ = ["nms", "roi_align", "ROIAlign", "roi_pool", "ROIPool"] diff --git a/lib/model/roi_layers/nms.py b/lib/model/roi_layers/nms.py deleted file mode 100644 index ffe4cc12..00000000 --- a/lib/model/roi_layers/nms.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -# from ._utils import _C -from model import _C - -nms = _C.nms -# nms.__doc__ = """ -# This function performs Non-maximum suppresion""" - diff --git a/lib/model/roi_layers/roi_align.py b/lib/model/roi_layers/roi_align.py deleted file mode 100644 index cd03715e..00000000 --- a/lib/model/roi_layers/roi_align.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -import torch -from torch import nn -from torch.autograd import Function -from torch.autograd.function import once_differentiable -from torch.nn.modules.utils import _pair - -from model import _C - - -class _ROIAlign(Function): - @staticmethod - def forward(ctx, input, roi, output_size, spatial_scale, sampling_ratio): - ctx.save_for_backward(roi) - ctx.output_size = _pair(output_size) - ctx.spatial_scale = spatial_scale - ctx.sampling_ratio = sampling_ratio - ctx.input_shape = input.size() - output = _C.roi_align_forward(input, roi, spatial_scale, - output_size[0], output_size[1], - sampling_ratio) - return output - - @staticmethod - @once_differentiable - def backward(ctx, grad_output): - rois, = ctx.saved_tensors - output_size = ctx.output_size - spatial_scale = ctx.spatial_scale - sampling_ratio = ctx.sampling_ratio - bs, ch, h, w = ctx.input_shape - grad_input = _C.roi_align_backward( - grad_output, - rois, - spatial_scale, - output_size[0], - output_size[1], - bs, - ch, - h, - w, - sampling_ratio, - ) - return grad_input, None, None, None, None - - -roi_align = _ROIAlign.apply - - -class ROIAlign(nn.Module): - def __init__(self, output_size, spatial_scale, sampling_ratio): - super(ROIAlign, self).__init__() - self.output_size = output_size - self.spatial_scale = spatial_scale - self.sampling_ratio = sampling_ratio - - def forward(self, input, rois): - return roi_align(input, rois, self.output_size, self.spatial_scale, - self.sampling_ratio) - - def __repr__(self): - tmpstr = self.__class__.__name__ + "(" - tmpstr += "output_size=" + str(self.output_size) - tmpstr += ", spatial_scale=" + str(self.spatial_scale) - tmpstr += ", sampling_ratio=" + str(self.sampling_ratio) - tmpstr += ")" - return tmpstr diff --git a/lib/model/roi_layers/roi_pool.py b/lib/model/roi_layers/roi_pool.py deleted file mode 100644 index 3fac3443..00000000 --- a/lib/model/roi_layers/roi_pool.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -import torch -from torch import nn -from torch.autograd import Function -from torch.autograd.function import once_differentiable -from torch.nn.modules.utils import _pair - -from model import _C - - -class _ROIPool(Function): - @staticmethod - def forward(ctx, input, roi, output_size, spatial_scale): - ctx.output_size = _pair(output_size) - ctx.spatial_scale = spatial_scale - ctx.input_shape = input.size() - output, argmax = _C.roi_pool_forward(input, roi, spatial_scale, - output_size[0], output_size[1]) - ctx.save_for_backward(input, roi, argmax) - return output - - @staticmethod - @once_differentiable - def backward(ctx, grad_output): - input, rois, argmax = ctx.saved_tensors - output_size = ctx.output_size - spatial_scale = ctx.spatial_scale - bs, ch, h, w = ctx.input_shape - grad_input = _C.roi_pool_backward( - grad_output, - input, - rois, - argmax, - spatial_scale, - output_size[0], - output_size[1], - bs, - ch, - h, - w, - ) - return grad_input, None, None, None - - -roi_pool = _ROIPool.apply - - -class ROIPool(nn.Module): - def __init__(self, output_size, spatial_scale): - super(ROIPool, self).__init__() - self.output_size = output_size - self.spatial_scale = spatial_scale - - def forward(self, input, rois): - return roi_pool(input, rois, self.output_size, self.spatial_scale) - - def __repr__(self): - tmpstr = self.__class__.__name__ + "(" - tmpstr += "output_size=" + str(self.output_size) - tmpstr += ", spatial_scale=" + str(self.spatial_scale) - tmpstr += ")" - return tmpstr diff --git a/lib/model/utils/.gitignore b/lib/model/utils/.gitignore deleted file mode 100644 index 15a165d4..00000000 --- a/lib/model/utils/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.c -*.cpp -*.so diff --git a/lib/model/utils/__init__.py b/lib/model/utils/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/modeling/model_builder.py b/lib/modeling/model_builder.py index e8c1279f..43456adc 100644 --- a/lib/modeling/model_builder.py +++ b/lib/modeling/model_builder.py @@ -8,7 +8,7 @@ from torch.autograd import Variable from core.config import cfg -from model.roi_layers import ROIPool, ROIAlign +from torchvision.ops import RoIPool, RoIAlign import modeling.rpn_heads as rpn_heads import modeling.fast_rcnn_heads as fast_rcnn_heads import modeling.mask_rcnn_heads as mask_rcnn_heads @@ -274,9 +274,9 @@ def roi_feature_transform(self, blobs_in, rpn_ret, blob_rois='rois', method='RoI rois = Variable(torch.from_numpy(rpn_ret[bl_rois])).cuda(device_id) if method == 'RoIPoolF': # Warning!: Not check if implementation matches Detectron - xform_out = ROIPool((resolution, resolution), sc)(bl_in, rois) + xform_out = RoIPool((resolution, resolution), sc)(bl_in, rois) elif method == 'RoIAlign': - xform_out = ROIAlign( + xform_out = RoIAlign( (resolution, resolution), sc, sampling_ratio)(bl_in, rois) bl_out_list.append(xform_out) @@ -298,9 +298,9 @@ def roi_feature_transform(self, blobs_in, rpn_ret, blob_rois='rois', method='RoI device_id = blobs_in.get_device() rois = Variable(torch.from_numpy(rpn_ret[blob_rois])).cuda(device_id) if method == 'RoIPoolF': - xform_out = ROIPool((resolution, resolution), spatial_scale)(blobs_in, rois) + xform_out = RoIPool((resolution, resolution), spatial_scale)(blobs_in, rois) elif method == 'RoIAlign': - xform_out = ROIAlign( + xform_out = RoIAlign( (resolution, resolution), spatial_scale, sampling_ratio)(blobs_in, rois) return xform_out diff --git a/lib/modeling/roi_xfrom/__init__.py b/lib/modeling/roi_xfrom/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/modeling/roi_xfrom/roi_align/__init__.py b/lib/modeling/roi_xfrom/roi_align/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/modeling/roi_xfrom/roi_align/_ext/__init__.py b/lib/modeling/roi_xfrom/roi_align/_ext/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/modeling/roi_xfrom/roi_align/_ext/roi_align/__init__.py b/lib/modeling/roi_xfrom/roi_align/_ext/roi_align/__init__.py deleted file mode 100644 index c5b6e5d5..00000000 --- a/lib/modeling/roi_xfrom/roi_align/_ext/roi_align/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ - -from torch.utils.ffi import _wrap_function -from ._roi_align import lib as _lib, ffi as _ffi - -__all__ = [] -def _import_symbols(locals): - for symbol in dir(_lib): - fn = getattr(_lib, symbol) - if callable(fn): - locals[symbol] = _wrap_function(fn, _ffi) - else: - locals[symbol] = fn - __all__.append(symbol) - -_import_symbols(locals()) diff --git a/lib/modeling/roi_xfrom/roi_align/build.py b/lib/modeling/roi_xfrom/roi_align/build.py deleted file mode 100644 index 30f0f2d2..00000000 --- a/lib/modeling/roi_xfrom/roi_align/build.py +++ /dev/null @@ -1,36 +0,0 @@ -from __future__ import print_function -import os -import torch -from torch.utils.ffi import create_extension - -# sources = ['src/roi_align.c'] -# headers = ['src/roi_align.h'] -sources = [] -headers = [] -defines = [] -with_cuda = False - -if torch.cuda.is_available(): - print('Including CUDA code.') - sources += ['src/roi_align_cuda.c'] - headers += ['src/roi_align_cuda.h'] - defines += [('WITH_CUDA', None)] - with_cuda = True - -this_file = os.path.dirname(os.path.realpath(__file__)) -print(this_file) -extra_objects = ['src/roi_align_kernel.cu.o'] -extra_objects = [os.path.join(this_file, fname) for fname in extra_objects] - -ffi = create_extension( - '_ext.roi_align', - headers=headers, - sources=sources, - define_macros=defines, - relative_to=__file__, - with_cuda=with_cuda, - extra_objects=extra_objects -) - -if __name__ == '__main__': - ffi.build() diff --git a/lib/modeling/roi_xfrom/roi_align/functions/__init__.py b/lib/modeling/roi_xfrom/roi_align/functions/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/modeling/roi_xfrom/roi_align/functions/roi_align.py b/lib/modeling/roi_xfrom/roi_align/functions/roi_align.py deleted file mode 100644 index 56807b4a..00000000 --- a/lib/modeling/roi_xfrom/roi_align/functions/roi_align.py +++ /dev/null @@ -1,48 +0,0 @@ -import torch -from torch.autograd import Function -from .._ext import roi_align - - -# TODO use save_for_backward instead -class RoIAlignFunction(Function): - def __init__(self, aligned_height, aligned_width, spatial_scale, sampling_ratio): - self.aligned_width = int(aligned_width) - self.aligned_height = int(aligned_height) - self.spatial_scale = float(spatial_scale) - self.sampling_ratio = int(sampling_ratio) - self.rois = None - self.feature_size = None - - def forward(self, features, rois): - self.rois = rois - self.feature_size = features.size() - - batch_size, num_channels, data_height, data_width = features.size() - num_rois = rois.size(0) - - output = features.new(num_rois, num_channels, self.aligned_height, self.aligned_width).zero_() - if features.is_cuda: - roi_align.roi_align_forward_cuda(self.aligned_height, - self.aligned_width, - self.spatial_scale, self.sampling_ratio, features, - rois, output) - else: - raise NotImplementedError - - return output - - def backward(self, grad_output): - assert(self.feature_size is not None and grad_output.is_cuda) - - batch_size, num_channels, data_height, data_width = self.feature_size - - grad_input = self.rois.new(batch_size, num_channels, data_height, - data_width).zero_() - roi_align.roi_align_backward_cuda(self.aligned_height, - self.aligned_width, - self.spatial_scale, self.sampling_ratio, grad_output, - self.rois, grad_input) - - # print grad_input - - return grad_input, None diff --git a/lib/modeling/roi_xfrom/roi_align/make.sh b/lib/modeling/roi_xfrom/roi_align/make.sh deleted file mode 100644 index 8428ce49..00000000 --- a/lib/modeling/roi_xfrom/roi_align/make.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -CUDA_PATH=/usr/local/cuda/ - -cd src -echo "Compiling my_lib kernels by nvcc..." -nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu -x cu -Xcompiler -fPIC -arch=sm_61 - -cd ../ -python build.py diff --git a/lib/modeling/roi_xfrom/roi_align/modules/__init__.py b/lib/modeling/roi_xfrom/roi_align/modules/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/modeling/roi_xfrom/roi_align/modules/roi_align.py b/lib/modeling/roi_xfrom/roi_align/modules/roi_align.py deleted file mode 100644 index e97cefbe..00000000 --- a/lib/modeling/roi_xfrom/roi_align/modules/roi_align.py +++ /dev/null @@ -1,45 +0,0 @@ -from torch.nn.modules.module import Module -from torch.nn.functional import avg_pool2d, max_pool2d -from ..functions.roi_align import RoIAlignFunction - - -class RoIAlign(Module): - def __init__(self, aligned_height, aligned_width, spatial_scale, sampling_ratio): - super(RoIAlign, self).__init__() - - self.aligned_width = int(aligned_width) - self.aligned_height = int(aligned_height) - self.spatial_scale = float(spatial_scale) - self.sampling_ratio = int(sampling_ratio) - - def forward(self, features, rois): - return RoIAlignFunction(self.aligned_height, self.aligned_width, - self.spatial_scale, self.sampling_ratio)(features, rois) - -class RoIAlignAvg(Module): - def __init__(self, aligned_height, aligned_width, spatial_scale, sampling_ratio): - super(RoIAlignAvg, self).__init__() - - self.aligned_width = int(aligned_width) - self.aligned_height = int(aligned_height) - self.spatial_scale = float(spatial_scale) - self.sampling_ratio = int(sampling_ratio) - - def forward(self, features, rois): - x = RoIAlignFunction(self.aligned_height+1, self.aligned_width+1, - self.spatial_scale, self.sampling_ratio)(features, rois) - return avg_pool2d(x, kernel_size=2, stride=1) - -class RoIAlignMax(Module): - def __init__(self, aligned_height, aligned_width, spatial_scale, sampling_ratio): - super(RoIAlignMax, self).__init__() - - self.aligned_width = int(aligned_width) - self.aligned_height = int(aligned_height) - self.spatial_scale = float(spatial_scale) - self.sampling_ratio = int(sampling_ratio) - - def forward(self, features, rois): - x = RoIAlignFunction(self.aligned_height+1, self.aligned_width+1, - self.spatial_scale, self.sampling_ratio)(features, rois) - return max_pool2d(x, kernel_size=2, stride=1) diff --git a/lib/modeling/roi_xfrom/roi_align/src/roi_align_cuda.c b/lib/modeling/roi_xfrom/roi_align/src/roi_align_cuda.c deleted file mode 100644 index ab8d1e7c..00000000 --- a/lib/modeling/roi_xfrom/roi_align/src/roi_align_cuda.c +++ /dev/null @@ -1,76 +0,0 @@ -#include -#include -#include "roi_align_kernel.h" - -extern THCState *state; - -int roi_align_forward_cuda(int aligned_height, int aligned_width, float spatial_scale, int sampling_ratio, - THCudaTensor * features, THCudaTensor * rois, THCudaTensor * output) -{ - // Grab the input tensor - float * data_flat = THCudaTensor_data(state, features); - float * rois_flat = THCudaTensor_data(state, rois); - - float * output_flat = THCudaTensor_data(state, output); - - // Number of ROIs - int num_rois = THCudaTensor_size(state, rois, 0); - int size_rois = THCudaTensor_size(state, rois, 1); - if (size_rois != 5) - { - return 0; - } - - // data height - int data_height = THCudaTensor_size(state, features, 2); - // data width - int data_width = THCudaTensor_size(state, features, 3); - // Number of channels - int num_channels = THCudaTensor_size(state, features, 1); - - cudaStream_t stream = THCState_getCurrentStream(state); - - ROIAlignForwardLaucher( - data_flat, spatial_scale, num_rois, data_height, - data_width, num_channels, aligned_height, - aligned_width, sampling_ratio, rois_flat, - output_flat, stream); - - return 1; -} - -int roi_align_backward_cuda(int aligned_height, int aligned_width, float spatial_scale, int sampling_ratio, - THCudaTensor * top_grad, THCudaTensor * rois, THCudaTensor * bottom_grad) -{ - // Grab the input tensor - float * top_grad_flat = THCudaTensor_data(state, top_grad); - float * rois_flat = THCudaTensor_data(state, rois); - - float * bottom_grad_flat = THCudaTensor_data(state, bottom_grad); - - // Number of ROIs - int num_rois = THCudaTensor_size(state, rois, 0); - int size_rois = THCudaTensor_size(state, rois, 1); - if (size_rois != 5) - { - return 0; - } - - // batch size - int batch_size = THCudaTensor_size(state, bottom_grad, 0); - // data height - int data_height = THCudaTensor_size(state, bottom_grad, 2); - // data width - int data_width = THCudaTensor_size(state, bottom_grad, 3); - // Number of channels - int num_channels = THCudaTensor_size(state, bottom_grad, 1); - - cudaStream_t stream = THCState_getCurrentStream(state); - ROIAlignBackwardLaucher( - top_grad_flat, spatial_scale, batch_size, num_rois, data_height, - data_width, num_channels, aligned_height, - aligned_width, sampling_ratio, rois_flat, - bottom_grad_flat, stream); - - return 1; -} diff --git a/lib/modeling/roi_xfrom/roi_align/src/roi_align_cuda.h b/lib/modeling/roi_xfrom/roi_align/src/roi_align_cuda.h deleted file mode 100644 index 9c7576d7..00000000 --- a/lib/modeling/roi_xfrom/roi_align/src/roi_align_cuda.h +++ /dev/null @@ -1,5 +0,0 @@ -int roi_align_forward_cuda(int aligned_height, int aligned_width, float spatial_scale, int sampling_ratio, - THCudaTensor * features, THCudaTensor * rois, THCudaTensor * output); - -int roi_align_backward_cuda(int aligned_height, int aligned_width, float spatial_scale, int sampling_ratio, - THCudaTensor * top_grad, THCudaTensor * rois, THCudaTensor * bottom_grad); diff --git a/lib/modeling/roi_xfrom/roi_align/src/roi_align_kernel.cu b/lib/modeling/roi_xfrom/roi_align/src/roi_align_kernel.cu deleted file mode 100644 index 8da6cd26..00000000 --- a/lib/modeling/roi_xfrom/roi_align/src/roi_align_kernel.cu +++ /dev/null @@ -1,295 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include "roi_align_kernel.h" - -#define CUDA_1D_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ - i += blockDim.x * gridDim.x) - - /*** Forward ***/ - - __device__ float bilinear_interpolate(const float* bottom_data, const int height, const int width, - float y, float x, const int index /* index for debug only*/) { - // deal with cases that inverse elements are out of feature map boundary - if (y < -1.0 || y > height || x < -1.0 || x > width) { - // empty - return 0; - } - - if (y <= 0) { - y = 0; - } - if (x <= 0) { - x = 0; - } - - int y_low = (int)y; - int x_low = (int)x; - int y_high; - int x_high; - - if (y_low >= height - 1) { - y_high = y_low = height - 1; - y = (float)y_low; - } else { - y_high = y_low + 1; - } - - if (x_low >= width - 1) { - x_high = x_low = width - 1; - x = (float)x_low; - } else { - x_high = x_low + 1; - } - - float ly = y - y_low; - float lx = x - x_low; - float hy = 1. -ly, hx = 1. - lx; - // do bilinear interpolation - float v1 = bottom_data[y_low * width + x_low]; - float v2 = bottom_data[y_low * width + x_high]; - float v3 = bottom_data[y_high * width + x_low]; - float v4 = bottom_data[y_high * width + x_high]; - float w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; - - float val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); - - return val; - } - - __global__ void ROIAlignForward(const int nthreads, const float* bottom_data, const float spatial_scale, const int height, const int width, - const int channels, const int aligned_height, const int aligned_width, const int sampling_ratio, - const float* bottom_rois, float* top_data) { - CUDA_1D_KERNEL_LOOP(index, nthreads) { - // (n, c, ph, pw) is an element in the aligned output - int pw = index % aligned_width; - int ph = (index / aligned_width) % aligned_height; - int c = (index / aligned_width / aligned_height) % channels; - int n = index / aligned_width / aligned_height / channels; - - const float* offset_bottom_rois = bottom_rois + n * 5; - int roi_batch_ind = offset_bottom_rois[0]; - - // Do not using rounding; this implementation detail is critical - float roi_start_w = offset_bottom_rois[1] * spatial_scale; - float roi_start_h = offset_bottom_rois[2] * spatial_scale; - float roi_end_w = offset_bottom_rois[3] * spatial_scale; - float roi_end_h = offset_bottom_rois[4] * spatial_scale; - - // Force malformed ROIs to be 1x1 - float roi_width = fmaxf(roi_end_w - roi_start_w, 1.f); - float roi_height = fmaxf(roi_end_h - roi_start_h, 1.f); - float bin_size_h = roi_height / aligned_height; - float bin_size_w = roi_width / aligned_width; - - const float* offset_bottom_data = - bottom_data + (roi_batch_ind * channels + c) * height * width; - - // We use roi_bin_grid to sample the grid and mimic integral - int roi_bin_grid_h = (sampling_ratio > 0) - ? sampling_ratio - : ceil(roi_height / aligned_height); // e.g., = 2 - int roi_bin_grid_w = - (sampling_ratio > 0) ? sampling_ratio : ceil(roi_width / aligned_width); - - // We do average (integral) pooling inside a bin - const float count = roi_bin_grid_h * roi_bin_grid_w; // e.g. = 4 - - float output_val = 0.; - for (int iy = 0; iy < roi_bin_grid_h; iy++) // e.g., iy = 0, 1 - { - const float y = roi_start_h + ph * bin_size_h + - (iy + .5f) * bin_size_h / roi_bin_grid_h; // e.g., 0.5, 1.5 - for (int ix = 0; ix < roi_bin_grid_w; ix++) { - const float x = roi_start_w + pw * bin_size_w + - (ix + .5f) * bin_size_w / roi_bin_grid_w; - - float val = bilinear_interpolate( - offset_bottom_data, height, width, y, x, index); - output_val += val; - } - } - output_val /= count; - - top_data[index] = output_val; - } - } - - int ROIAlignForwardLaucher(const float* bottom_data, const float spatial_scale, const int num_rois, const int height, const int width, - const int channels, const int aligned_height, const int aligned_width, const int sampling_ratio, - const float* bottom_rois, float* top_data, cudaStream_t stream) { - const int kThreadsPerBlock = 1024; - const int output_size = num_rois * aligned_height * aligned_width * channels; - cudaError_t err; - - - ROIAlignForward<<<(output_size + kThreadsPerBlock - 1) / kThreadsPerBlock, kThreadsPerBlock, 0, stream>>>( - output_size, bottom_data, spatial_scale, height, width, channels, - aligned_height, aligned_width, sampling_ratio, bottom_rois, top_data); - - err = cudaGetLastError(); - if(cudaSuccess != err) { - fprintf( stderr, "cudaCheckError() failed : %s\n", cudaGetErrorString( err ) ); - exit( -1 ); - } - - return 1; - } - - /*** Backward ***/ - inline __device__ float gpu_atomic_add(const float val, float* address); - inline __device__ float gpu_atomic_add(const float val, float* address) { - return atomicAdd(address, val); - } - - __device__ void bilinear_interpolate_gradient(const int height, const int width, float y, float x, - float& w1, float& w2, float& w3, float& w4, - int& x_low, int& x_high, int& y_low, int& y_high, - const int index /* index for debug only*/) { - // deal with cases that inverse elements are out of feature map boundary - if (y < -1.0 || y > height || x < -1.0 || x > width) { - // empty - w1 = w2 = w3 = w4 = 0.; - x_low = x_high = y_low = y_high = -1; - return; - } - - if (y <= 0) { - y = 0; - } - if (x <= 0) { - x = 0; - } - - y_low = (int)y; - x_low = (int)x; - - if (y_low >= height - 1) { - y_high = y_low = height - 1; - y = (float)y_low; - } else { - y_high = y_low + 1; - } - - if (x_low >= width - 1) { - x_high = x_low = width - 1; - x = (float)x_low; - } else { - x_high = x_low + 1; - } - - float ly = y - y_low; - float lx = x - x_low; - float hy = 1. - ly, hx = 1. - lx; - - w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; - - return; - } - - __global__ void ROIAlignBackward(const int nthreads, const float* top_diff, const float spatial_scale, const int height, const int width, - const int channels, const int aligned_height, const int aligned_width, const int sampling_ratio, - float* bottom_diff, const float* bottom_rois) { - CUDA_1D_KERNEL_LOOP(index, nthreads) { - // (n, c, ph, pw) is an element in the aligned output - int pw = index % aligned_width; - int ph = (index / aligned_width) % aligned_height; - int c = (index / aligned_width / aligned_height) % channels; - int n = index / aligned_width / aligned_height / channels; - - const float* offset_bottom_rois = bottom_rois + n * 5; - int roi_batch_ind = offset_bottom_rois[0]; - - // Do not using rounding; this implementation detail is critical - float roi_start_w = offset_bottom_rois[1] * spatial_scale; - float roi_start_h = offset_bottom_rois[2] * spatial_scale; - float roi_end_w = offset_bottom_rois[3] * spatial_scale; - float roi_end_h = offset_bottom_rois[4] * spatial_scale; - - // Force malformed ROIs to be 1x1 - float roi_width = fmaxf(roi_end_w - roi_start_w, 1.f); - float roi_height = fmaxf(roi_end_h - roi_start_h, 1.f); - float bin_size_h = roi_height / aligned_height; - float bin_size_w = roi_width / aligned_width; - - float* offset_bottom_diff = - bottom_diff + (roi_batch_ind * channels + c) * height * width; - - int top_offset = (n * channels + c) * aligned_height * aligned_width; - const float* offset_top_diff = top_diff + top_offset; - const float top_diff_this_bin = offset_top_diff[ph * aligned_width + pw]; - - // We use roi_bin_grid to sample the grid and mimic integral - int roi_bin_grid_h = (sampling_ratio > 0) - ? sampling_ratio - : ceil(roi_height / aligned_height); // e.g., = 2 - int roi_bin_grid_w = - (sampling_ratio > 0) ? sampling_ratio : ceil(roi_width / aligned_width); - - // We do average (integral) pooling inside a bin - const float count = roi_bin_grid_h * roi_bin_grid_w; // e.g. = 4 - - for (int iy = 0; iy < roi_bin_grid_h; iy++) // e.g., iy = 0, 1 - { - const float y = roi_start_h + ph * bin_size_h + - (iy + .5f) * bin_size_h / roi_bin_grid_h; // e.g., 0.5, 1.5 - for (int ix = 0; ix < roi_bin_grid_w; ix++) { - const float x = roi_start_w + pw * bin_size_w + - (ix + .5f) * bin_size_w / roi_bin_grid_w; - - float w1, w2, w3, w4; - int x_low, x_high, y_low, y_high; - - bilinear_interpolate_gradient( - height, width, y, x, w1, w2, w3, w4, - x_low, x_high, y_low, y_high, index); - - float g1 = top_diff_this_bin * w1 / count; - float g2 = top_diff_this_bin * w2 / count; - float g3 = top_diff_this_bin * w3 / count; - float g4 = top_diff_this_bin * w4 / count; - - if (x_low >= 0 && x_high >= 0 && y_low >= 0 && y_high >= 0) { - // atomicAdd(offset_bottom_diff + y_low * width + x_low, g1); - // atomicAdd(offset_bottom_diff + y_low * width + x_high, g2); - // atomicAdd(offset_bottom_diff + y_high * width + x_low, g3); - // atomicAdd(offset_bottom_diff + y_high * width + x_high, g4); - gpu_atomic_add(g1, offset_bottom_diff + y_low * width + x_low); - gpu_atomic_add(g2, offset_bottom_diff + y_low * width + x_high); - gpu_atomic_add(g3, offset_bottom_diff + y_high * width + x_low); - gpu_atomic_add(g4, offset_bottom_diff + y_high * width + x_high); - } // if - } // ix - } // iy - } // CUDA_1D_KERNEL_LOOP - } // RoIAlignBackward - - int ROIAlignBackwardLaucher(const float* top_diff, const float spatial_scale, const int batch_size, const int num_rois, const int height, const int width, - const int channels, const int aligned_height, const int aligned_width, const int sampling_ratio, - const float* bottom_rois, float* bottom_diff, cudaStream_t stream) { - const int kThreadsPerBlock = 1024; - const int output_size = num_rois * aligned_height * aligned_width * channels; - cudaError_t err; - - ROIAlignBackward<<<(output_size + kThreadsPerBlock - 1) / kThreadsPerBlock, kThreadsPerBlock, 0, stream>>>( - output_size, top_diff, spatial_scale, height, width, channels, - aligned_height, aligned_width, sampling_ratio, bottom_diff, bottom_rois); - - err = cudaGetLastError(); - if(cudaSuccess != err) { - fprintf( stderr, "cudaCheckError() failed : %s\n", cudaGetErrorString( err ) ); - exit( -1 ); - } - - return 1; - } - - -#ifdef __cplusplus -} -#endif diff --git a/lib/modeling/roi_xfrom/roi_align/src/roi_align_kernel.h b/lib/modeling/roi_xfrom/roi_align/src/roi_align_kernel.h deleted file mode 100644 index 4cff4957..00000000 --- a/lib/modeling/roi_xfrom/roi_align/src/roi_align_kernel.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _ROI_ALIGN_KERNEL -#define _ROI_ALIGN_KERNEL - -#ifdef __cplusplus -extern "C" { -#endif - -__global__ void ROIAlignForward(const int nthreads, const float* bottom_data, - const float spatial_scale, const int height, const int width, - const int channels, const int aligned_height, const int aligned_width, const int sampling_ratio, - const float* bottom_rois, float* top_data); - -int ROIAlignForwardLaucher( - const float* bottom_data, const float spatial_scale, const int num_rois, const int height, - const int width, const int channels, const int aligned_height, - const int aligned_width, const int sampling_ratio, const float* bottom_rois, - float* top_data, cudaStream_t stream); - -__global__ void ROIAlignBackward(const int nthreads, const float* top_diff, - const float spatial_scale, const int height, const int width, - const int channels, const int aligned_height, const int aligned_width, const int sampling_ratio, - float* bottom_diff, const float* bottom_rois); - -int ROIAlignBackwardLaucher(const float* top_diff, const float spatial_scale, const int batch_size, const int num_rois, - const int height, const int width, const int channels, const int aligned_height, - const int aligned_width, const int sampling_ratio, const float* bottom_rois, - float* bottom_diff, cudaStream_t stream); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/lib/setup_bbox.py b/lib/setup.py similarity index 100% rename from lib/setup_bbox.py rename to lib/setup.py diff --git a/lib/setup_layers.py b/lib/setup_layers.py deleted file mode 100644 index 32f029a4..00000000 --- a/lib/setup_layers.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#!/usr/bin/env python - -import glob -import os - -import torch -from setuptools import find_packages -from setuptools import setup -from torch.utils.cpp_extension import CUDA_HOME -from torch.utils.cpp_extension import CppExtension -from torch.utils.cpp_extension import CUDAExtension - -requirements = ["torch", "torchvision"] - - -def get_extensions(): - this_dir = os.path.dirname(os.path.abspath(__file__)) - extensions_dir = os.path.join(this_dir, "model", "csrc") - - main_file = glob.glob(os.path.join(extensions_dir, "*.cpp")) - source_cpu = glob.glob(os.path.join(extensions_dir, "cpu", "*.cpp")) - source_cuda = glob.glob(os.path.join(extensions_dir, "cuda", "*.cu")) - - sources = main_file + source_cpu - extension = CppExtension - - extra_compile_args = {"cxx": []} - define_macros = [] - - if torch.cuda.is_available() and CUDA_HOME is not None: - extension = CUDAExtension - sources += source_cuda - define_macros += [("WITH_CUDA", None)] - extra_compile_args["nvcc"] = [ - "-DCUDA_HAS_FP16=1", - "-D__CUDA_NO_HALF_OPERATORS__", - "-D__CUDA_NO_HALF_CONVERSIONS__", - "-D__CUDA_NO_HALF2_OPERATORS__", - ] - - sources = [os.path.join(extensions_dir, s) for s in sources] - - include_dirs = [extensions_dir] - - ext_modules = [ - extension( - "model._C", - sources, - include_dirs=include_dirs, - define_macros=define_macros, - extra_compile_args=extra_compile_args, - ) - ] - - return ext_modules - - -setup( - name="detectron_pytorch", - version="0.1", - description="detectron in pytorch", - packages=find_packages(exclude=("configs", "tests",)), - # install_requires=requirements, - ext_modules=get_extensions(), - cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension}, -) diff --git a/lib/model/utils/net_utils.py b/lib/utils/net_utils.py similarity index 100% rename from lib/model/utils/net_utils.py rename to lib/utils/net_utils.py From 9f2dc7c0adbf889ff84b3705ee28aedf6c4395e4 Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Thu, 30 May 2019 12:28:44 +0530 Subject: [PATCH 51/52] Update README.md --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 47d8f01b..2cd950cc 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ -**This code follows the implementation architecture of Detectron.** Only part of the functionality is supported. Check [this section](#supported-network-modules) for more information. This code now supports **PyTorch 1.0** +**This code follows the implementation architecture of Detectron.** Only part of the functionality is supported. Check [this section](#supported-network-modules) for more information. This code now supports **PyTorch 1.0** and **TorchVision 0.3**. With this code, you can... @@ -48,6 +48,7 @@ This implementation has the following features: - (2018/05/15) PyTorch0.4 is supported now ! - (2019/08/28) Support PASCAL VOC and Custom Dataset - (2019/01/17) **PyTorch 1.0 Supported now!** +- (2019/05/30) Code rebased on **TorchVision 0.3**. Compilation is now optional! ## Getting Started Clone the repo: @@ -62,7 +63,7 @@ Tested under python3. - python packages - pytorch>=1.0.0 - - torchvision>=0.2.0 + - torchvision>=0.3.0 - cython>=0.29.2 - matplotlib - numpy @@ -72,10 +73,10 @@ Tested under python3. - packaging - [pycocotools](https://github.com/cocodataset/cocoapi) — for COCO dataset, also available from pip. - tensorboardX — for logging the losses in Tensorboard -- An NVIDAI GPU and CUDA 8.0 or higher. Some operations only have gpu implementation. +- An NVIDIA GPU and CUDA 8.0 or higher. Some operations only have gpu implementation. - **NOTICE**: different versions of Pytorch package have different memory usages. -### Compilation +### Compilation [Optional] Compile the CUDA code: @@ -84,7 +85,7 @@ cd lib # please change to this directory sh make.sh ``` -It will compile all the modules you need, including NMS, ROI_Pooing and ROI_Align. (Actually gpu nms is never used ...) +It will compile all the modules you need, including NMS. (Actually gpu nms is never used ...) Note that, If you use `CUDA_VISIBLE_DEVICES` to set gpus, **make sure at least one gpu is visible when compile the code.** From c780eb3d22808911978b317fe97cf544c8c47d8b Mon Sep 17 00:00:00 2001 From: Aditya Arun Date: Thu, 5 Sep 2019 13:14:43 +0530 Subject: [PATCH 52/52] Fix bug Fixes #10 --- lib/nn/parallel/scatter_gather.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/nn/parallel/scatter_gather.py b/lib/nn/parallel/scatter_gather.py index 69474383..b9dce95a 100644 --- a/lib/nn/parallel/scatter_gather.py +++ b/lib/nn/parallel/scatter_gather.py @@ -5,7 +5,17 @@ from torch.autograd import Variable from ._functions import Scatter, Gather from torch._six import string_classes, int_classes -from torch.utils.data.dataloader import numpy_type_map + +numpy_type_map = { + 'float64': torch.DoubleTensor, + 'float32': torch.FloatTensor, + 'float16': torch.HalfTensor, + 'int64': torch.LongTensor, + 'int32': torch.IntTensor, + 'int16': torch.ShortTensor, + 'int8': torch.CharTensor, + 'uint8': torch.ByteTensor, +} def scatter(inputs, target_gpus, dim=0):