Skip to content

Commit

Permalink
fix recycle dep (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
fandaoyi authored and KevinfromTJ committed Dec 4, 2023
1 parent 7bd5c20 commit e83db3d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
#include <c10/core/Allocator.h>
#include <c10/core/Device.h>

#include "../DIPUEvent.h"
#include "csrc_dipu/runtime/core/DIPUEvent.h"

#include "DIPUAsyncResourcePool.h"
#include "DIPUCachingAllocatorUtils.h"
#include "DIPURawAllocator.h"

namespace dipu {
Expand Down Expand Up @@ -137,24 +139,6 @@ void setAllocator(const std::string name, c10::DeviceType device_type,

c10::Allocator* getAllocator(c10::DeviceType device_type);

size_t memoryReserved(const c10::Device& device);

size_t memoryAllocated(const c10::Device& device);

size_t maxMemoryReserved(const c10::Device& device);

size_t maxMemoryAllocated(const c10::Device& device);

void emptyCachedMem();

void initCachedAllocator();

void releaseAllDeviceMem();

void recordStream(const c10::DataPtr& ptr, DIPUStream stream);

void recordStream(const at::Tensor& tensor, DIPUStream stream);

namespace { // For internal implementation only

struct AllocatorRegisterer {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

#pragma once

#include <c10/core/Allocator.h>
#include <c10/core/Device.h>

#include "csrc_dipu/runtime/core/DIPUStream.h"

namespace dipu {
size_t memoryReserved(const c10::Device& device);

size_t memoryAllocated(const c10::Device& device);

size_t maxMemoryReserved(const c10::Device& device);

size_t maxMemoryAllocated(const c10::Device& device);

void emptyCachedMem();

void initCachedAllocator();

void releaseAllDeviceMem();

void recordStream(const c10::DataPtr& ptr, DIPUStream stream);

void recordStream(const at::Tensor& tensor, DIPUStream stream);

} // namespace dipu
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@

#include <csrc_dipu/base/basedef.h>
#include <csrc_dipu/runtime/core/DIPUStream.h>
#include <csrc_dipu/runtime/core/allocator/DIPUCachingAllocatorUtils.h>
#include <csrc_dipu/runtime/devproxy/deviceproxy.h>

namespace dipu {
// seems DIPUCachingAllocator.h and this class has Cycle reference? need
// refactor?
void recordStream(const c10::DataPtr& ptr, DIPUStream stream);

struct DIPUGuardImpl : public c10::impl::DeviceGuardImplInterface {
static constexpr at::DeviceType static_type = dipu::DIPU_DEVICE_TYPE;
DIPUGuardImpl() {}
Expand Down

0 comments on commit e83db3d

Please sign in to comment.