// Instantiate the CLFullyConnectedLayer object.
auto layer = genLayer("arm_compute::CLFullyConnectedLayer", operation_name,
{AF::ref(in), AF::ref(weights), AF::lit("nullptr"), AF::ref(out)});
+
addToPersistentTensors(weights);
// Serialize the weights tensor and generate the function to deserialize it in the artifact.
serializeTensor(weights, ir_weights);
auto layer = genLayer("arm_compute::CLArithmeticAddition", layer_name,
{AF::ref(transposed_input), AF::ref(biases), AF::ref(transposed_output),
AF::lit("arm_compute::ConvertPolicy::WRAP")});
+
addToPersistentTensors(biases);
// Save the IR biases tensor to later read this in the artifact.
serializeTensor(biases, ir_biases);
addToPersistentTensors(tensor);
}
-void AclCppOpGenerator::visit(ops::ConstantOp& op) {
- Shape out_shape = op.getOutputShape(0);
- TensorVariant data = op.getValue();
+// FIXME: temporary decision
+static bool shouldSerializeConstant(ops::ConstantOp& op) {
+ // Operations from 'self_serializing_ops_to_inputs' serializing tensors with appropriate index themselves,
+ // so we don't serialize them here, also we don't serialize tensors from dangling ConstantOp
+ static std::map<Operation::Type, int> self_serializing_ops_to_inputs{
+ {Operation::Type::scale, 1},
+ {Operation::Type::conv2D, 1},
+ {Operation::Type::fullyConnected, 1},
+ {Operation::Type::biasAdd, 1}};
+
+ for (auto& next_node : op.getNextNodes()) {
+ auto self_serializing_op_it = self_serializing_ops_to_inputs.find(next_node->getType());
+ // Serialize if next_node type not from 'self_serializing_ops_to_inputs'
+ if (self_serializing_op_it == self_serializing_ops_to_inputs.end())
+ return true;
+
+ // If next_node has current ConstantOp as it's previous node, but not with appropriate index -
+ // serialize current ConstantOp
+ int serializing_input_index = self_serializing_op_it->second;
+ auto next_node_prev_nodes = static_cast<int>(next_node->getPrevNodes().size());
+ for (int i = 0; i < next_node_prev_nodes; ++i) {
+ if (next_node->getPrevNodes()[i].op == &op && i != serializing_input_index)
+ return true;
+ }
+ }
- shared_ptr<ArtifactId> out = genTensor(op, out_shape);
+ return false;
+}
- addToPersistentTensors(out);
- // Serialize the weights tensor and generate the function to deserialize it in the artifact.
- serializeTensor(out, data);
+void AclCppOpGenerator::visit(ops::ConstantOp& op) {
+ if (shouldSerializeConstant(op)) {
+ Shape out_shape = op.getOutputShape(0);
+ TensorVariant data = op.getValue();
+ shared_ptr<ArtifactId> out = genTensor(op, out_shape);
+ addToPersistentTensors(out);
+ serializeTensor(out, data);
+ }
}
void AclCppOpGenerator::visit(ops::ReluOp& op) {
auto layer2 = genLayer("arm_compute::CLArithmeticDivision",
operation_name + "_arithmetic_div_layer_2",
{AF::ref(transposed_input), AF::ref(tmp), AF::ref(transposed_output)});
+
addToPersistentTensors(scales);
// Save the IR scales tensor to later read this in the artifact.
serializeTensor(scales, ir_scales);
// Create the convolution (/depthwise convolution/deconvolution) layer class instance.
shared_ptr<ArtifactId> layer = genLayer(acl_func_name, operation_name, config_params);
- addToPersistentTensors(weights);
+ addToPersistentTensors(weights);
// Save the IR weights tensor to later read this in the artifact.
serializeTensor(weights, ir_weights);
genTensorAllocation(_infBlock, transposed_output);
}
void AclCppOpGenerator::genDeserializations() {
- for (auto s : _serializations)
- _constrBlock->call("deserializeTensor", {_parIn, s});
+ for (auto& tensor : _serializations)
+ _constrBlock->call("deserializeTensor", {_parIn, tensor});
}
void AclCppOpGenerator::genFillings() {
}
void AclCppOpGenerator::genPersistentTensorAllocations() {
- for (shared_ptr<ArtifactId> tensor: _persistent_tensors)
+ for (auto& tensor : _persistent_tensors)
genTensorAllocation(_constrBlock, tensor);
}