forked from huashiyiqike/LSTM-MATLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gputype.m
executable file
·24 lines (24 loc) · 911 Bytes
/
gputype.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
function [mones,mzeros,convert,useG]=gputype(usegpu)
switch usegpu
case 'gpu_single'
mones = @(varargin) gpuArray(ones(varargin{:},'single'));
mzeros = @(varargin) gpuArray(zeros(varargin{:},'single'));
convert = @(varargin) gpuArray( single(varargin{:}) );
useG=1;
case 'gpu_double'
mones = @(varargin) gpuArray(ones(varargin{:},'double'));
mzeros = @(varargin) gpuArray(zeros(varargin{:},'double'));
convert = @(varargin) gpuArray( double(varargin{:}) );
useG=1;
case 'cpu_single'
mones = @(varargin)ones(varargin{:}, 'single');
mzeros = @(varargin)zeros(varargin{:}, 'single');
convert = @single;
useG=0;
case 'cpu_double'
mones = @(varargin)ones(varargin{:}, 'double');
mzeros = @(varargin)zeros(varargin{:}, 'double');
convert = @(x)x;
useG=0;
end
end