forked from ankane/torch.rb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
53 lines (44 loc) · 1.1 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require "bundler/gem_tasks"
require "rake/testtask"
require "rake/extensiontask"
task default: :test
Rake::TestTask.new do |t|
t.libs << "test"
t.pattern = "test/**/*_test.rb"
end
Rake::ExtensionTask.new("torch") do |ext|
ext.name = "ext"
ext.lib_dir = "lib/torch"
end
task :remove_ext do
Dir["lib/torch/ext.bundle", "ext/torch/*_functions.{cpp,hpp}"].each do |path|
File.unlink(path) if File.exist?(path)
end
end
Rake::Task["build"].enhance [:remove_ext]
namespace :generate do
desc "Generate C++ functions"
task :functions do
require_relative "codegen/generate_functions"
generate_functions
end
end
namespace :benchmark do
desc "Benchmark Numo"
task :numo do
require "benchmark"
require "numo/narray"
require "torch-rb"
x = Numo::SFloat.new(60000, 28, 28).seq
t = nil
p Benchmark.realtime { t = Torch.from_numo(x) }
p Benchmark.realtime { t.numo }
end
desc "Benchmark dispatcher"
task :dispatcher do
require "benchmark"
require "torch-rb"
x = Torch.tensor([1, 2, 3])
p Benchmark.realtime { 100000.times { x.contiguous } }
end
end