ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Index.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 "mir/Index.h"
18
19#include <algorithm>
20
21namespace mir
22{
23
25{
26 _indices.resize(size);
27 return *this;
28}
29
30Index &Index::fill(int32_t index)
31{
32 std::fill(std::begin(_indices), std::end(_indices), index);
33 return (*this);
34}
35
36std::ostream &operator<<(std::ostream &s, const Index &idx)
37{
38 s << "[ ";
39 for (int32_t i = 0; i < idx.rank(); ++i)
40 {
41 if (i != 0)
42 s << ", ";
43 s << idx.at(i);
44 }
45 s << "]";
46
47 return s;
48}
49
50} // namespace mir
void resize(size_t new_size) noexcept
resize to given new size
Definition SmallVector.h:78
int32_t rank() const
Definition Index.h:43
Index & resize(int32_t size)
resize index to given dimension number
Definition Index.cpp:24
Index & fill(int32_t index)
fill all axis with index
Definition Index.cpp:30
int32_t & at(int32_t axis)
return position on given axis
Definition Index.h:64
std::ostream & operator<<(std::ostream &s, const Index &idx)
Definition Index.cpp:36
int32_t size[5]
Definition Slice.cpp:35