-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[QualcommQnn] support models (#9412)
- Loading branch information
1 parent
322f350
commit b5e5795
Showing
27 changed files
with
427 additions
and
53 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
lite/backends/nnadapter/nnadapter/include/nnadapter/operation/math/expand.h
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,51 @@ | ||
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// Licensed 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. | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
#include "operation/math/utility.h" | ||
|
||
namespace nnadapter { | ||
namespace operation { | ||
namespace math { | ||
|
||
template <typename T> | ||
static int expand(const T* input_data, | ||
const std::vector<int32_t>& input_shape, | ||
T* output_data, | ||
const std::vector<int32_t>& output_shape) { | ||
std::vector<int> in_stride(input_shape.size(), 1); | ||
std::vector<int> out_stride(output_shape.size(), 1); | ||
for (int i = input_shape.size() - 2; i >= 0; --i) { | ||
in_stride[i] = input_shape[i + 1] * in_stride[i + 1]; | ||
} | ||
for (int i = output_shape.size() - 2; i >= 0; --i) { | ||
out_stride[i] = output_shape[i + 1] * out_stride[i + 1]; | ||
} | ||
int out_size = shape_production(output_shape); | ||
for (int out_id = 0; out_id < out_size; ++out_id) { | ||
int in_id = 0; | ||
for (int i = input_shape.size() - 1; i >= 0; --i) { | ||
int in_j = (out_id / out_stride[i]) % input_shape[i]; | ||
in_id += in_j * in_stride[i]; | ||
} | ||
output_data[out_id] = input_data[in_id]; | ||
} | ||
return 0; | ||
} | ||
|
||
} // namespace math | ||
} // namespace operation | ||
} // namespace nnadapter |
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
23 changes: 23 additions & 0 deletions
23
...nds/nnadapter/nnadapter/include/nnadapter/optimizer/fuse_unsqueeze_pad_squeeze_into_pad.h
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,23 @@ | ||
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// Licensed 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. | ||
|
||
#pragma once | ||
|
||
#include "core/types.h" | ||
|
||
namespace nnadapter { | ||
|
||
void FuseUnsqueezePadSqueezeIntoPad(core::Model *model); | ||
|
||
} // namespace nnadapter |
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
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
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
Oops, something went wrong.