mirror of https://github.com/Jittor/Jittor
commit
0abdc60b77
|
@ -2229,10 +2229,9 @@ def histc(input, bins, min=0., max=0.):
|
||||||
if bins <= 0:
|
if bins <= 0:
|
||||||
raise RuntimeError(f"bins must be > 0, but got {bins}")
|
raise RuntimeError(f"bins must be > 0, but got {bins}")
|
||||||
bin_length = (max - min) / bins
|
bin_length = (max - min) / bins
|
||||||
histc = jt.floor((input[jt.logical_and(input >= min, input <= max)] - min) / bin_length).int().reshape(-1)
|
histc = jt.floor((input[jt.logical_and(input >= min, input < max)] - min) / bin_length).int().reshape(-1)
|
||||||
hist = jt.ones_like(histc).float().reindex_reduce("add", [bins,], ["@e0(i0)"], extras=[histc])
|
hist = jt.ones_like(histc).float().reindex_reduce("add", [bins,], ["@e0(i0)"], extras=[histc])
|
||||||
if hist.sum() != histc.shape[0]:
|
hist[-1] += input[input == max].shape[0]
|
||||||
hist[-1] += 1
|
|
||||||
return hist
|
return hist
|
||||||
|
|
||||||
def peek_s(x):
|
def peek_s(x):
|
||||||
|
|
|
@ -30,7 +30,7 @@ EXTERN_LIB bool no_cuda_error_when_free;
|
||||||
|
|
||||||
struct CudaDualAllocator : Allocator {
|
struct CudaDualAllocator : Allocator {
|
||||||
//for recycle block_id
|
//for recycle block_id
|
||||||
static const size_t ID_LIMIT = 1 << 16;
|
static const size_t ID_LIMIT = 1 << 20;
|
||||||
int n_free_ids;
|
int n_free_ids;
|
||||||
int free_ids[ID_LIMIT];
|
int free_ids[ID_LIMIT];
|
||||||
DualAllocation allocations[ID_LIMIT];
|
DualAllocation allocations[ID_LIMIT];
|
||||||
|
|
|
@ -36,7 +36,7 @@ struct CachingBlockPool {
|
||||||
//start from 1
|
//start from 1
|
||||||
static size_t tot_block_id;
|
static size_t tot_block_id;
|
||||||
static std::unique_ptr<CachingBlock*[]> occupied_id_mapper;
|
static std::unique_ptr<CachingBlock*[]> occupied_id_mapper;
|
||||||
static const size_t ID_LIMIT = 1 << 18;
|
static const size_t ID_LIMIT = 1 << 21;
|
||||||
|
|
||||||
pair<size_t,size_t> get_key(CachingBlock* block);
|
pair<size_t,size_t> get_key(CachingBlock* block);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ struct TempCachingBlock {
|
||||||
|
|
||||||
struct TempAllocator : Allocator {
|
struct TempAllocator : Allocator {
|
||||||
static const size_t ALIGN_SIZE = 512;
|
static const size_t ALIGN_SIZE = 512;
|
||||||
static const size_t ID_LIMIT = 1 << 18;
|
static const size_t ID_LIMIT = 1 << 21;
|
||||||
static vector<TempAllocator*> temp_allocators;
|
static vector<TempAllocator*> temp_allocators;
|
||||||
Allocator* underlying;
|
Allocator* underlying;
|
||||||
size_t cache_blocks_limit, used_memory, unused_memory;
|
size_t cache_blocks_limit, used_memory, unused_memory;
|
||||||
|
|
Loading…
Reference in New Issue