173{
176
177
179 const_node->
name(node.name());
180
181
183 const_node->dtype(dtype);
184
185
187 const auto &input_shape = input_tensor.tensor_shape();
188 const auto &input_dims = input_shape.dim();
189 assert(input_shape.dim_size() <= 6);
190 const_node->rank(input_shape.dim_size());
192 bool zero_sized_shape = false;
193 for (auto &d : input_dims)
194 {
195 assert(d.size() <= std::numeric_limits<int>::max());
196 if (d.size() == 0)
197 zero_sized_shape = true;
198
199 assert(d.size() >= 0);
200 const_node->dim(
index++) = d.size();
201 }
202
204 if (zero_sized_shape)
205 {
206 const_node->rank(0);
208 }
209 else
210 {
211 for (uint32_t d = 0; d < const_node->rank(); d++)
212 {
214 }
215 }
216
217 switch (dtype)
218 {
219 case loco::DataType::S8:
220 read_value_int8(const_node, num_elements, input_tensor);
221 break;
222
223 case loco::DataType::S32:
224 read_value_int32(const_node, num_elements, input_tensor);
225 break;
226
227 case loco::DataType::FLOAT32:
228 read_value_float32(const_node, num_elements, input_tensor);
229 break;
230
231
232
233 default:
234 assert(false);
235 }
236
237
239 tensor_names->
enroll(output_name, const_node);
240}
SymbolTable * tensor_names()
Class to store and query loco::Node* with string name key.
void enroll(const TensorName &tensor_name, loco::Node *node)
Registers a name with corresponding loco::Node *.
loco::GraphInputIndex index(const TFPlaceholder *node)
uint32_t num_elements(const Shape &shape)
The number of elements of a feature map of a given shape.
const tensorflow::TensorProto & get_tensor_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
tensorflow::DataType get_datatype_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
loco::DataType as_loco_datatype(const tensorflow::DataType dtype)
NodeName name(void) const