未验证 提交 9ae1e645 编写于 作者: 石晓伟 提交者: GitHub

print not impl info in base classes, test=develop (#3905)

上级 8a24a31c
......@@ -17,6 +17,7 @@
#include <cstdint>
#include <string>
#include <vector>
#include "lite/utils/cp_logging.h"
namespace paddle {
namespace lite {
......@@ -46,11 +47,11 @@ class BlockDescReadAPI {
class BlockDescWriteAPI {
public:
virtual void SetIdx(int32_t idx) = 0;
virtual void SetParentIdx(int32_t idx) = 0;
virtual void ClearVars() = 0;
virtual void ClearOps() = 0;
virtual void SetForwardBlockIdx(int32_t idx) = 0;
virtual void SetIdx(int32_t idx) { NotImplemented(); }
virtual void SetParentIdx(int32_t idx) { NotImplemented(); }
virtual void ClearVars() { NotImplemented(); }
virtual void ClearOps() { NotImplemented(); }
virtual void SetForwardBlockIdx(int32_t idx) { NotImplemented(); }
template <typename T>
T* AddVar();
......@@ -59,6 +60,11 @@ class BlockDescWriteAPI {
T* AddOp();
virtual ~BlockDescWriteAPI() = default;
private:
void NotImplemented() {
LOG(FATAL) << "BlockDescWriteAPI is not available in model read-only mode.";
}
};
// The reading and writing of the model are one-time and separate.
......
......@@ -16,6 +16,7 @@
#include <string>
#include <vector>
#include "lite/model_parser/base/traits.h"
#include "lite/utils/cp_logging.h"
#include "lite/utils/string.h"
namespace paddle {
......@@ -61,16 +62,25 @@ class OpDescReadAPI {
class OpDescWriteAPI {
public:
virtual void SetType(const std::string& type) = 0;
virtual void SetType(const std::string& type) { NotImplemented(); }
virtual void SetInput(const std::string& param,
const std::vector<std::string>& args) = 0;
const std::vector<std::string>& args) {
NotImplemented();
}
virtual void SetOutput(const std::string& param,
const std::vector<std::string>& args) = 0;
const std::vector<std::string>& args) {
NotImplemented();
}
template <typename T>
void SetAttr(const std::string& name, const T& v);
virtual ~OpDescWriteAPI() = default;
private:
void NotImplemented() {
LOG(FATAL) << "OpDescWriteAPI is not available in model read-only mode.";
}
};
// The reading and writing of the model are one-time and separate.
......
......@@ -14,6 +14,8 @@
#pragma once
#include "lite/utils/cp_logging.h"
namespace paddle {
namespace lite {
......@@ -34,13 +36,19 @@ class ProgramDescReadAPI {
class ProgramDescWriteAPI {
public:
virtual void ClearBlocks() = 0;
virtual void SetVersion(int64_t version) = 0;
virtual void ClearBlocks() { NotImplemented(); }
virtual void SetVersion(int64_t version) { NotImplemented(); }
template <typename T>
T* AddBlock();
virtual ~ProgramDescWriteAPI() = default;
private:
void NotImplemented() {
LOG(FATAL)
<< "ProgramDescWriteAPI is not available in model read-only mode.";
}
};
// The reading and writing of the model are one-time and separate.
......
......@@ -16,6 +16,7 @@
#include <string>
#include <vector>
#include "lite/utils/cp_logging.h"
namespace paddle {
namespace lite {
......@@ -62,11 +63,16 @@ class VarDescReadAPI {
class VarDescWriteAPI {
public:
virtual void SetName(std::string name) = 0;
virtual void SetType(VarDataType type) = 0;
virtual void SetPersistable(bool persistable) = 0;
virtual void SetShape(const std::vector<int64_t>& dims) = 0;
virtual void SetName(std::string name) { NotImplemented(); }
virtual void SetType(VarDataType type) { NotImplemented(); }
virtual void SetPersistable(bool persistable) { NotImplemented(); }
virtual void SetShape(const std::vector<int64_t>& dims) { NotImplemented(); }
virtual ~VarDescWriteAPI() = default;
private:
void NotImplemented() {
LOG(FATAL) << "VarDescWriteAPI is not available in model read-only mode.";
}
};
// The reading and writing of the model are one-time and separate.
......
......@@ -22,7 +22,7 @@ namespace paddle {
namespace lite {
namespace fbs {
class BlockDesc : public BlockDescReadAPI {
class BlockDesc : public BlockDescAPI {
public:
explicit BlockDesc(proto::BlockDesc* desc) : desc_(desc) { CHECK(desc_); }
......
......@@ -27,7 +27,7 @@ namespace paddle {
namespace lite {
namespace fbs {
class OpDesc : public OpDescReadAPI {
class OpDesc : public OpDescAPI {
public:
explicit OpDesc(proto::OpDesc* desc) : desc_(desc) { CHECK(desc_); }
......
......@@ -23,7 +23,7 @@ namespace paddle {
namespace lite {
namespace fbs {
class ProgramDesc : public ProgramDescReadAPI {
class ProgramDesc : public ProgramDescAPI {
public:
explicit ProgramDesc(proto::ProgramDesc *desc) : desc_(desc) { CHECK(desc); }
......
......@@ -25,7 +25,7 @@ namespace paddle {
namespace lite {
namespace fbs {
class VarDesc : public VarDescReadAPI {
class VarDesc : public VarDescAPI {
public:
explicit VarDesc(proto::VarDesc* desc) : desc_(desc) {}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册