71{
72 assert(context != nullptr);
73
75 SymbolTable *tensor_names = context->tensor_names();
76 UpdateQueue *updates = context->updates();
77
78
80 {
81 call_node->
op(tf_node.op());
82 call_node->name(tf_node.name());
83 call_node->dtype(_signature->
dtype(tf_node.name()));
84
85 auto shape = _signature->
shape(tf_node.name());
86 call_node->rank(shape->rank());
87 for (int d = 0; d < shape->rank(); d++)
88 call_node->dim(d) = shape->dim(d);
89
90 for (auto iter = tf_node.attr().begin(); iter != tf_node.attr().end(); iter++)
91 {
92 auto name = iter->first;
93 auto val = iter->second;
94
95 if (val.value_case() == tensorflow::AttrValue::kF)
96 {
97 call_node->attr(name, std::make_unique<locoex::COpAttrFloat>(val.f()));
98 }
99 else if (val.value_case() == tensorflow::AttrValue::kI)
100 {
101 call_node->attr(name, std::make_unique<locoex::COpAttrInt>(val.i()));
102 }
103
104 else
105 {
106 throw oops::UserExn(
"Unsupported attribute type", tf_node.name());
107 }
108 }
109 }
110
111
113 tensor_names->enroll(output_name, call_node);
114
115
116 std::vector<TensorName> input_names;
117 for (int i = 0; i < tf_node.input_size(); ++i)
118 {
119 input_names.emplace_back(
TensorName(tf_node.input(i)));
120 }
121 auto update = std::make_unique<COpCallGraphUpdate>(call_node, input_names);
122 updates->enroll(std::move(
update));
123}
Class to calls custom operation.
void op(const std::string &op)
FeatureShapeUpdater update(loco::FeatureShape &feature_shape)
void dtype(const std::string &node_name, loco::DataType dtype)
Adds node name and its dtype provided from user.
void shape(const std::string &node_name, const angkor::TensorShape &shape)
Adds node name and its shape provided from user.