forked from joanshen0508/Deep-Semantic-Face-Deblurring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
move.m
64 lines (62 loc) · 1.94 KB
/
move.m
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
54
55
56
57
58
59
60
61
62
63
64
function [obj]=move(obj, device)
%MOVE Move the DagNN to either CPU or GPU
% MOVE(obj, 'cpu') moves the DagNN obj to the CPU.
%
% MOVE(obj, 'gpu') moves the DagNN obj to the GPU.
% Copyright (C) 2015 Karel Lenc and Andrea Vedaldi.
% All rights reserved.
%
% This file is part of the VLFeat library and is made available under
% the terms of the BSD license (see the COPYING file).
switch device
case 'gpu'
for i=1:length(obj)
if isfield(obj(1,i),'w')
obj(i).w = gpuArray(obj(i).w) ;
end
if isfield(obj(1,i),'b')
obj(i).b= gpuArray(obj(i).b) ;
end
if isfield(obj(1,i),'bw')
obj(i).bw= gpuArray(obj(i).bw) ;
end
if isfield(obj(1,i),'bb')
obj(i).bb= gpuArray(obj(i).bb) ;
end
if isfield(obj(1,i),'bm')
obj(i).bm= gpuArray(obj(i).bm) ;
end
if isfield(obj(1,i),'upw')
obj(1,i).upw= gpuArray(obj(i).upw) ;
end
if isfield(obj(1,i),'upb')
obj(i).upb= gpuArray(obj(i).upb) ;
end
end
case 'cpu'
for i=1:length(obj)
if isfield(obj(1,i),'w')
obj(i).w = (obj(i).w) ;
end
if isfield(obj(1,i),'b')
obj(i).b= (obj(i).b) ;
end
if isfield(obj(1,i),'bw')
obj(i).bw= (obj(i).bw) ;
end
if isfield(obj(1,i),'bb')
obj(i).bb= (obj(i).bb) ;
end
if isfield(obj(1,i),'bm')
obj(i).bm= (obj(i).bm) ;
end
if isfield(obj(1,i),'upw')
obj(1,i).upw= (obj(i).upw) ;
end
if isfield(obj(1,i),'upb')
obj(i).upb= (obj(i).upb) ;
end
end
otherwise
error('DEVICE must be either ''cpu'' or ''gpu''.') ;
end