Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/optim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoumith Chintala <soumith@gmail.com>2015-05-19 18:28:47 +0300
committerSoumith Chintala <soumith@gmail.com>2015-05-19 18:28:47 +0300
commit07fb9e0e22c1ff1a64613b24f0ba290e710aa5bd (patch)
treec46fcb1a06b1543808897972c1b5decb80dba07f
parent446de4f45f3e901adc889f4d6a49051028e437e8 (diff)
parent0b78f62128677cee3ff8288481f10a1be8442abd (diff)
Merge pull request #58 from dpfau/cuda_cg
Added CUDA support for cg.lua
-rw-r--r--cg.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/cg.lua b/cg.lua
index a03c220..842a7d5 100644
--- a/cg.lua
+++ b/cg.lua
@@ -54,9 +54,9 @@ function optim.cg(opfunc, x, config, state)
local d1,d2,d3 = 0,0,0
local f1,f2,f3 = 0,0,0
- local df1 = state.df1 or torch.Tensor()
- local df2 = state.df2 or torch.Tensor()
- local df3 = state.df3 or torch.Tensor()
+ local df1 = state.df1 or x.new()
+ local df2 = state.df2 or x.new()
+ local df3 = state.df3 or x.new()
local tdf
df1:resizeAs(x)
@@ -64,13 +64,13 @@ function optim.cg(opfunc, x, config, state)
df3:resizeAs(x)
-- search direction
- local s = state.s or torch.Tensor()
+ local s = state.s or x.new()
s:resizeAs(x)
-- we need a temp storage for X
- local x0 = state.x0 or torch.Tensor()
+ local x0 = state.x0 or x.new()
local f0 = 0
- local df0 = state.df0 or torch.Tensor()
+ local df0 = state.df0 or x.new()
x0:resizeAs(x)
df0:resizeAs(x)