Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Revert "Subgraph API for integrating accelerators with MXNet (#12157)" #12443

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions include/mxnet/c_api_test.h

This file was deleted.

22 changes: 2 additions & 20 deletions include/mxnet/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,8 @@ class Engine;

/*! \brief namespace of engine internal types. */
namespace engine {
/*! \brief base class of engine variables.*/
struct Var {
virtual size_t version() {
return version_;
}
virtual ~Var() = default;
/*!
* \brief cast variable to derived type T
* \tparam T the type we want to cast into.
* \return A casted variable.
*/
template <typename T>
inline T* Cast();
/*!
* \brief version number of the var. Every time the object it is associated with
* is modified, the version number is incremented by 1.
*/
size_t version_{0};
}; // struct Var

/*! \brief Internal representation of variable. */
struct Var;
/*! \brief Internal representation of operator. */
struct Opr;
/*! \brief Variable pointer type, usually hold by user used to specify dependencies. */
Expand Down
4 changes: 0 additions & 4 deletions include/mxnet/ndarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,6 @@ class NDArray {
inline size_t byte_offset() const {
return byte_offset_;
}
/*! \brief return var version of the NDArray*/
inline size_t version() const {
return var()->version();
}
/*!
* \brief save the content into binary stream
* \param strm the output stream
Expand Down
73 changes: 0 additions & 73 deletions src/c_api/c_api_test.cc

This file was deleted.

14 changes: 14 additions & 0 deletions src/engine/engine_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@
namespace mxnet {
namespace engine {

/*! \brief base class of engine variables, used for type checking */
struct Var {
#if ENGINE_DEBUG
virtual ~Var() = default;
#endif // ENGINE_DEBUG
/*!
* \brief cast variable to derived type T
* \tparam T the type we want to cast into.
* \return A casted variable.
*/
template <typename T>
inline T* Cast();
}; // struct Var

/*! \brief base class of engine operators, used for type checking */
struct Opr {
#if ENGINE_DEBUG
Expand Down
31 changes: 6 additions & 25 deletions src/engine/naive_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,10 @@
#include "./engine_impl.h"
#include "../profiler/profiler.h"
#include "./openmp.h"
#include "../common/object_pool.h"

namespace mxnet {
namespace engine {

/*!
* \brief var used in Naive Engine for tracking the version
* of the objects it is associated with.
*/
class NaiveVar final
: public Var, public common::ObjectPoolAllocatable<NaiveVar> {
public:
inline static NaiveVar* CastFromBase(Var* ptr) {
return ptr->Cast<NaiveVar>();
}
}; // class NaiveVar


// implement naive engine
class NaiveEngine final : public Engine {
public:
Expand Down Expand Up @@ -85,7 +71,8 @@ class NaiveEngine final : public Engine {

// new variables
VarHandle NewVariable() override {
return NaiveVar::New();
size_t v = ++counter_;
return reinterpret_cast<VarHandle>(v);
}

OprHandle NewOperator(AsyncFn fn,
Expand Down Expand Up @@ -159,10 +146,6 @@ class NaiveEngine final : public Engine {
opr->opr_profile.reset(new profiler::ProfileOperator(opr->opr_name, attrs.release()));
opr->opr_profile->start(exec_ctx.dev_type, exec_ctx.dev_id);
}
// increment mutable var version
for (auto var : mutable_vars) {
++var->version_;
}
if (exec_ctx.dev_mask() == gpu::kDevMask) {
#if MXNET_USE_CUDA
size_t dev_id = static_cast<size_t>(exec_ctx.dev_id);
Expand All @@ -188,12 +171,8 @@ class NaiveEngine final : public Engine {
}

void DeleteVariable(SyncFn delete_fn, Context exec_ctx, VarHandle var) override {
NaiveVar* naive_var = NaiveVar::CastFromBase(var);
this->PushAsync([delete_fn, naive_var](RunContext ctx, CallbackOnComplete on_complete) mutable {
delete_fn(ctx);
NaiveVar::Delete(naive_var);
on_complete();
}, exec_ctx, {}, {var}, FnProperty::kDeleteVar, 0, "DeleteVariable");
this->PushSync(delete_fn, exec_ctx, {}, {var},
FnProperty::kNormal, 0, "DeleteVariable");
}

void WaitForVar(VarHandle var) override {
Expand All @@ -213,6 +192,8 @@ class NaiveEngine final : public Engine {
}
// whether action is completed
bool req_completed_;
// counter
std::atomic<size_t> counter_{0};
/*! \brief whether it is during shutdown phase*/
std::atomic<bool> shutdown_phase_{false};
// CPU stream
Expand Down
10 changes: 1 addition & 9 deletions src/engine/threaded_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ inline bool ThreadedVar::CompleteWriteDependency(Dispatcher dispatcher) {
assert(pending_write_ != nullptr);
CHECK_EQ(num_pending_reads_, kWriteTriggered);

// increment version number
++version_;

// really delete
if (to_delete_) {
VersionedVarBlock *head = pending_write_->next;
Expand Down Expand Up @@ -167,7 +164,7 @@ inline bool ThreadedVar::CompleteWriteDependency(Dispatcher dispatcher) {
}
// This is outside of lock scope
// Be very carful, pending_write_ and num_pending_reads_
// can change now, do not rely on these two variables.
// can change now, do not reply ont the two variables.
// The linked list \in [old_pending_write, end_of_read_chain)
// is already detached from this Var.
// So it is safe to modify these
Expand Down Expand Up @@ -199,11 +196,6 @@ inline bool ThreadedVar::ready_to_read() {
return this->is_ready_to_read();
}

inline size_t ThreadedVar::version() {
std::lock_guard<std::mutex> lock{mutex_};
return this->version_;
}

// implementation of threaded engine
ThreadedVar* ThreadedEngine::NewVariable() {
return ThreadedVar::New(VersionedVarBlock::New());
Expand Down
1 change: 0 additions & 1 deletion src/engine/threaded_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ class ThreadedVar final
inline void SetToDelete();
/*! \return whether this variable is ready to read. */
inline bool ready_to_read();
inline size_t version() override;
/*!
* \brief Cast a Var pointer to ThreadedVar pointer
* \param ptr pointer from base.
Expand Down
Loading