codegen/generate_functions.rb in torch-rb-0.16.0 vs codegen/generate_functions.rb in torch-rb-0.17.0
- old
+ new
@@ -153,14 +153,14 @@
else
name
end
ruby_name = "_#{ruby_name}" if ["size", "stride", "random!"].include?(ruby_name)
- ruby_name = ruby_name.sub(/\Afft_/, "") if type == "fft"
- ruby_name = ruby_name.sub(/\Alinalg_/, "") if type == "linalg"
- ruby_name = ruby_name.sub(/\Aspecial_/, "") if type == "special"
- ruby_name = ruby_name.sub(/\Asparse_/, "") if type == "sparse"
+ ruby_name = ruby_name.delete_prefix("fft_") if type == "fft"
+ ruby_name = ruby_name.delete_prefix("linalg_") if type == "linalg"
+ ruby_name = ruby_name.delete_prefix("special_") if type == "special"
+ ruby_name = ruby_name.delete_prefix("sparse_") if type == "sparse"
ruby_name = name if name.start_with?("__")
"rb_#{def_method}(m, \"#{ruby_name}\", #{full_name(name, type)}, -1);"
end
@@ -214,11 +214,11 @@
if function["out"] && function["out"] != function["base"]
base_code = generate_dispatch(function["base"], def_method)
out_code = generate_dispatch(function["out"], def_method)
out_index = function["out"].out_index
- return "if (_r.isNone(#{out_index})) {
+ "if (_r.isNone(#{out_index})) {
#{indent(base_code)}
} else {
#{indent(out_code)}
}"
else
@@ -437,10 +437,10 @@
when "string"
"stringViewOptional"
else
"#{func}Optional"
end
- end
+ end
"_r.#{func}(#{param[:position]})"
end
end