-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remote/develop' into onnx_mt_perf
- Loading branch information
Showing
50 changed files
with
2,245 additions
and
703 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
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
30 changes: 30 additions & 0 deletions
30
nncf/experimental/common/tensor_statistics/statistical_functions.py
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,30 @@ | ||
# Copyright (c) 2023 Intel Corporation | ||
# 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. | ||
|
||
from nncf.experimental.tensor import Tensor | ||
from nncf.experimental.tensor import functions as fns | ||
|
||
|
||
def mean_per_channel(x: Tensor, axis: int) -> Tensor: | ||
""" | ||
Computes the mean of elements across given channel dimension of Tensor. | ||
:param x: Tensor to reduce. | ||
:param axis: The channel dimensions to reduce. | ||
:return: Reduced Tensor. | ||
""" | ||
if len(x.shape) < 3: | ||
return fns.mean(x, axis=0) | ||
pos_axis = axis + x.ndim if axis < 0 else axis | ||
if pos_axis < 0 or pos_axis >= x.ndim: | ||
raise ValueError(f"axis {axis} is out of bounds for array of dimension {x.ndim}") | ||
axis = tuple(i for i in range(x.ndim) if i != pos_axis) | ||
return fns.mean(x, axis=axis) |
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.