pytorch/caffe2/core/net_simple.h
Yangqing Jia 9c49bb9ddf Move registry fully to c10 (#12077)
Summary:
This does 6 things:

- add c10/util/Registry.h as the unified registry util
  - cleaned up some APIs such as export condition
- fully remove aten/core/registry.h
- fully remove caffe2/core/registry.h
- remove a bogus aten/registry.h
- unifying all macros
- set up registry testing in c10

Also, an important note that we used to mark the templated Registry class as EXPORT - this should not happen, because one should almost never export a template class. This PR fixes that.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12077

Reviewed By: ezyang

Differential Revision: D10050771

Pulled By: Yangqing

fbshipit-source-id: 417b249b49fed6a67956e7c6b6d22374bcee24cf
2018-09-27 03:09:54 -07:00

57 lines
1.4 KiB
C++

#ifndef CAFFE2_CORE_NET_SIMPLE_H_
#define CAFFE2_CORE_NET_SIMPLE_H_
#include <vector>
#include "c10/util/Registry.h"
#include "caffe2/core/common.h"
#include "caffe2/core/logging.h"
#include "caffe2/core/net.h"
#include "caffe2/core/tensor.h"
#include "caffe2/core/workspace.h"
#include "caffe2/proto/caffe2_pb.h"
namespace caffe2 {
// This is the very basic structure you need to run a network - all it
// does is simply to run everything in sequence. If you want more fancy control
// such as a DAG-like execution, check out other better net implementations.
class CAFFE2_API SimpleNet : public NetBase {
public:
SimpleNet(const std::shared_ptr<const NetDef>& net_def, Workspace* ws);
bool SupportsAsync() override {
return false;
}
vector<float> TEST_Benchmark(
const int warmup_runs,
const int main_runs,
const bool run_individual) override;
/*
* This returns a list of pointers to objects stored in unique_ptrs.
* Used by Observers.
*
* Think carefully before using.
*/
vector<OperatorBase*> GetOperators() const override {
vector<OperatorBase*> op_list;
for (auto& op : operators_) {
op_list.push_back(op.get());
}
return op_list;
}
protected:
bool Run() override;
bool RunAsync() override;
vector<unique_ptr<OperatorBase>> operators_;
C10_DISABLE_COPY_AND_ASSIGN(SimpleNet);
};
} // namespace caffe2
#endif // CAFFE2_CORE_NET_SIMPLE_H_