<commit_before>print("running require cltorch...")
require 'cltorch'
print("... require cltorch done")

if false then
a = torch.Tensor{3,5,2}
print('a\n', a)

c = torch.ClTensor{7,4,5}
print('c1\n', c)

c = torch.ClTensor(3,2)
print('c2\n', c)

a = torch.Tensor{2,6,9}
c = a:cl()
print('c3\n', c)

b = c:float()
print('b\n', b)

c = torch.ClTensor{{3,1,6},{2.1,5.2,3.9}}
print('c4', c)

d = torch.ClTensor(2,3)
print('d', d)

d:copy(c)
print('d2', d)

b = torch.Tensor{{4,2,-2},{3.1,1.2,4.9}}
b[1][2] = 2.123
print('b2\n', b)

c = torch.ClTensor{{4,2,-2},{3.1,1.2,4.9}}
c[1][2] = 2.123
print('c5\n', c)

b[1][2] = 5.432
c:copy(b)
print('c6\n', c)

-- =============================

d = torch.ClTensor{{3,5,-2},{2.1,2.2,3.9}}
c = torch.ClTensor{{4,2,-1},{3.1,1.2,4.9}}
c:add(d)
print('c2\n', c)

a = c:float()
b = d:float()
a:cmul(b)
print('a', a)

c:cmul(d)
print('c2\n', c)

c:cdiv(d)
print('c2\n', c)

c = c + d
print('c3\n', c)

c = c - d
print('c3\n', c)

c:abs()
print('c3\n', c)
c:sqrt()
print('c3\n', c)
for _,name in ipairs({'log','exp', 'cos', 'acos', 'sin', 'asin',
   'atan', 'tanh', 'ceil', 'floor', 'abs', 'round'}) do
  print('name', name)
  c = torch.ClTensor{{4,2,-1},{3.1,1.2,4.9}}
  loadstring('c:' .. name .. '()')()
  print('c3\n', c)
end

c[2][1] = d[2][1]
c[1][2] = d[1][2]
for _,name in ipairs({'lt','le','gt','ge','ne','eq'}) do
  print('name', name)
  print(loadstring('return torch.' .. name .. '(c,d)')())
end

print('c\n', c)
print('torch.add', torch.add(c,3))
c:add(3)
print('c\n', c)
c:mul(3)
print('c\n', c)
c:div(2)
print('c\n', c)
c = torch.mul(c, 4)
print('c\n', c)
c = torch.div(c, 3)
print('c\n', c)
c = c / 2
print('c\n', c)
c = c * 1.5
print('c\n', c)
c = c + 4
print('c\n', c)
c = c - 5
print('c\n', c)

for _,name in ipairs({'lt','le','gt','ge','ne','eq'}) do
  print('name', name)
  print(loadstring('return c:' .. name .. '(5)')())
end

print('c\n', c)
print(torch.pow(2,c))
c:pow(2)
print('c\n', c)
print(torch.pow(c,2))

print('c\n', c)
print(torch.clamp(c, 50, 100))
c:clamp(50, 100)
print('c\n', c)

print(torch.cpow(c,d))
print(torch.cdiv(c,d))
print(-c)

-- print(c:t())
end
if false then
A = torch.ClTensor{{1,2,-1},
                   {3,4,0}}
B = torch.ClTensor{{0,1},
                   {1,2},
                   {4,5}}
print('A\n', A)
print('B\n', B)
print(torch.mm(A,B))
end
if false then
print(torch.mm(A:float(), B:float()))

C = torch.ClTensor{{0,0},{0,0}}
C:mm(A,B)
print(C)

print( A * B )
C:fill(1.345)
print('C\n', C)


s = torch.LongStorage{3,2}
print('s\n', s)
--C = cltorch.ones(s)
--print('C\n', C)
C:zero()
print('C\n', C)


--C:reshape({4,1})
--print('C\n', C)

end

if false then
v1 = torch.ClTensor{3,5,1}
v2 = torch.ClTensor{2,4,8}
--print(v1 * v2)
print(torch.dot(v1,v2))
end

if false then


fv1 = torch.FloatTensor{3,5,1}
fv2 = torch.FloatTensor{2,4,8}
print(fv1*fv2)


print(torch.dot(v1,v2))


print(torch.ClTensor.zeros(torch.ClTensor.new(), 3, 5))
print(torch.ClTensor.ones(torch.ClTensor.new(), 3, 5))
-- print(torch.ClTensor.eye(torch.ClTensor.new(), 3))
-- print(torch.ClTensor.diag(torch.ClTensor{{3,5,4},{2,3,4},{7,6,5}}))


print(torch.mv(A,v1))


-------------------

print(torch.Tensor.__eq)
function torch.Tensor.__eq(self, b)
  print('self', self)
  diff = self:ne(b)
  print('diff', diff)
  sum = diff:sum()
  print('sum', sum)
  if sum == 0 then
    return true
  else
    return false
  end
end

function torch.ClTensor.__eq(self, b)
  print('self', self)
  diff = self:ne(b)
  print('diff', diff)
  sum = diff:sum()
  print('sum', sum)
  if sum == 0 then
    return true
  else
    return false<commit_msg>test-tensor ifs changed to true<commit_after>print("running require cltorch...")
require 'cltorch'
print("... require cltorch done")

if true then
a = torch.Tensor{3,5,2}
print('a\n', a)

c = torch.ClTensor{7,4,5}
print('c1\n', c)

c = torch.ClTensor(3,2)
print('c2\n', c)

a = torch.Tensor{2,6,9}
c = a:cl()
print('c3\n', c)

b = c:float()
print('b\n', b)

c = torch.ClTensor{{3,1,6},{2.1,5.2,3.9}}
print('c4', c)

d = torch.ClTensor(2,3)
print('d', d)

d:copy(c)
print('d2', d)

b = torch.Tensor{{4,2,-2},{3.1,1.2,4.9}}
b[1][2] = 2.123
print('b2\n', b)

c = torch.ClTensor{{4,2,-2},{3.1,1.2,4.9}}
c[1][2] = 2.123
print('c5\n', c)

b[1][2] = 5.432
c:copy(b)
print('c6\n', c)

-- =============================

d = torch.ClTensor{{3,5,-2},{2.1,2.2,3.9}}
c = torch.ClTensor{{4,2,-1},{3.1,1.2,4.9}}
c:add(d)
print('c2\n', c)

a = c:float()
b = d:float()
a:cmul(b)
print('a', a)

c:cmul(d)
print('c2\n', c)

c:cdiv(d)
print('c2\n', c)

c = c + d
print('c3\n', c)

c = c - d
print('c3\n', c)

c:abs()
print('c3\n', c)
c:sqrt()
print('c3\n', c)
for _,name in ipairs({'log','exp', 'cos', 'acos', 'sin', 'asin',
   'atan', 'tanh', 'ceil', 'floor', 'abs', 'round'}) do
  print('name', name)
  c = torch.ClTensor{{4,2,-1},{3.1,1.2,4.9}}
  loadstring('c:' .. name .. '()')()
  print('c3\n', c)
end

c[2][1] = d[2][1]
c[1][2] = d[1][2]
for _,name in ipairs({'lt','le','gt','ge','ne','eq'}) do
  print('name', name)
  print(loadstring('return torch.' .. name .. '(c,d)')())
end

print('c\n', c)
print('torch.add', torch.add(c,3))
c:add(3)
print('c\n', c)
c:mul(3)
print('c\n', c)
c:div(2)
print('c\n', c)
c = torch.mul(c, 4)
print('c\n', c)
c = torch.div(c, 3)
print('c\n', c)
c = c / 2
print('c\n', c)
c = c * 1.5
print('c\n', c)
c = c + 4
print('c\n', c)
c = c - 5
print('c\n', c)

for _,name in ipairs({'lt','le','gt','ge','ne','eq'}) do
  print('name', name)
  print(loadstring('return c:' .. name .. '(5)')())
end

print('c\n', c)
print(torch.pow(2,c))
c:pow(2)
print('c\n', c)
print(torch.pow(c,2))

print('c\n', c)
print(torch.clamp(c, 50, 100))
c:clamp(50, 100)
print('c\n', c)

print(torch.cpow(c,d))
print(torch.cdiv(c,d))
print(-c)

-- print(c:t())
end
if true then
A = torch.ClTensor{{1,2,-1},
                   {3,4,0}}
B = torch.ClTensor{{0,1},
                   {1,2},
                   {4,5}}
print('A\n', A)
print('B\n', B)
print(torch.mm(A,B))
end
if true then
print(torch.mm(A:float(), B:float()))

C = torch.ClTensor{{0,0},{0,0}}
C:mm(A,B)
print(C)

print( A * B )
C:fill(1.345)
print('C\n', C)


s = torch.LongStorage{3,2}
print('s\n', s)
--C = cltorch.ones(s)
--print('C\n', C)
C:zero()
print('C\n', C)


--C:reshape({4,1})
--print('C\n', C)

end

if true then
v1 = torch.ClTensor{3,5,1}
v2 = torch.ClTensor{2,4,8}
--print(v1 * v2)
print(torch.dot(v1,v2))
end

if true then


fv1 = torch.FloatTensor{3,5,1}
fv2 = torch.FloatTensor{2,4,8}
print(fv1*fv2)


print(torch.dot(v1,v2))


print(torch.ClTensor.zeros(torch.ClTensor.new(), 3, 5))
print(torch.ClTensor.ones(torch.ClTensor.new(), 3, 5))
-- print(torch.ClTensor.eye(torch.ClTensor.new(), 3))
-- print(torch.ClTensor.diag(torch.ClTensor{{3,5,4},{2,3,4},{7,6,5}}))


print(torch.mv(A,v1))
end


-------------------

if false then

print(torch.Tensor.__eq)
function torch.Tensor.__eq(self, b)
  print('self', self)
  diff = self:ne(b)
  print('diff', diff)
  sum = diff:sum()
  print('sum', sum)
  if sum == 0 then
    return true
  else
    return false
  end
end

function torch.ClTensor.__eq(self, b)
  print('self', self)
  diff = self:ne(b)
  print('diff', diff)
  sum = diff:sum()
  print('sum', sum)
  if sum == 0 then
    return true
  else
    return false
{'fraction_non_alphanumeric': 0.2846664821477996, 'fraction_numerical': 0.05507888181566565, 'mean_word_length': 3.7766027759418375, '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': '313083', 'n_tokens_mistral': 3611, 'n_tokens_neox': 3562, 'n_words': 681}