#include <cstdint>
#include <memory>
+#include <set>
#include "core/modelIR/Shape.h"
#include "core/modelIR/TensorVariant.h"
*/
mir::TensorVariant fixGroupedKernel(int groups, const mir::TensorVariant& folded_kernel);
+/** Throws PassException if problems set is not empty
+ *
+ * @param problemsSet - set of strings describing incorrect parts of the network
+ * and parts of the network unsupported by NNC
+ * @throws PassException with appropriate message
+ */
+void handleProblemSet(const std::set<std::string>& problemsSet);
+
} // namespace nnc
#endif // FRONTEND_COMMON_OP_CREATOR_HELPER_H_
#include <cassert>
#include "caffe2_importer.h"
+#include "passes/common_frontend/op_creator_helper.h"
#include "passes/common_frontend/shape_helper.h"
#include "support/ProtobufHelper.h"
for (auto& op : _net->op())
collectUnsupportedOp(op);
- if (!_problemsOpSet.empty()) {
- std::string msg("Detected problems:\n");
- for (const auto& problemStr : _problemsOpSet)
- msg.append(problemStr + "\n");
- throw PassException(msg);
- }
+ handleProblemSet(_problemsOpSet);
}
void Caffe2Importer::collectUnsupportedOp(const OperatorDef& op) {
std::vector<mir::Shape> _inputShapes;
static const std::map<std::string, SupportedCaffe2OpType> _operatorTypes;
+ // set of strings describing incorrect parts of network and parts of network unsupported by NNC
std::set<std::string> _problemsOpSet;
// This map maps caffe2 operators names to MIR operators
#include "core/modelIR/TensorUtil.h"
#include "pass/PassException.h"
+#include "passes/common_frontend/op_creator_helper.h"
#include "passes/common_frontend/shape_helper.h"
#include "support/ProtobufHelper.h"
for (int i = 0; i < _net->layer_size(); ++i)
collectUnsupportedOp(_net->layer(i));
- if (!_problemsOpSet.empty()) {
- std::string msg("Detected problems:\n");
- for (const auto& problemStr : _problemsOpSet)
- msg.append(problemStr + "\n");
- throw PassException(msg);
- }
+ handleProblemSet(_problemsOpSet);
}
void CaffeImporter::createMIRNodesFromLayer(const LayerParameter& layer) {
std::map<std::string, mir::IODescriptor> _blobNameToIODescriptor;
static const std::map<std::string, CaffeOpType> _operatorTypes;
+ // set of strings describing incorrect parts of network and parts of network unsupported by NNC
std::set<std::string> _problemsOpSet;
/**
* limitations under the License.
*/
+#include "pass/PassException.h"
#include "passes/common_frontend/op_creator_helper.h"
#include "core/modelIR/Shape.h"
#include "core/modelIR/ShapeRange.h"
#include "core/modelIR/TensorVariant.h"
+#include <set>
+
namespace nnc {
using namespace mir;
return unfold_kernel;
}
+void handleProblemSet(const std::set<std::string>& problemsSet) {
+ if (!problemsSet.empty()) {
+ std::string msg("NNC can't load model. Detected problems:");
+ for (const auto& problem_str : problemsSet)
+ msg.append("\n * " + problem_str);
+ throw PassException(msg);
+ }
+}
+
} // namespace nnc
\ No newline at end of file
#include "tflite_importer.h"
#include "core/modelIR/operations/ElementwiseOp.h"
#include "tflite_op_creator.h"
+#include "passes/common_frontend/op_creator_helper.h"
using namespace ::tflite;
for (auto op: *(sub_graph->operators()))
processUnsupportedOp(op);
- if (!_problemsOpSet.empty()) {
- std::string msg("Detected problems:\n");
- for (const auto& problem_str : _problemsOpSet)
- msg.append(problem_str + "\n");
- throw PassException(msg);
- }
+ handleProblemSet(_problemsOpSet);
}
void TfliteImporter::processUnsupportedOp(const Operator* op) {
// This map maps indices of TFLite tensors to MIR operations/nodes
// that correspond to operations having these tensors as output.
std::map<int, mir::Operation*> _opsForTensorsTheyOutput;
-
+ // set of strings describing incorrect parts of network and parts of network unsupported by NNC
std::set<std::string> _problemsOpSet;
/**
#include <string>
#include <iostream>
-const char *ErrorMsg = "Detected problems:\n"
- "Sin: unknown layer\n";
+const char *ErrorMsg = "NNC can't load model. Detected problems:\n"
+ " * Sin: unknown layer";
// When adding support for new layers, change the model, not the test
TEST(CAFFE_IMPORT_UNSUPPORTED, ImportAModelWithUnsupportedLayers) {
#include <string>
#include <iostream>
-const char *ErrorMsg = "Detected problems:\n"
- "DummyData: unsupported layer\n"
- "LSTM: parameter 'expose_hidden' has unsupported value: 1\n"
- "UnexcitingLayerType: unknown layer\n";
+
+const char *ErrorMsg = "NNC can't load model. Detected problems:\n"
+ " * DummyData: unsupported layer\n"
+ " * LSTM: parameter 'expose_hidden' has unsupported value: 1\n"
+ " * UnexcitingLayerType: unknown layer";
// When adding support for new layers, change the model, not the test
TEST(CAFFE_IMPORT_UNSUPPORTED, ImportAModelWithUnsupportedLayers) {
#include <string>
#include <iostream>
-const char *ErrorMsg = "Detected problems:\n"
- "SIN: unsupported operator\n";
+const char *ErrorMsg = "NNC can't load model. Detected problems:\n"
+ " * SIN: unsupported operator";
// When adding support for new layers, change the model, not the test
TEST(TFLITE_IMPORT_UNSUPPORTED, ImportModelWithUnsupportedLayers) {