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#include "cascader_options.h"
20
21#include <utility>
22
23namespace tvm {
24namespace contrib {
25namespace ethosu {
26namespace cascader {
27
28void CascaderOptionsNode::VisitAttrs(AttrVisitor* v) {
29 v->Visit("cascade_region", &cascade_region);
30 v->Visit("max_proposals", &max_proposals);
31 v->Visit("stripe_factors", &stripe_factors);
32 v->Visit("max_plan_size", &max_plan_size);
33 v->Visit("max_open_plans", &max_open_plans);
34 v->Visit("max_closed_plans", &max_closed_plans);
35 v->Visit("always_copy_size", &always_copy_size);
36 v->Visit("disable_pareto_plans", &disable_pareto_plans);
37 v->Visit("disable_pareto_proposals", &disable_pareto_proposals);
38 v->Visit("enable_multi_dimensional_striping", &enable_multi_dimensional_striping);
39 v->Visit("disable_block_culling", &disable_block_culling);
40 v->Visit("enable_striping", &enable_striping);
41}
42
43CascaderOptions::CascaderOptions(const MemoryRegion& cascade_region, int max_proposals,
44 int stripe_factors, int max_plan_size, int max_open_plans,
45 int max_closed_plans, int always_copy_size,
46 bool disable_pareto_plans, bool disable_pareto_proposals,
47 bool enable_multi_dimensional_striping, bool disable_block_culling,
48 bool enable_striping) {
49 auto n = make_object<CascaderOptionsNode>();
50 n->cascade_region = std::move(cascade_region);
51 n->max_proposals = max_proposals;
52 n->stripe_factors = stripe_factors;
53 n->max_plan_size = max_plan_size;
54 n->max_open_plans = max_open_plans;
55 n->max_closed_plans = max_closed_plans;
56 n->always_copy_size = always_copy_size;
57 n->disable_pareto_plans = disable_pareto_plans;
58 n->disable_pareto_proposals = disable_pareto_proposals;
59 n->enable_multi_dimensional_striping = enable_multi_dimensional_striping;
60 n->disable_block_culling = disable_block_culling;
61 n->enable_striping = enable_striping;
62 data_ = std::move(n);
63}
64
65TVM_REGISTER_GLOBAL("contrib.ethosu.cascader.CascaderOptions")
66 .set_body_typed([](MemoryRegion cascade_region, int max_proposals, int stripe_factors,
67 int max_plan_size, int max_open_plans, int max_closed_plans,
68 int always_copy_size, bool disable_pareto_plans,
69 bool disable_pareto_proposals, bool enable_multi_dimensional_striping,
70 bool disable_block_culling, bool enable_striping) {
71 return CascaderOptions(
72 cascade_region, max_proposals, stripe_factors, max_plan_size, max_open_plans,
73 max_closed_plans, always_copy_size, disable_pareto_plans, disable_pareto_proposals,
74 enable_multi_dimensional_striping, disable_block_culling, enable_striping);
75 });
76
77TVM_REGISTER_NODE_TYPE(CascaderOptionsNode);
78
79} // namespace cascader
80} // namespace ethosu
81} // namespace contrib
82} // namespace tvm
83