1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20/*!
21 * \file src/contrib/ethosu/cascader/cascader_options.h
22 * \brief Class to store configuration options for the NPU cascader
23 */
24#ifndef TVM_CONTRIB_ETHOSU_CASCADER_CASCADER_OPTIONS_H_
25#define TVM_CONTRIB_ETHOSU_CASCADER_CASCADER_OPTIONS_H_
26
27#include <tvm/node/reflection.h>
28#include <tvm/runtime/object.h>
29
30#include "tensor_config.h"
31
32namespace tvm {
33namespace contrib {
34namespace ethosu {
35namespace cascader {
36
37/*! \brief Node to represent CascaderOptions */
38class CascaderOptionsNode : public Object {
39 public:
40 void VisitAttrs(AttrVisitor* v);
41
42 /*! \brief The MemoryRegion to place cascading buffer into. */
43 MemoryRegion cascade_region;
44 /*! \brief The maximum number of Proposals to generate. */
45 int max_proposals;
46 /*! \brief How many striping factors to try per axis. */
47 int stripe_factors;
48 /*! \brief The maximum number of Parts in a Plan. */
49 int max_plan_size;
50 /*! \brief The maximum number of open Plans saved for a Part Group */
51 int max_open_plans;
52 /*! \brief The maximum number of closed Plans saved for a Part Group */
53 int max_closed_plans;
54 /*! \brief The maximum size of Tensor that will always be copied into the cascade region. */
55 int always_copy_size;
56 /*! \brief Flag to disable pareto culling for plans to allow non pareto-optimal plans */
57 bool disable_pareto_plans;
58 /*! \brief Flag to disable pareto culling for proposals to allow non pareto-optimal proposals */
59 bool disable_pareto_proposals;
60 /*! \brief Whether to consider multi-dimensional striping */
61 bool enable_multi_dimensional_striping;
62 /*! \brief Flag to disable culling for block configs to allow non-dominant blocks */
63 bool disable_block_culling;
64 /*! \brief A boolean option to enable striping. */
65 bool enable_striping;
66
67 static constexpr const char* _type_key = "contrib.ethosu.cascader.CascaderOptions";
68 TVM_DECLARE_FINAL_OBJECT_INFO(CascaderOptionsNode, Object)
69};
70
71/*! \brief A class to hold configuration options for the cascader. */
72class CascaderOptions : public ObjectRef {
73 public:
74 CascaderOptions(const MemoryRegion& cascade_region, int max_proposals, int stripe_factors,
75 int max_plan_size, int max_open_plans, int max_closed_plans, int always_copy_size,
76 bool disable_pareto_plans, bool disable_pareto_proposals,
77 bool enable_multi_dimensional_striping, bool disable_block_culling,
78 bool multi_dimensional_striping);
79
80 TVM_DEFINE_OBJECT_REF_METHODS(CascaderOptions, ObjectRef, CascaderOptionsNode);
81};
82
83} // namespace cascader
84} // namespace ethosu
85} // namespace contrib
86} // namespace tvm
87
88#endif // TVM_CONTRIB_ETHOSU_CASCADER_CASCADER_OPTIONS_H_
89