ONE - On-device Neural Engine
Loading...
Searching...
No Matches
CircleVariable.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2022 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
#include "
luci/Import/Nodes/CircleVariable.h
"
18
19
#include <
luci/IR/Nodes/CircleVariable.h
>
20
#include <
luci/Log.h
>
21
22
#include <cassert>
23
#include <ostream>
24
#include <string>
25
#include <vector>
26
27
namespace
28
{
29
30
std::ostream &
operator<<
(std::ostream &os,
const
luci::VectorWrapper<int32_t>
&vect)
31
{
32
uint32_t seq = 0;
33
for
(
const
auto
&v : vect)
34
{
35
if
(seq)
36
os <<
", "
;
37
os << v;
38
seq++;
39
}
40
return
os;
41
}
42
43
}
// namespace
44
45
namespace
luci
46
{
47
48
CircleVariable
*
create_circlevariable
(
GraphBuilderContext
*context, int32_t
tensor_index
)
49
{
50
LOGGER
(l);
51
52
auto
graph = context->
graph
();
53
auto
reader = context->
reader
();
54
const
auto
tensors = reader->
tensors
();
55
const
auto
variable_tensor
= tensors[
tensor_index
];
56
assert(
variable_tensor
!=
nullptr
);
57
58
if
(
not
variable_tensor
->is_variable())
59
{
60
// not a variable
61
return
nullptr
;
62
}
63
{
64
// check if there is no buffer as we don't support this for now
65
// TODO use buffer when this is enabled in Kernel
66
assert(reader->buffers()[
variable_tensor
->buffer()] !=
nullptr
);
67
assert(reader->buffers()[
variable_tensor
->buffer()]->data() ==
nullptr
);
68
}
69
70
auto
variable_node
= graph->nodes()->create<
CircleVariable
>();
71
copy_tensor_attributes
(
variable_tensor
,
variable_node
);
72
variable_node
->shape_status(
luci::ShapeStatus::VALID
);
73
74
INFO
(l) <<
"[luci] NodeFinder variable node("
<<
tensor_index
<<
") -> "
<<
variable_node
<<
" "
75
<<
wrap
(
variable_tensor
->shape()) << std::endl;
76
77
return
variable_node
;
78
}
79
80
}
// namespace luci
LOGGER
#define LOGGER(name)
Definition
Log.h:65
INFO
#define INFO(name)
Definition
Log.h:68
operator<<
std::ostream & operator<<(std::ostream &os, const circledump::ModelEx &model)
Definition
Dump.cpp:477
luci::CircleReader::tensors
CircleTensors tensors() const
Definition
CircleReader.h:107
luci::CircleVariable
Virtual CircleVariable in Circle for 'variable' Tensor.
Definition
CircleVariable.h:32
luci::GraphBuilderContext
Class to store context to build loco graph IR from TensorFlow.
Definition
GraphBuilderContext.h:70
luci::GraphBuilderContext::graph
loco::Graph * graph()
Definition
GraphBuilderContext.h:84
luci::GraphBuilderContext::reader
CircleReader * reader()
Definition
GraphBuilderContext.h:85
luci::VectorWrapper
Wrapper to use flatbuffers::Vector pointer as std::vector entity.
Definition
CircleReader.h:62
CircleVariable.h
CircleVariable.h
Log.h
luci
Definition
CircleModel.h:27
luci::copy_tensor_attributes
void copy_tensor_attributes(const circle::Tensor *tensor, CircleNode *node)
Copy common tensor attributes such as name, type, etc. to node.
Definition
CircleReader.cpp:292
luci::create_circlevariable
CircleVariable * create_circlevariable(GraphBuilderContext *context, int32_t tensor_index)
Definition
CircleVariable.cpp:48
luci::must_cast
T must_cast(loco::Node *node)
Definition
CircleNodeDecl.h:95
luci::wrap
VectorWrapper< T > wrap(const flatbuffers::Vector< T > *vec)
Definition
CircleReader.h:84
luci::ShapeStatus::VALID
@ VALID
compiler
luci
import
src
Nodes
CircleVariable.cpp
Generated by
1.9.8