2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __SOUSCHEF_DIMS_H__
18 #define __SOUSCHEF_DIMS_H__
27 template <typename T> using Dims = std::vector<T>;
29 template <typename SHAPETYPE> Dims<int32_t> as_dims(const SHAPETYPE &shape)
31 std::vector<int32_t> res;
33 for (auto &dim : shape.dim())
35 res.emplace_back(static_cast<int32_t>(dim));
41 int32_t element_count(const Dims<int32_t> &dims)
43 return std::accumulate(dims.begin(), dims.end(), 1, std::multiplies<int32_t>());
46 } // namespace souschef
48 #endif // __SOUSCHEF_DIMS_H__