Skip to content

[YOLO]yolo op added in frontend and removed from topi - #1974

Merged
tqchen merged 1 commit into
apache:masterfrom
siju-samuel:yolo_removal
Oct 30, 2018
Merged

tqchen merged 1 commit into
apache:masterfrom
siju-samuel:yolo_removal

Conversation

@siju-samuel

Copy link
Copy Markdown
Member

The yolo op is used only in darknet and since its not generic and can be acheived by frontend itself, i implemented the op in darknet.py and removed all the existing yolo_op registration, testcases and topi code.

@PariksheetPinjari909 @yzhliu Please review. Thanks in advance.

Thanks for contributing to TVM! Please refer to guideline https://docs.tvm.ai/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers.

@siju-samuel siju-samuel changed the title [YOLO]yolo app added in frontend and removed from topi [YOLO]yolo op added in frontend and removed from topi Oct 24, 2018
@siju-samuel
siju-samuel force-pushed the yolo_removal branch 2 times, most recently from 90f9827 to 3961f81 Compare October 24, 2018 13:04
@siju-samuel

Copy link
Copy Markdown
Member Author

cc @PariksheetPinjari909 @masahi @yzhliu please review

@PariksheetPinjari909

Copy link
Copy Markdown
Contributor

As yolo, region are not generic ops and looking at the progress of darknet, moving these ops to frontend is a good idea. Thanks @siju-samuel for bringing in this PR. Let's check if we can bring region to frontend as well. Any views on this @yzhliu

@siju-samuel

Copy link
Copy Markdown
Member Author

@PariksheetPinjari909 I have already tried this.
But im facing a strange issue with concatenate for some specific values in graph_runtime create.
I reported an issue here
https://discuss.tvm.ai/t/graphruntimecreate-is-in-deadloop/1032
Waiting for replys.
This can be replaced with the below code and all the region op in topi/nnvm can be removed.

def _darknet_region(inputs, attrs):
    """Process the region operation."""
    num = attrs.get('n', 1)
    classes = attrs.get('classes', 1)
    coords = attrs.get('coords', 0)
    background = attrs.get('background', 0)
    softmax = attrs.get('softmax', True)
    input_shape = attrs.get('shape')

    split_size = classes + coords + 1;
    intermediate_shape = (input_shape[0], num, split_size, input_shape[2], input_shape[3])
    data_block = _sym.reshape(inputs[0], shape=intermediate_shape)
    split_res = _sym.split(data_block, indices_or_sections=split_size, axis=2)
    splits = []
    for i in split_res:
        splits.append(i)
    splits[0] = _sym.sigmoid(splits[0])
    splits[1] = _sym.sigmoid(splits[1])
    if not background:
        splits[coords] = _sym.sigmoid(splits[coords])
    if softmax:
        offset = coords + int(not background)
        softmax_input = _sym.concatenate(*splits[offset:], axis=2)
        softmax_output = _sym.softmax(softmax_input, axis=2)
        data_block_1 = splits[:offset]
        splits = data_block_1 + [softmax_output]
    concat_out = _sym.concatenate(*splits, axis=2)
    return _sym.reshape(concat_out, shape=input_shape), None

@PariksheetPinjari909 PariksheetPinjari909 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tqchen
tqchen merged commit b840e96 into apache:master Oct 30, 2018
@tqchen

tqchen commented Oct 30, 2018

Copy link
Copy Markdown
Member

Thanks @PariksheetPinjari909 @siju-samuel this is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants