<commit_before>--[[ MemoryOptimizer is a class used for optimizing memory usage
--]]
local MemoryOptimizer = torch.class('MemoryOptimizer')

-- We cannot share the output of these modules as they use it in their backward pass.
local protectOutput = {
  'nn.Sigmoid',
  'nn.SoftMax',
  'nn.Tanh'
}

-- We cannot share the input of these modules as they use it in their backward pass.
local protectInput = {
  'nn.Linear',
  'nn.JoinTable',
  'onmt.JoinReplicateTable',
  'nn.CMulTable',
  'nn.MM'
}

local function contains(list, m)
  for i = 1, #list do
    if torch.typename(m) == list[i] then
      return true
    end
  end
  return false
end

local function tensorIncluded(t, l)
  if torch.isTensor(l) then
    return torch.pointer(t:storage()) == torch.pointer(l:storage())
  elseif torch.type(l) == 'table' then
    for _, m in ipairs(l) do
      if tensorIncluded(t, m) then
        return true
      end<commit_msg>Remove unnecessary input protection in MemoryOptimizer<commit_after>--[[ MemoryOptimizer is a class used for optimizing memory usage
--]]
local MemoryOptimizer = torch.class('MemoryOptimizer')

-- We cannot share the output of these modules as they use it in their backward pass.
local protectOutput = {
  'nn.Sigmoid',
  'nn.SoftMax',
  'nn.Tanh'
}

-- We cannot share the input of these modules as they use it in their backward pass.
local protectInput = {
  'nn.Linear',
  'nn.JoinTable',
  'nn.CMulTable',
  'nn.MM'
}

local function contains(list, m)
  for i = 1, #list do
    if torch.typename(m) == list[i] then
      return true
    end
  end
  return false
end

local function tensorIncluded(t, l)
  if torch.isTensor(l) then
    return torch.pointer(t:storage()) == torch.pointer(l:storage())
  elseif torch.type(l) == 'table' then
    for _, m in ipairs(l) do
      if tensorIncluded(t, m) then
        return true
      end
{'fraction_non_alphanumeric': 0.1108719052744887, 'fraction_numerical': 0.001076426264800861, 'mean_word_length': 3.3434579439252334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4015427', 'n_tokens_mistral': 610, 'n_tokens_neox': 605, 'n_words': 213}