# add nnc library as target
function(nnc_add_library)
- add_library(${ARGV})
+ add_nncc_library(${ARGV})
get_target_property(LIBS ${NNC_TARGET_EXECUTABLE} LINK_LIBRARIES)
if(LIBS MATCHES NOTFOUND)
set(SERIALIZER_SOURCES "modelIR/Serializer.cpp"
"modelIR/Deserializer.cpp")
- add_library(nnc_core SHARED ${SOURCES} ${SERIALIZER_SOURCES})
+ add_nncc_library(nnc_core SHARED ${SOURCES} ${SERIALIZER_SOURCES})
target_link_libraries(nnc_core PUBLIC model_ir_proto)
else()
message(WARNING "Protobuf not found, NNC serialization not available")
- add_library(nnc_core SHARED ${SOURCES})
+ add_nncc_library(nnc_core SHARED ${SOURCES})
endif()
set_target_properties(nnc_core PROPERTIES LINKER_LANGUAGE CXX)
return 4;
case DTYPE::INT64:
return 8;
+ default:
+ assert(false);
}
}
/**
*/
template<typename T>
T get() const {
- assert(sizeof(T) <= getDataSize());
+ assert(static_cast<int>(sizeof(T)) <= getDataSize());
T result;
memcpy(&result, _data, sizeof(T));
return result;
namespace nnc {
-class TensorDescription;
+struct TensorDescription;
/**
* @brief CPPCodeGenerator implements interfaces that provides BaseCodeGenerator for C++ language
"arm_compute::DataLayoutDimension::WIDTH"};
int axis = op.getAxis();
- assert(axis >= 0 && axis < sizeof(axis_names) / sizeof(axis_names[0]) &&
+ assert(axis >= 0 && axis < static_cast<int>(sizeof(axis_names) / sizeof(axis_names[0])) &&
"axis outside this range is not supported in ACL");
const char* axis_name = axis_names[axis];
genLayerExecution(layer);
}
-void AclCppOpGenerator::visit(ops::GemmOp& op) {
+void AclCppOpGenerator::visit(ops::GemmOp&) {
assert(false);
}
_outputs.insert(&op);
}
-void AclCppOpGenerator::visit(mir::ops::SliceOp& op) {
+void AclCppOpGenerator::visit(mir::ops::SliceOp&) {
throw AclCppException( "Unimplemented operation: SliceOp");
}
-void AclCppOpGenerator::visit(ops::BatchNormOp& op) {
+void AclCppOpGenerator::visit(ops::BatchNormOp&) {
// Not supported in our framework, but present in ACL API.
throw AclCppException("Not supported in inference yet.");
}
genConvolution(op, "arm_compute::CLDeconvolutionLayer", "_deconvolution_layer");
}
-void AclCppOpGenerator::visit(ops::EluOp& op) {
+void AclCppOpGenerator::visit(ops::EluOp&) {
throw AclCppException("Not supported by the ACL library yet.");
}
-void AclCppOpGenerator::visit(ops::PadOp& op) {
+void AclCppOpGenerator::visit(ops::PadOp&) {
throw AclCppException("Not supported by the ACL library yet.");
}
const string& name, const vector <T>& init) {
list<shared_ptr<ArtifactExpr>> dims;
- for (int i = 0; i < init.size(); ++i)
- dims.push_back(AF::lit(to_string(init[i])));
+ for (const auto& v : init)
+ dims.push_back(AF::lit(to_string(v)));
auto shape_var = block->var(type, name, {}, dims);
auto shape_id = shape_var->use();
_fillings.push_back(make_pair(tensor_id, val));
}
-void AclCppOpGenerator::visit(ops::SqueezeOp& op) {
+void AclCppOpGenerator::visit(ops::SqueezeOp&) {
throw AclCppException("Unimplemented operation: Squeeze");
}
-void AclCppOpGenerator::visit(ops::SqrtOp& op) {
+void AclCppOpGenerator::visit(ops::SqrtOp&) {
throw AclCppException("Unimplemented operation: Sqrt");
}
_infBlock->call("run", {}, layer_id);
}
-void AclCppOpGenerator::visit(mir::ops::ResizeOp& op) {
+void AclCppOpGenerator::visit(mir::ops::ResizeOp&) {
throw AclCppException("Unimplemented operation: Resize");
}
-void AclCppOpGenerator::visit(mir::ops::ReduceFOp& op) {
+void AclCppOpGenerator::visit(mir::ops::ReduceFOp&) {
throw AclCppException("Unimplemented operation: ReduceFOp");
}
genTranspose(input, output, mir_axis_order, false);
}
-void AclCppOpGenerator::visit(mir::ops::GatherOp& op) {
+void AclCppOpGenerator::visit(mir::ops::GatherOp&) {
throw AclCppException("Unimplemented operation: GatherOp");
}
node->expr()->accept(this);
}
-void ArtifactGeneratorCppCode::visit(const ArtifactBreak* node) {
+void ArtifactGeneratorCppCode::visit(const ArtifactBreak*) {
_out << "break";
}
-void ArtifactGeneratorCppCode::visit(const ArtifactCont* node) {
+void ArtifactGeneratorCppCode::visit(const ArtifactCont*) {
_out << "continue";
}
}
}
-void ArtifactGeneratorCppCode::visit(const ArtifactFunction* node) {
+void ArtifactGeneratorCppCode::visit(const ArtifactFunction*) {
// TODO implement this function
}
_out << node->typeName() << " " << node->name();
}
-void ArtifactGeneratorCppDecl::visit(const ArtifactFunctionCall* node) {
+void ArtifactGeneratorCppDecl::visit(const ArtifactFunctionCall*) {
}
-void ArtifactGeneratorCppDecl::visit(const ArtifactUnaryExpr* node) {
+void ArtifactGeneratorCppDecl::visit(const ArtifactUnaryExpr*) {
}
-void ArtifactGeneratorCppDecl::visit(const ArtifactBinaryExpr* node) {
+void ArtifactGeneratorCppDecl::visit(const ArtifactBinaryExpr*) {
}
-void ArtifactGeneratorCppDecl::visit(const ArtifactIndex* node) {
+void ArtifactGeneratorCppDecl::visit(const ArtifactIndex*) {
}
-void ArtifactGeneratorCppDecl::visit(const ArtifactRet* node) {
+void ArtifactGeneratorCppDecl::visit(const ArtifactRet*) {
}
-void ArtifactGeneratorCppDecl::visit(const ArtifactBreak* node) {
+void ArtifactGeneratorCppDecl::visit(const ArtifactBreak*) {
}
-void ArtifactGeneratorCppDecl::visit(const ArtifactCont* node) {
+void ArtifactGeneratorCppDecl::visit(const ArtifactCont*) {
}
-void ArtifactGeneratorCppDecl::visit(const ArtifactBlock* node) {
+void ArtifactGeneratorCppDecl::visit(const ArtifactBlock*) {
}
-void ArtifactGeneratorCppDecl::visit(const ArtifactForLoop* node) {
+void ArtifactGeneratorCppDecl::visit(const ArtifactForLoop*) {
}
-void ArtifactGeneratorCppDecl::visit(const ArtifactIf* node) {
+void ArtifactGeneratorCppDecl::visit(const ArtifactIf*) {
}
void ArtifactGeneratorCppDecl::visit(const ArtifactFunction* node) {
void NNInterpreter::visit(ops::TanhOp& op) {
auto operand = op.getPrevNodes()[0];
Tensor<float> input(var(operand.op->getId())[operand.index]);
- var(op.getId()) = Fill<float>(op.getOutputShape(0), [&input, &op](const Index &id) {
+ var(op.getId()) = Fill<float>(op.getOutputShape(0), [&input](const Index &id) {
return std::tanh(input.at(id));
})();
}
op.getOutputShape(0), input, op.getReductionDims(), func)();
Tensor<float> out_t = Tensor<float>(var(op.getId())[0]); // for numerical stability
var(op.getId()) = Fill<float>(op.getOutputShape(0),
- [&out_t, &op, reduction_area](const Index& id) {
+ [&out_t, reduction_area](const Index& id) {
return out_t.at(id) / reduction_area;
})();
}
int is_error = fseek(f, 0L, SEEK_END);
assert(!is_error);
- auto len = static_cast<size_t>(ftell(f));
+ auto len = ftell(f);
assert(len != -1);
auto data_size = static_cast<size_t>(shape.numElements() * sizeof(float));
// Check size
- if (len != data_size) {
+ if (static_cast<size_t>(len) != data_size) {
std::stringstream info;
info << "Wrong input file size <" << cli::interInputData << "> = "
<< len << ". Should be :" << data_size;
std::vector<mir::TensorVariant> BiasAdd::operator()() {
return Fill<float>(_input1.getShape(), [this](const mir::Index& idx) {
- return _input1.at(idx) + _input2.atOffset({idx.at(idx.rank() - 1)});
+ return _input1.at(idx) + _input2.atOffset(idx.at(idx.rank() - 1));
})();
}
std::vector<TensorVariant> Gather::operator()() {
const auto& data_shape = _data.getShape();
const auto& indices_shape = _indices.getShape();
- const auto& output_shape = _op.getOutputShape(0);
auto res = allocate_tensor(_op.getOutputShape(0));
Tensor<float> data(_data);
Tensor<float> indices(_indices);
auto out = OperationImpl<T>::allocate_tensor(_output_shape);
- mir::Tensor<float> outAccessor(out);
// Shapes element count compared in Reshape ctor
return Fill<T>(_output_shape, [this, &inIter](const mir::Index&) -> T { return _input.at(*inIter++); })();
}
std::vector<mir::TensorVariant> Scale::operator()() {
return Fill<float>(_input1.getShape(), [this](const mir::Index& idx) {
- return _input1.at(idx) * _input2.atOffset({idx.at(idx.rank() - 1)});
+ return _input1.at(idx) * _input2.atOffset(idx.at(idx.rank() - 1));
})();
}
using namespace std;
-namespace nnc
-{
+namespace nnc {
-void CCodeGenerator::formatTensorNames(const ModelAnalyzer &ma)
-{
+void CCodeGenerator::formatTensorNames(const ModelAnalyzer&) {
// TODO format tensor names according to c backend requirements
}
-void CCodeGenerator::materializeHeader(ostream &out, const ModelAnalyzer &ma)
-{
+void CCodeGenerator::materializeHeader(ostream&, const ModelAnalyzer&) {
// TODO emit C header to out stream
}
-void CCodeGenerator::materializeCode(ostream &out, const ModelAnalyzer &ma, const Serializer &s)
-{
+void CCodeGenerator::materializeCode(ostream&, const ModelAnalyzer&, const Serializer&) {
// TODO emit C code to out stream
}
-Pass &CCodeGenerator::getInstance()
-{
+Pass& CCodeGenerator::getInstance() {
static CCodeGenerator instance;
return instance;
}
return _modelName;
}
- const size_t getMaxTemporarySize() const {
+ size_t getMaxTemporarySize() const {
return _max_temp_size;
}
- const size_t getTempTID() const {
+ size_t getTempTID() const {
return _temp_tensor_id;
}