ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Common.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <cassert>
18
19#include "Common.h"
20
21namespace mir_interpreter
22{
23
24using namespace mir;
25
26Index shift(const Index &in_index, const Shape &shift_from)
27{
28 Index index = in_index;
29 assert(index.rank() == shift_from.rank());
30 for (int32_t d = 0; d < in_index.rank(); ++d)
31 {
32 index.at(d) = index.at(d) + shift_from.dim(d);
33 }
34 return index;
35}
36
37} // namespace mir_interpreter
int32_t rank() const
Definition Index.h:43
int32_t & dim(int32_t axis) noexcept
Definition Shape.h:47
int32_t rank() const
Definition Shape.h:43
Index shift(const Index &in_index, const Shape &shift_from)
Definition Common.cpp:26