ONE - On-device Neural Engine
Loading...
Searching...
No Matches
CircleCustom.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 __LUCI_IR_CIRCLECUSTOM_H__
18#define __LUCI_IR_CIRCLECUSTOM_H__
19
22
23namespace luci
24{
25
29class CircleCustom final : public VariadicArityNode<CircleNodeImpl<CircleOpcode::CUSTOM>>
30{
31public:
32 CircleCustom(uint32_t arity, uint32_t out)
33 : VariadicArityNode<CircleNodeImpl<CircleOpcode::CUSTOM>>(arity), _output_count(out)
34 {
35 // NOTE Custom can have 0 input or 0 output but not both
36 assert(arity != 0 || out != 0);
37 }
38
39public:
40 uint32_t numInputs(void) const { return arity(); }
41 uint32_t numOutputs(void) const { return _output_count; }
42
43public:
44 Node *inputs(uint32_t index) const { return at(index)->node(); }
45 void inputs(uint32_t index, Node *node) { at(index)->node(node); }
46
47public:
48 const std::vector<uint8_t> &custom_options(void) const { return _custom_options; }
49 void custom_options(const std::vector<uint8_t> &custom_options)
50 {
51 _custom_options = custom_options;
52 }
53
54 const std::string &custom_code(void) const { return _custom_code; }
55 void custom_code(const std::string &custom_code) { _custom_code = custom_code; }
56
57private:
58 std::vector<uint8_t> _custom_options;
59 std::string _custom_code;
60 uint32_t _output_count{0};
61};
62
63} // namespace luci
64
65#endif // __LUCI_IR_CIRCLECUSTOM_H__
Node()=default
Node * node(void) const
Definition Use.h:58
CUSTOM in Circle.
const std::vector< uint8_t > & custom_options(void) const
uint32_t numInputs(void) const
void custom_options(const std::vector< uint8_t > &custom_options)
uint32_t numOutputs(void) const
void custom_code(const std::string &custom_code)
void inputs(uint32_t index, Node *node)
Node * inputs(uint32_t index) const
CircleCustom(uint32_t arity, uint32_t out)
const std::string & custom_code(void) const
Nodes with the variadic inputs.
uint32_t arity(void) const final
Return the number of arguments.