ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Dims.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 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
#ifndef __SOUSCHEF_DIMS_H__
18
#define __SOUSCHEF_DIMS_H__
19
20
#include <cstdint>
21
#include <functional>
22
#include <numeric>
23
#include <vector>
24
25
namespace
souschef
26
{
27
28
template
<
typename
T>
using
Dims
= std::vector<T>;
29
30
using
DimsI32_t
=
Dims<int32_t>
;
31
32
template
<
typename
SHAPETYPE>
DimsI32_t
as_dims
(
const
SHAPETYPE &shape)
33
{
34
std::vector<int32_t> res;
35
36
for
(
auto
&dim : shape.dim())
37
{
38
res.emplace_back(
static_cast<
int32_t
>
(dim));
39
}
40
41
return
res;
42
}
43
44
int32_t
element_count
(
const
DimsI32_t
&dims)
45
{
46
return
std::accumulate(dims.begin(), dims.end(), 1, std::multiplies<int32_t>());
47
}
48
49
}
// namespace souschef
50
51
#endif
// __SOUSCHEF_DIMS_H__
souschef
This file provides string <-> number cast helpers.
Definition
Arguments.h:24
souschef::as_dims
DimsI32_t as_dims(const SHAPETYPE &shape)
Definition
Dims.h:32
souschef::element_count
int32_t element_count(const DimsI32_t &dims)
Definition
Dims.h:44
souschef::DimsI32_t
Dims< int32_t > DimsI32_t
Definition
Dims.h:30
Dims
Definition
Dims.h:26
compiler
souschef
include
souschef
Dims.h
Generated by
1.9.8