Skip to content

Commit

Permalink
treemax support for non-contiguous tensors
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-leonard committed Oct 17, 2014
1 parent 23e645d commit bd6f528
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion treemax.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ function torch.treemax(tensor, treeSize)
tmb = {
mean = tensor.new(),
max = tensor.new(),
idx = torch.LongTensor()
idx = torch.LongTensor(),
copy = tensor.new()
}
treeMaxBuffer[torch.type(tensor)] = tmb
end

if not tensor:isContiguous() then
tmb.copy:resizeAs(tensor):copy(tensor)
tensor = tmb.copy
end

local lvl = tensor
local maxIdx, maxVal = 1, 0
for i=1,#treeSize do
Expand Down

0 comments on commit bd6f528

Please sign in to comment.