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>
23 #include <luci/IR/CircleNodes.h>
31 struct ShapeDescription
33 std::vector<int32_t> _dims;
37 // TODO remove these when CircleDialect is fully functioal
38 ShapeDescription to_shape_description(const luci::CircleNode *node);
39 ShapeDescription to_shape_description(const loco::TensorShape &shape);
40 ShapeDescription to_shape_description(const loco::FeatureShape &shape);
41 ShapeDescription to_shape_description(const loco::FilterShape &shape);
42 ShapeDescription to_shape_description(const loco::BiasShape &shape);
43 ShapeDescription to_shape_description(const loco::MatrixShape &shape);
44 ShapeDescription to_shape_description(const loco::NodeShape &shape);
46 template <typename Permutation> inline bool isNHWC(Permutation *perm);
48 template <> inline bool isNHWC(loco::Permutation<loco::Domain::Feature> *perm)
50 return perm->axis(loco::FeatureAxis::Count) == 0 && perm->axis(loco::FeatureAxis::Height) == 1 &&
51 perm->axis(loco::FeatureAxis::Width) == 2 && perm->axis(loco::FeatureAxis::Depth) == 3;
54 template <> inline bool isNHWC(loco::Permutation<loco::Domain::Filter> *perm)
56 return perm->axis(loco::FilterAxis::Count) == 0 && perm->axis(loco::FilterAxis::Height) == 1 &&
57 perm->axis(loco::FilterAxis::Width) == 2 && perm->axis(loco::FilterAxis::Depth) == 3;
62 #endif // __LUCI_SHAPE_DESCRIPTION_H__