-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ETHOSN] Connect existing arm_cpu schedule to relay strategy for conc…
…atenate NPU used generic implementation for concatenate before cpu schedules were made the default fallback schedules. This leads to performance degradation as this blocks fusion with nearby ops. This commit adds Relay op strategy for arm_cpu implementation which makes it use arm_cpu schedule before cpu one. Reference: #13775 Co-authored-by: Luke Hutton <luke.hutton@arm.com>
- Loading branch information
1 parent
302cee9
commit c80d8fa
Showing
2 changed files
with
67 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
""" Tests strategy selection for Relay ops """ | ||
import pytest | ||
import tvm | ||
from tvm import relay | ||
from tvm import te | ||
from tvm.relay.testing import run_infer_type | ||
import tvm.testing | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"target, expected_implementation", | ||
[("llvm", "concatenate.cpu"), ("llvm -device=arm_cpu", "concatenate.arm_cpu")], | ||
) | ||
def test_concatenate(target, expected_implementation): | ||
target = tvm.target.Target(target) | ||
|
||
shape = (1, 1, 1, 3) | ||
dtype = "float32" | ||
axis = 1 | ||
inputs = [] | ||
inputs.append(relay.var("var0", shape=shape, dtype=dtype)) | ||
inputs.append(relay.var("var1", shape=shape, dtype=dtype)) | ||
input_tuple = relay.Tuple(inputs) | ||
out = relay.op.concatenate(input_tuple, axis) | ||
out = run_infer_type(out) | ||
|
||
impl, xx = relay.backend.te_compiler.select_implementation( | ||
relay.op.get("concatenate"), | ||
out.attrs, | ||
[te.placeholder(shape)], | ||
out.checked_type, | ||
target, | ||
use_autotvm=False, | ||
) | ||
assert impl.name == expected_implementation | ||
|
||
|
||
if __name__ == "__main__": | ||
tvm.testing.main() |