#include "pass/PassData.h"
-#include "passes/caffe_frontend/CaffeFrontend.h"
-#include "passes/tflite_frontend/TfliteFrontend.h"
+#include "passes/caffe_frontend/caffe_importer.h"
+#include "passes/tflite_frontend/tflite_importer.h"
#include "passes/interpreter/InterpreterPass.h"
#include "passes/soft_backend/CPPGenerator.h"
#include "passes/acl_soft_backend/AclCppGenerator.h"
pass_data = pass->run(pass_data);
}
+ // NOTE. Now we destroy data of all passes when PassManager is destroyed.
+ // In future to reduce memory consumption we can destory it when passes are being performed
+
} // runPasses
/**
if (cli::caffeFrontend) {
#ifdef NNC_FRONTEND_CAFFE_ENABLED
- pass = std::move(std::unique_ptr<Pass>(new CaffeFrontend()));
+ pass = std::move(std::unique_ptr<Pass>(new CaffeImporter(cli::inputFile)));
#endif // NNC_FRONTEND_CAFFE_ENABLED
} else if (cli::tflFrontend) {
#ifdef NNC_FRONTEND_TFLITE_ENABLED
- pass = std::move(std::unique_ptr<Pass>(new TFLiteFrontend()));
+ pass = std::move(std::unique_ptr<Pass>(new TfliteImporter(cli::inputFile)));
#endif // NNC_FRONTEND_TFLITE_ENABLED
} else {
throw DriverException("one of the following options must be defined: '"
#include "support/CommandLine.h"
#include "option/Options.h"
-#include "caffe_importer.h"
+#include "passes/caffe_frontend/caffe_importer.h"
#include "core/modelIR/graph.h"
#include "core/modelIR/IrDotDumper.h"
#include "core/modelIR/ShapeInference.h"
#include "support/CommandLine.h"
#include "pass/PassException.h"
#include "option/Options.h"
-#include "tflite_importer.h"
+#include "passes/tflite_frontend/tflite_importer.h"
#include "core/modelIR/graph.h"
#include "core/modelIR/IrDotDumper.h"
#include "core/modelIR/ShapeInference.h"
*/
virtual PassData run(PassData data) = 0;
+ /**
+ * @brief clean compiler pass data
+ */
+ virtual void cleanup() {};
+
virtual ~Pass() = default;
};
class PassData
{
public:
- PassData(const PassData &) = default;
-
PassData(std::nullptr_t data) { _dataContainer.unknown = data; _dataType = PDT::UNKNOWN; }
/**
* @brief Implicit conversion from Graph* to PassData
*/
/* implicit */ PassData(mir::Graph *graph) { _dataContainer.graph = graph; _dataType = PDT::GRAPH; }
+
/**
* @brief Implicit conversion from PassData to Graph*
*/
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef NNCC_CAFFEFRONTEND_H
-#define NNCC_CAFFEFRONTEND_H
-
-#include "pass/Pass.h"
-#include "pass/PassData.h"
-
-
-namespace nnc {
-
-/**
- * @brief class represent frontend of caffe NN framework
- */
-class CaffeFrontend : public Pass {
-public:
- PassData run(PassData) override;
-
-};
-
-} // namespace nnc
-
-#endif //NNCC_CAFFEFRONTEND_H
#include "caffe/proto/caffe.pb.h"
#include "passes/common_frontend/nn_importer.h"
+/// @todo caffe_op_creator.h and caffe_op_types.h aren't interface files.
+/// We need to remove them and use here forward declarations
#include "caffe_op_creator.h"
#include "caffe_op_types.h"
+#include "pass/Pass.h"
+#include "pass/PassData.h"
+
namespace nnc {
-class CaffeImporter : public NNImporter {
+class CaffeImporter : public NNImporter, public Pass {
public:
explicit CaffeImporter(std::string filename) : _modelFilename(std::move(filename)),
_graph(new mir::Graph()),
*/
Graph* createIR() override;
+ PassData run(PassData) override;
+ void cleanup() override;
+
private:
std::string _modelFilename;
std::unique_ptr<::caffe::NetParameter> _net;
mir::Graph* _graph;
- OpCreator _opCreator;
+ CaffeOpCreator _opCreator;
std::vector<mir::Shape> _inputShapes;
using IrTensor = nnc::mir::TensorVariant;
using nnc::mir::Shape;
-class OpCreator {
+class CaffeOpCreator {
public:
using InputOps = std::vector<INode::Ref>&;
using InputParams = std::vector<std::shared_ptr<IrTensor>>&;
- explicit OpCreator(Graph* g) : graph(g) {};
+ explicit CaffeOpCreator(Graph* g) : graph(g) {};
std::vector<INode::Ref> createConv2D(InputOps, InputParams,
const ::caffe::ConvolutionParameter&);
};
template <typename OpType, typename ...Types>
-std::vector<INode::Ref> OpCreator::createOp(std::vector<INode::Ref>& inputs, Types&& ... args) {
+std::vector<INode::Ref> CaffeOpCreator::createOp(std::vector<INode::Ref>& inputs, Types&& ... args) {
std::vector<INode::Ref> outputs;
// TODO: set operation names
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef NNCC_TFLITEFRONTEND_H
-#define NNCC_TFLITEFRONTEND_H
-
-#include "pass/Pass.h"
-#include "pass/PassData.h"
-
-
-namespace nnc {
-
-/**
- * @brief class represent frontend of tensorflow lite NN framework
- */
-class TFLiteFrontend : public Pass {
-public:
- PassData run(PassData) override;
-
-};
-
-} // namespace nnc
-
-#endif //NNCC_TFLITEFRONTEND_H
#include <string>
#include "schema_generated.h"
+#include "pass/Pass.h"
#include "pass/PassException.h"
+#include "pass/PassData.h"
#include "passes/common_frontend/nn_importer.h"
#include "passes/common_frontend/model_allocation.h"
#include "core/modelIR/TensorUtil.h"
#include "core/modelIR/TensorVariant.h"
+/// @todo tflite_op_creator.h isn't interface file.
+/// We need to remove it and use here forward declarations
#include "tflite_op_creator.h"
namespace nnc {
-class TfliteImporter : NNImporter {
+class TfliteImporter : public NNImporter, public Pass {
public:
explicit TfliteImporter(std::string filename);
void importUnpacked();
+ PassData run(PassData) override;
+ void cleanup() override;
+
private:
std::string _filename;
std::unique_ptr<ModelAllocation> _modelRaw;
const ::tflite::Model* _modelPacked = nullptr;
Graph* _graph = nullptr;
- std::unique_ptr<OpCreator> _opCreator;
+ std::unique_ptr<TFLiteOpCreator> _opCreator;
const flatbuffers::Vector<flatbuffers::Offset<::tflite::OperatorCode>>* _opcodes = nullptr;
const flatbuffers::Vector<flatbuffers::Offset<::tflite::Tensor>>* _tensors = nullptr;
using IrTensor = mir::TensorVariant;
using mir::Shape;
-class OpCreator {
+class TFLiteOpCreator {
public:
using InputOps = std::vector<INode::Ref>&;
using InputParams = std::vector<std::shared_ptr<IrTensor>>&;
- explicit OpCreator(Graph* g) : graph(g) {};
+ explicit TFLiteOpCreator(Graph* g) : graph(g) {};
std::vector<INode::Ref> createConv2D(InputOps, InputParams, const ::tflite::Conv2DOptions*);
};
template<typename OpType, typename... Types>
-std::vector<INode::Ref> OpCreator::createOp(
+std::vector<INode::Ref> TFLiteOpCreator::createOp(
std::vector<INode::Ref>& inputs,
::tflite::ActivationFunctionType activation, Types&& ... args) {
std::vector<INode::Ref> outputs;
PassManager::PassManager() {}
-PassManager::~PassManager() {}
+PassManager::~PassManager() {
+ for (auto &pass : _passes)
+ pass->cleanup();
+}
void PassManager::registerPass(std::unique_ptr<Pass> pass)
{
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <map>
-#include <vector>
-#include <iostream>
-
-#include "option/Options.h"
-#include "pass/PassException.h"
-#include "passes/caffe_frontend/CaffeFrontend.h"
-
-#include "caffe_importer.h"
-
-
-namespace nnc {
-
-PassData CaffeFrontend::run(PassData) {
- CaffeImporter importer{cli::inputFile};
-
- importer.import();
-
- return importer.createIR();
-}
-
-} // namespace nnc
#include <sstream>
#include <cassert>
-#include "caffe_importer.h"
+#include "passes/caffe_frontend/caffe_importer.h"
#include "proto_reader.h"
#include "core/modelIR/Shape.h"
item.second->setName(item.first);
}
+PassData CaffeImporter::run(PassData) {
+ import();
+ return createIR();
+}
+
+void CaffeImporter::cleanup() {
+ delete _graph;
+}
+
const std::map<std::string, CaffeOpType> CaffeImporter::_operatorTypes = {
{"AbsVal", CaffeOpType::absVal},
{"Accuracy", CaffeOpType::accuracy},
#include "passes/common_frontend/shape_helper.h"
#include "pass/PassException.h"
-#include "caffe_op_creator.h"
+#include "passes/caffe_frontend/caffe_op_creator.h"
#include <set>
#include <cmath>
return unfold_kernel;
}
-void OpCreator::checkConv2D(const caffe::ConvolutionParameter& opts,
+void CaffeOpCreator::checkConv2D(const caffe::ConvolutionParameter& opts,
std::set<std::string>& problems_op_set) {
assert(opts.stride_size() <= 2);
problems_op_set.insert("Conv2D: Unsupported number of pads");
}
-std::vector<INode*> OpCreator::createConv2D(InputOps inputs, InputParams params,
+std::vector<INode*> CaffeOpCreator::createConv2D(InputOps inputs, InputParams params,
const caffe::ConvolutionParameter& opts) {
ops::PaddingType pad_type = ops::PaddingType::Custom;
Shape stride_shape = getConvStride(opts);
return outputs;
}
-void OpCreator::checkFullyConnected(const caffe::InnerProductParameter& opts,
+void CaffeOpCreator::checkFullyConnected(const caffe::InnerProductParameter& opts,
std::set<std::string>& problemsOpSet) {
if (opts.has_axis() && opts.axis() != 1)
problemsOpSet.insert("Fully Connected: layer axis param is not supported yet");
* implement it correctly.
* @todo Support axis and transpose parameters as needed.
*/
-std::vector<INode*> OpCreator::createFullyConnected(InputOps& inputs, InputParams& params,
+std::vector<INode*> CaffeOpCreator::createFullyConnected(InputOps& inputs, InputParams& params,
const caffe::InnerProductParameter& opts) {
// Add Reshape operation to make sure the input for FC operation has shape [1, fcInputSize]
// It is needed because Caffe InnerProduct layer takes NCHW input and flattens the CHW part.
return fc_outputs;
}
-std::vector<INode*> OpCreator::createConcat(InputOps inputs, InputParams params,
+std::vector<INode*> CaffeOpCreator::createConcat(InputOps inputs, InputParams params,
const caffe::ConcatParameter& opts) {
(void) params;
return createOp<ops::ConcatOp>(inputs, inputs.size(), getAxisValue(opts));
}
-void OpCreator::checkPool(const caffe::PoolingParameter& opts,
+void CaffeOpCreator::checkPool(const caffe::PoolingParameter& opts,
std::set<std::string>& problemsOpSet) {
if (opts.has_global_pooling() && opts.global_pooling())
problemsOpSet.insert("Pooling: pooling layer global_pooling param is not supported yet");
problemsOpSet.insert("Pooling: conflicting padding properties in pooling");
}
-std::vector<INode*> OpCreator::createPool(InputOps inputs, InputParams params,
+std::vector<INode*> CaffeOpCreator::createPool(InputOps inputs, InputParams params,
const caffe::PoolingParameter& opts) {
(void) params;
return pooling;
}
-std::vector<INode*> OpCreator::createSoftmax(InputOps inputs, InputParams params,
+std::vector<INode*> CaffeOpCreator::createSoftmax(InputOps inputs, InputParams params,
const caffe::SoftmaxParameter& opts) {
(void) params;
return createOp<ops::SoftmaxOp>(inputs, getAxisValue(opts));
}
-void OpCreator::checkReshape(const caffe::ReshapeParameter& opts,
+void CaffeOpCreator::checkReshape(const caffe::ReshapeParameter& opts,
std::set<std::string>& problemsOpSet) {
if (opts.has_axis() || opts.has_num_axes())
problemsOpSet.insert("Reshape layer axis and num_axes params are not supported yet");
* @todo Decide how to react to the absence of "shape" parameter.
* @todo Support zero values in "shape" parameter.
*/
-std::vector<INode*> OpCreator::createReshape(InputOps inputs, InputParams params,
+std::vector<INode*> CaffeOpCreator::createReshape(InputOps inputs, InputParams params,
const caffe::ReshapeParameter& opts) {
(void) params;
return outputs;
}
-void OpCreator::checkRelu(const caffe::ReLUParameter& opts,
+void CaffeOpCreator::checkRelu(const caffe::ReLUParameter& opts,
std::set<std::string>& problems_op_set) {
if (opts.has_negative_slope())
problems_op_set.insert("ReLU layer negative_slope param is not supported yet.");
}
-std::vector<INode*> OpCreator::createRelu(InputOps inputs, InputParams params,
+std::vector<INode*> CaffeOpCreator::createRelu(InputOps inputs, InputParams params,
const caffe::ReLUParameter& opts) {
(void) params;
}
std::vector<INode*>
-OpCreator::createScale(InputOps inputs, InputParams params, const ScaleParameter& opts) {
+CaffeOpCreator::createScale(InputOps inputs, InputParams params, const ScaleParameter& opts) {
auto outputs = createOp<ops::ScaleOp>(inputs, std::move(*params[0]));
// bias_term is optional (so might not be present) and defaults to true
if (!opts.has_bias_term() || opts.bias_term())
return outputs;
}
-void OpCreator::checkBatchNorm(const caffe::BatchNormParameter& opts, InputParams params,
+void CaffeOpCreator::checkBatchNorm(const caffe::BatchNormParameter& opts, InputParams params,
std::set<std::string>& problems_op_set) {
// Check that last blob(with scaleFactor) containing only one number
if (params[2]->getShape().rank() != 1 && params[2]->getShape().dim(0) != 1)
}
std::vector<INode*>
-OpCreator::createBatchNorm(InputOps inputs, InputParams params, const BatchNormParameter& opts) {
+CaffeOpCreator::createBatchNorm(InputOps inputs, InputParams params, const BatchNormParameter& opts) {
const float MAFRAC_DEF = 0.999f;
const float EPS_DEF = 1e-5f;
// optional params may be left out, so we fill them with defalt values (lifted from caffe docs)
}
std::vector<INode*>
-OpCreator::createDropout(InputOps inputs, InputParams params, const DropoutParameter& opts) {
+CaffeOpCreator::createDropout(InputOps inputs, InputParams params, const DropoutParameter& opts) {
(void) params;
const float DROPOUT_RATIO_DEF = 0.5f;
// optional params may be left out, so we fill them with defalt values (lifted from caffe docs)
}
std::vector<INode*>
- OpCreator::createDeconvolution( std::vector<INode*> &inputs,
+ CaffeOpCreator::createDeconvolution( std::vector<INode*> &inputs,
std::vector<std::shared_ptr<IrTensor>> ¶ms,
const ConvolutionParameter &opts) noexcept {
ops::PaddingType pad_type = ops::PaddingType::Custom;
}
std::vector<INode*>
-OpCreator::createELU(std::vector<INode*>& inputs,
+CaffeOpCreator::createELU(std::vector<INode*>& inputs,
std::vector<std::shared_ptr<IrTensor>>& params,
const ELUParameter& opts) noexcept {
const float ELU_ALPHA= 1.0f;
return createOp<ops::EluOp>(inputs, elu_alpha);
}
-std::vector<INode*> OpCreator::createTanh(std::vector<INode*>& inputs,
+std::vector<INode*> CaffeOpCreator::createTanh(std::vector<INode*>& inputs,
std::vector<std::shared_ptr<IrTensor>>&,
const TanHParameter&) noexcept {
return createOp<ops::TanhOp>(inputs);
}
-std::vector<INode*> OpCreator::createEltwise(std::vector<INode*>& inputs,
+std::vector<INode*> CaffeOpCreator::createEltwise(std::vector<INode*>& inputs,
std::vector<std::shared_ptr<IrTensor>>& params,
const EltwiseParameter& opts) noexcept {
(void) params;
}
-void OpCreator::connectInputs(INode* op, InputOps inputs) {
+void CaffeOpCreator::connectInputs(INode* op, InputOps inputs) {
// TODO: this part doesn't support the situation where an operator takes as input
// some tensor that is not the 0th output of some other operator
for (int i = 0; i < static_cast<int>(inputs.size()); ++i)
###################
set(tflite_importer_sources tflite_op_creator.cpp
- tflite_importer.cpp
- tflite_frontend.cpp)
+ tflite_importer.cpp)
file(GLOB tflite_importer_headers *.h)
set(tflite_import tflite_import)
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <map>
-#include <vector>
-#include <iostream>
-
-#include "pass/PassException.h"
-#include "passes/tflite_frontend/TfliteFrontend.h"
-#include "option/Options.h"
-
-#include "tflite_importer.h"
-
-
-namespace nnc {
-
-PassData TFLiteFrontend::run(PassData) {
- TfliteImporter importer{cli::inputFile};
-
- importer.import();
-
- return reinterpret_cast<mir::Graph*>(importer.createIR());
-}
-
-} // namespace nnc
* limitations under the License.
*/
-#include "tflite_importer.h"
-#include "tflite_op_creator.h"
+#include "passes/tflite_frontend/tflite_importer.h"
+#include "passes/tflite_frontend/tflite_op_creator.h"
using namespace ::tflite;
TfliteImporter::TfliteImporter(std::string filename) : _filename(filename) {
_modelRaw.reset(new ModelAllocation{std::move(filename)});
_graph = new Graph();
- _opCreator.reset(new OpCreator(_graph));
+ _opCreator.reset(new TFLiteOpCreator(_graph));
}
void TfliteImporter::importUnpacked() {
item.second->setName((*_tensors)[item.first]->name()->c_str());
}
+
+PassData TfliteImporter::run(PassData) {
+ import();
+ return createIR();
+}
+
+void TfliteImporter ::cleanup() {
+ delete _graph;
+}
+
} // namespace nnc
* limitations under the License.
*/
-#include "tflite_op_creator.h"
+#include "passes/tflite_frontend/tflite_op_creator.h"
#include "schema_generated.h"
#include "core/modelIR/operations/concat_op.h"
namespace nnc {
-void OpCreator::checkConv2D(const Conv2DOptions* opts, std::set<std::string>& problems_op_set) {
+void TFLiteOpCreator::checkConv2D(const Conv2DOptions* opts, std::set<std::string>& problems_op_set) {
checkActivationType(opts->fused_activation_function(), problems_op_set);
}
-std::vector<INode::Ref> OpCreator::createConv2D(InputOps inputs, InputParams params,
+std::vector<INode::Ref> TFLiteOpCreator::createConv2D(InputOps inputs, InputParams params,
const Conv2DOptions* opts) {
auto outputs = createOp<ops::Conv2DOp>(inputs, ActivationFunctionType_NONE, std::move(*params[0]),
Shape{static_cast<int32_t>(opts->stride_h()),
std::move(*params[1]));
}
-void OpCreator::checkDepthConv2D(const DepthwiseConv2DOptions* opts,
+void TFLiteOpCreator::checkDepthConv2D(const DepthwiseConv2DOptions* opts,
std::set<std::string>& problems_op_set) {
checkActivationType(opts->fused_activation_function(), problems_op_set);
}
-std::vector<INode::Ref> OpCreator::createDepthConv2D(InputOps inputs, InputParams params,
+std::vector<INode::Ref> TFLiteOpCreator::createDepthConv2D(InputOps inputs, InputParams params,
const DepthwiseConv2DOptions* opts) {
auto outputs = createOp<ops::DepthwiseConv2DOp>(
inputs, ActivationFunctionType_NONE, std::move(*params[0]),
std::move(*params[1]));
}
-void OpCreator::checkConcat(const ConcatenationOptions* opts,
+void TFLiteOpCreator::checkConcat(const ConcatenationOptions* opts,
std::set<std::string>& problems_op_set) {
checkActivationType(opts->fused_activation_function(), problems_op_set);
}
-std::vector<INode::Ref> OpCreator::createConcat(InputOps inputs, InputParams params,
+std::vector<INode::Ref> TFLiteOpCreator::createConcat(InputOps inputs, InputParams params,
const ConcatenationOptions* opts) {
// Decrementing axis to account for the unnecessary batch dimension
return createOp<ops::ConcatOp>(inputs, opts->fused_activation_function(), inputs.size(),
opts->axis() - 1);
}
-void OpCreator::checkPool(const Pool2DOptions* opts, std::set<std::string>& problems_op_set) {
+void TFLiteOpCreator::checkPool(const Pool2DOptions* opts, std::set<std::string>& problems_op_set) {
checkActivationType(opts->fused_activation_function(), problems_op_set);
}
-std::vector<INode::Ref> OpCreator::createMaxPool(InputOps inputs, InputParams params,
+std::vector<INode::Ref> TFLiteOpCreator::createMaxPool(InputOps inputs, InputParams params,
const Pool2DOptions* opts) {
return createOp<ops::PoolOp>(inputs, opts->fused_activation_function(),
Shape{static_cast<int32_t>(opts->filter_height()),
ops::PoolOp::BorderType::EMPTY);
}
-std::vector<INode::Ref> OpCreator::createAvgPool(InputOps inputs, InputParams params,
+std::vector<INode::Ref> TFLiteOpCreator::createAvgPool(InputOps inputs, InputParams params,
const Pool2DOptions* opts) {
return createOp<ops::PoolOp>(inputs, opts->fused_activation_function(),
Shape{static_cast<int32_t>(opts->filter_height()),
ops::PoolOp::BorderType::EMPTY);
}
-std::vector<INode::Ref> OpCreator::createSoftmax(InputOps inputs, InputParams params,
+std::vector<INode::Ref> TFLiteOpCreator::createSoftmax(InputOps inputs, InputParams params,
const SoftmaxOptions* opts) {
// -1 represents last one dimension
return createOp<ops::SoftmaxOp>(inputs, ActivationFunctionType_NONE, -1);
}
-std::vector<INode::Ref> OpCreator::createReshape(InputOps inputs, InputParams params,
+std::vector<INode::Ref> TFLiteOpCreator::createReshape(InputOps inputs, InputParams params,
const ReshapeOptions* opts) {
auto outputs = createOp<ops::ReshapeOp>(inputs, ActivationFunctionType_NONE);
return outputs;
}
-void OpCreator::checkFullyConnected(const FullyConnectedOptions* opts,
+void TFLiteOpCreator::checkFullyConnected(const FullyConnectedOptions* opts,
std::set<std::string>& problems_op_set) {
checkActivationType(opts->fused_activation_function(), problems_op_set);
}
-std::vector<INode::Ref> OpCreator::createFullyConnected(InputOps& inputs, InputParams& params,
+std::vector<INode::Ref> TFLiteOpCreator::createFullyConnected(InputOps& inputs, InputParams& params,
const FullyConnectedOptions* opts) {
// Add Reshape operation to make sure the input for FC operation has shape [1, fcInputSize]
auto outputs = createOp<ops::ReshapeOp>(inputs, ActivationFunctionType_NONE);
std::move(*params[1]));
}
-void OpCreator::checkActivationType(ActivationFunctionType activation_type,
+void TFLiteOpCreator::checkActivationType(ActivationFunctionType activation_type,
std::set<std::string>& problems_op_set) {
if (activation_type != ActivationFunctionType_NONE
&& activation_type != ActivationFunctionType_RELU
+ EnumNamesActivationFunctionType()[activation_type]);
}
-INode::Ref OpCreator::addFusedActivation(INode::Ref input, ActivationFunctionType activation_type) {
+INode::Ref TFLiteOpCreator::addFusedActivation(INode::Ref input, ActivationFunctionType activation_type) {
INode::Ref activation;
if (activation_type != ActivationFunctionType_NONE) {
}
}
-void OpCreator::connectInputs(INode::Ref op, std::vector<INode::Ref>& inputs) {
+void TFLiteOpCreator::connectInputs(INode::Ref op, std::vector<INode::Ref>& inputs) {
// TODO: this part doesn't support the situation where an operator takes as input
// some tensor that is not the 0th output of some other operator
assert(inputs.size() == op->getOperation()->getNumInputs());
#include "support/CommandLine.h"
#include "option/Options.h"
-#include "caffe_importer.h"
+#include "passes/caffe_frontend/caffe_importer.h"
using namespace nnc;
#include "support/CommandLine.h"
#include "option/Options.h"
-#include "tflite_importer.h"
+#include "passes/tflite_frontend/tflite_importer.h"
using namespace nnc;
-#include "caffe_importer.h"
+#include "passes/caffe_frontend/caffe_importer.h"
#include "gtest/gtest.h"
#include "pass/PassException.h"
#include <string>
}
catch (nnc::PassException &e) {
ASSERT_EQ(std::string(ErrorMsg), e.what());
+ importer.cleanup();
return;
}
-#include "tflite_importer.h"
+#include "passes/tflite_frontend/tflite_importer.h"
#include "gtest/gtest.h"
#include "pass/PassException.h"
#include <string>
}
catch (nnc::PassException &e) {
ASSERT_EQ(std::string(ErrorMsg), e.what());
+ importer.cleanup();
return;
}