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 __LUCI_SHAPE_DESCRIPTION_H__
18 #define __LUCI_SHAPE_DESCRIPTION_H__
20 #include <loco/IR/PermutingCodec.h>
21 #include <loco/IR/NodeShape.h>
29 struct ShapeDescription
31 std::vector<int32_t> _dims;
35 // TODO remove these when CircleDialect is fully functioal
36 ShapeDescription to_shape_description(const loco::TensorShape &shape);
37 ShapeDescription to_shape_description(const loco::FeatureShape &shape);
38 ShapeDescription to_shape_description(const loco::FilterShape &shape);
39 ShapeDescription to_shape_description(const loco::BiasShape &shape);
40 ShapeDescription to_shape_description(const loco::MatrixShape &shape);
41 ShapeDescription to_shape_description(const loco::NodeShape &shape);
43 template <typename Permutation> inline bool isNHWC(Permutation *perm);
45 template <> inline bool isNHWC(loco::Permutation<loco::Domain::Feature> *perm)
47 return perm->axis(loco::FeatureAxis::Count) == 0 && perm->axis(loco::FeatureAxis::Height) == 1 &&
48 perm->axis(loco::FeatureAxis::Width) == 2 && perm->axis(loco::FeatureAxis::Depth) == 3;
51 template <> inline bool isNHWC(loco::Permutation<loco::Domain::Filter> *perm)
53 return perm->axis(loco::FilterAxis::Count) == 0 && perm->axis(loco::FilterAxis::Height) == 1 &&
54 perm->axis(loco::FilterAxis::Width) == 2 && perm->axis(loco::FilterAxis::Depth) == 3;
59 #endif // __LUCI_SHAPE_DESCRIPTION_H__