Skip to content
Snippets Groups Projects
Unverified Commit 50b81849 authored by Zhenhua's avatar Zhenhua Committed by GitHub
Browse files

Refactor namespace eager (#4727)


* Rename namespace eager to vm

* Merge the same namespace

* Fix conflict

Co-authored-by: default avataroneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com>
parent 64641785
No related branches found
No related tags found
No related merge requests found
Showing
with 47 additions and 58 deletions
......@@ -33,7 +33,7 @@ limitations under the License.
#include "oneflow/core/eager/eager_blob_object.h"
namespace oneflow {
namespace eager {
namespace vm {
namespace {
......@@ -115,7 +115,7 @@ Maybe<void> LazyReferenceInstructionType::Run(vm::Instruction* instruction) cons
&parallel_ctx, instruction->stream().machine_id(), instruction->stream().device_id()));
Blob* blob = Global<RegstMgr>::Get()->Blob4LbiAndParallelId(GenLogicalBlobId(lbn),
parallel_ctx.parallel_id());
eager_blob_rw->Init<eager::LazyRefBlobObject>(blob);
eager_blob_rw->Init<vm::LazyRefBlobObject>(blob);
return Maybe<void>::Ok();
}
......@@ -158,5 +158,5 @@ class ReadTensorShapeByCallbackInstructionType : public vm::InstructionType {
COMMAND(vm::RegisterInstructionType<ReadTensorShapeByCallbackInstructionType>(
"ReadTensorShapeByCallback"));
} // namespace eager
} // namespace vm
} // namespace oneflow
......@@ -18,7 +18,7 @@ limitations under the License.
#include "oneflow/core/vm/instruction_operand.msg.h"
namespace oneflow {
namespace eager {
namespace vm {
class LazyReferenceInstructionType : public vm::InstructionType {
public:
......@@ -53,5 +53,5 @@ class AccessBlobByCallbackInstructionType : public vm::InstructionType {
}
};
} // namespace eager
} // namespace vm
} // namespace oneflow
......@@ -17,7 +17,7 @@ limitations under the License.
#include "oneflow/core/job/parallel_desc.h"
namespace oneflow {
namespace eager {
namespace vm {
Maybe<void> BlobObject::CheckMemCase(const ParallelDesc& parallel_desc, int64_t machine_id) const {
CHECK_OR_RETURN(parallel_desc.HasMachineId(machine_id))
......@@ -39,5 +39,5 @@ Maybe<void> BlobObject::CheckMemCase(const ParallelDesc& parallel_desc, int64_t
return Maybe<void>::Ok();
}
} // namespace eager
} // namespace vm
} // namespace oneflow
......@@ -24,7 +24,7 @@ namespace oneflow {
class ParallelDesc;
namespace eager {
namespace vm {
class BlobObject : public vm::Object {
public:
......@@ -53,7 +53,7 @@ class BlobObject : public vm::Object {
BlobDesc blob_desc_;
};
} // namespace eager
} // namespace vm
} // namespace oneflow
#endif // ONEFLOW_CORE_EAGER_BLOB_OBJECT_H_
......@@ -17,7 +17,7 @@ limitations under the License.
#include "oneflow/core/vm/cpu_stream_type.h"
namespace oneflow {
namespace eager {
namespace vm {
class CpuLazyReferenceInstructionType : public LazyReferenceInstructionType {
public:
CpuLazyReferenceInstructionType() = default;
......@@ -38,5 +38,5 @@ class CpuAccessBlobByCallbackInstructionType final : public AccessBlobByCallback
COMMAND(vm::RegisterInstructionType<CpuAccessBlobByCallbackInstructionType>(
"cpu.AccessBlobByCallback"));
} // namespace eager
} // namespace vm
} // namespace oneflow
......@@ -26,7 +26,7 @@ limitations under the License.
#include "oneflow/core/vm/object.h"
namespace oneflow {
namespace eager {
namespace vm {
class CpuLocalCallOpKernelInstructionType final : public LocalCallOpKernelInstructionType {
public:
......@@ -116,5 +116,5 @@ class CpuFeedBlobInstructionType final : public FeedBlobInstructionType {
};
COMMAND(vm::RegisterInstructionType<CpuFeedBlobInstructionType>("cpu.FeedBlob"));
} // namespace eager
} // namespace vm
} // namespace oneflow
......@@ -18,7 +18,7 @@ limitations under the License.
#include "oneflow/core/vm/cuda_stream_type.h"
namespace oneflow {
namespace eager {
namespace vm {
class GpuLazyReferenceInstructionType : public LazyReferenceInstructionType {
public:
GpuLazyReferenceInstructionType() = default;
......@@ -37,6 +37,6 @@ class GpuAccessBlobByCallbackInstructionType final : public AccessBlobByCallback
COMMAND(vm::RegisterInstructionType<GpuAccessBlobByCallbackInstructionType>(
"gpu.AccessBlobByCallback"));
} // namespace eager
} // namespace vm
} // namespace oneflow
#endif
......@@ -30,7 +30,7 @@ limitations under the License.
#include "oneflow/core/vm/object.h"
namespace oneflow {
namespace eager {
namespace vm {
class CudaLocalCallOpKernelInstructionType final : public LocalCallOpKernelInstructionType {
public:
......@@ -155,7 +155,7 @@ class GpuFeedBlobInstructionType final : public FeedBlobInstructionType {
};
COMMAND(vm::RegisterInstructionType<GpuFeedBlobInstructionType>("gpu.FeedBlob"));
} // namespace eager
} // namespace vm
} // namespace oneflow
#endif
......@@ -20,7 +20,7 @@ limitations under the License.
#include "oneflow/core/framework/shut_down_util.h"
namespace oneflow {
namespace eager {
namespace vm {
namespace {
Maybe<VmLocalDepObject> GetVmLocalDepObject(
......@@ -92,5 +92,5 @@ Maybe<void> EagerBlobObject::TryAllocateBlobBodyMemory(DeviceCtx* device_ctx) {
return Maybe<void>::Ok();
}
} // namespace eager
} // namespace vm
} // namespace oneflow
......@@ -23,7 +23,7 @@ limitations under the License.
namespace oneflow {
namespace eager {
namespace vm {
class TensorBuffer {
public:
......@@ -79,7 +79,7 @@ class EagerBlobObject final : public BlobObject {
Maybe<VmLocalDepObject> compute_local_dep_object_;
};
} // namespace eager
} // namespace vm
} // namespace oneflow
#endif // ONEFLOW_CORE_EAGER_EAGER_BLOB_OBJECT_H_
syntax = "proto2";
package oneflow.eager;
package oneflow.vm;
import "oneflow/core/vm/instruction.proto";
import "oneflow/core/eager/eager_symbol.proto";
......
......@@ -36,7 +36,7 @@ limitations under the License.
#include "oneflow/core/common/util.h"
namespace oneflow {
namespace eager {
namespace vm {
namespace {
......@@ -77,23 +77,22 @@ Maybe<void> EagerOneflow::RunPhysicalInstruction(
Maybe<void> EagerOneflow::RunPhysicalInstruction(
vm::InstructionMsgList* instruction_list,
const eager::cfg::EagerSymbolList& cfg_eager_symbol_list) {
eager::EagerSymbolList eager_symbol_list;
const vm::cfg::EagerSymbolList& cfg_eager_symbol_list) {
vm::EagerSymbolList eager_symbol_list;
cfg_eager_symbol_list.ToProto(&eager_symbol_list);
return RunPhysicalInstruction(instruction_list, eager_symbol_list);
}
Maybe<void> EagerOneflow::RunPhysicalInstruction(vm::InstructionMsgList* instruction_list,
const eager::EagerSymbolList& eager_symbol_list) {
const vm::EagerSymbolList& eager_symbol_list) {
for (const auto& eager_symbol : eager_symbol_list.eager_symbol()) {
JUST(StorageAdd(eager_symbol));
}
return vm::Run(instruction_list);
}
Maybe<void> EagerOneflow::RunLogicalInstruction(
vm::InstructionMsgList* instruction_list,
const eager::cfg::EagerSymbolList& eager_symbol_list) {
Maybe<void> EagerOneflow::RunLogicalInstruction(vm::InstructionMsgList* instruction_list,
const vm::cfg::EagerSymbolList& eager_symbol_list) {
ClusterInstructionProto cluster_instruction;
auto* repeated_instruction_proto = cluster_instruction.mutable_eager_instruction()
->mutable_instruction_list()
......@@ -111,5 +110,5 @@ Maybe<void> EagerOneflow::RunLogicalInstruction(
COMMAND(Global<EagerOneflow>::SetAllocated(new EagerOneflow()));
} // namespace eager
} // namespace vm
} // namespace oneflow
......@@ -28,36 +28,26 @@ namespace vm {
namespace cfg {
class InstructionListProto;
} // namespace cfg
} // namespace vm
namespace eager {
namespace cfg {
class EagerSymbolList;
} // namespace cfg
} // namespace eager
namespace eager {
class EagerOneflow final {
public:
Maybe<void> RunLogicalInstruction(vm::InstructionMsgList* instruction_list,
const eager::cfg::EagerSymbolList& eager_symbol_list);
const vm::cfg::EagerSymbolList& eager_symbol_list);
Maybe<void> RunPhysicalInstruction(
const std::shared_ptr<const ClusterInstructionProto>& cluster_instruction);
Maybe<void> RunPhysicalInstruction(vm::InstructionMsgList* instruction_list,
const eager::cfg::EagerSymbolList& eager_symbol_list);
const vm::cfg::EagerSymbolList& eager_symbol_list);
Maybe<void> RunPhysicalInstruction(vm::InstructionMsgList* instruction_list,
const eager::EagerSymbolList& eager_symbol_list);
const vm::EagerSymbolList& eager_symbol_list);
};
} // namespace eager
} // namespace vm
} // namespace oneflow
#endif // ONEFLOW_CORE_EAGER_EAGER_ONEFLOW_H_
syntax = "proto2";
package oneflow.eager;
package oneflow.vm;
import "oneflow/core/job/job_conf.proto";
import "oneflow/core/job/placement.proto";
......
......@@ -21,7 +21,7 @@ limitations under the License.
#include "oneflow/core/operator/op_conf_symbol.h"
namespace oneflow {
namespace eager {
namespace vm {
COMMAND(Global<symbol::Storage<Scope>>::SetAllocated(new symbol::Storage<Scope>()));
using ScopeInstr = vm::InitSymbolInstructionType<Scope>;
......@@ -42,5 +42,5 @@ COMMAND(Global<symbol::Storage<OpNodeSignatureDesc>>::SetAllocated(
using OpNodeSignatureInstr = vm::InitSymbolInstructionType<OpNodeSignatureDesc>;
COMMAND(vm::RegisterInstructionType<OpNodeSignatureInstr>("InitOpNodeSignatureDescSymbol"));
} // namespace eager
} // namespace vm
} // namespace oneflow
......@@ -36,7 +36,7 @@ limitations under the License.
#include "oneflow/core/operator/op_conf_symbol.h"
namespace oneflow {
namespace eager {
namespace vm {
namespace test {
namespace {
......@@ -86,5 +86,5 @@ TEST(InitSymbolInstructionType, operator_conf) {
}
} // namespace test
} // namespace eager
} // namespace vm
} // namespace oneflow
......@@ -19,7 +19,7 @@ limitations under the License.
#include "oneflow/core/eager/blob_object.h"
namespace oneflow {
namespace eager {
namespace vm {
class LazyRefBlobObject final : public BlobObject {
public:
......@@ -57,7 +57,7 @@ class LazyRefBlobObject final : public BlobObject {
Blob* ref_blob_ = nullptr;
};
} // namespace eager
} // namespace vm
} // namespace oneflow
#endif // ONEFLOW_CORE_EAGER_LAZY_REF_BLOB_OBJECT_H_
......@@ -17,7 +17,7 @@ limitations under the License.
#include "oneflow/user/kernels/stateful_local_opkernel.h"
namespace oneflow {
namespace eager {
namespace vm {
void LocalCallOpKernelPhyInstrOperand::ForEachConstMirroredObject(
const std::function<void(vm::MirroredObject* infer, vm::MirroredObject* compute)>& DoEach)
......@@ -73,5 +73,5 @@ void LocalCallOpKernelPhyInstrOperand::ForEachMut2MirroredObject(
}
}
} // namespace eager
} // namespace vm
} // namespace oneflow
......@@ -26,7 +26,7 @@ namespace one {
class StatefulOpKernel;
using EagerBlobObjectList =
std::shared_ptr<const std::vector<std::shared_ptr<eager::EagerBlobObject>>>;
std::shared_ptr<const std::vector<std::shared_ptr<vm::EagerBlobObject>>>;
} // namespace one
......@@ -36,7 +36,7 @@ class OpKernel;
} // namespace user_op
namespace eager {
namespace vm {
class LocalCallOpKernelPhyInstrOperand final : public vm::PhyInstrOperand {
public:
......@@ -84,7 +84,7 @@ class LocalCallOpKernelPhyInstrOperand final : public vm::PhyInstrOperand {
const user_op::OpKernel* user_opkernel_;
};
} // namespace eager
} // namespace vm
} // namespace oneflow
#endif // ONEFLOW_CORE_EAGER_LOCAL_CALL_OPKERNEL_PHY_INSTR_OPERAND_H_
......@@ -21,7 +21,7 @@ limitations under the License.
#include "oneflow/core/vm/instruction_operand.msg.h"
namespace oneflow {
namespace eager {
namespace vm {
// clang-format off
FLAT_MSG_VIEW_BEGIN(NewOpKernelObjectInstrOperand);
......@@ -94,7 +94,7 @@ FLAT_MSG_VIEW_BEGIN(RemoveForeignCallbackInstrOperand);
FLAT_MSG_VIEW_END(RemoveForeignCallbackInstrOperand);
// clang-format on
} // namespace eager
} // namespace vm
} // namespace oneflow
#endif // ONEFLOW_CORE_EAGER_OPKERNEL_INSTRUCTION_MSG_H_
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment