Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
8ace7fb5
Commit
8ace7fb5
authored
Jun 15, 2018
by
Scott Thornton
Browse files
Fixed up clang tidy checks and formatting
parent
121ded22
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
463 additions
and
406 deletions
+463
-406
src/include/rtg/operators.hpp
src/include/rtg/operators.hpp
+26
-26
src/targets/cpu/cpu_target.cpp
src/targets/cpu/cpu_target.cpp
+173
-120
test/cpu_ops_test.cpp
test/cpu_ops_test.cpp
+264
-260
No files found.
src/include/rtg/operators.hpp
View file @
8ace7fb5
...
@@ -263,25 +263,25 @@ struct reshape
...
@@ -263,25 +263,25 @@ struct reshape
struct
gemm
struct
gemm
{
{
std
::
string
name
()
const
{
return
"gemm"
;}
std
::
string
name
()
const
{
return
"gemm"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
check_shapes
{
inputs
}.
has
(
2
).
same_type
();
check_shapes
{
inputs
}.
has
(
2
).
same_type
();
const
shape
&
a
=
inputs
.
at
(
0
);
const
shape
&
a
=
inputs
.
at
(
0
);
const
shape
&
b
=
inputs
.
at
(
1
);
const
shape
&
b
=
inputs
.
at
(
1
);
auto
t
=
a
.
type
();
auto
t
=
a
.
type
();
if
(
a
.
lens
()[
1
]
!=
b
.
lens
()[
0
])
if
(
a
.
lens
()[
1
]
!=
b
.
lens
()[
0
])
RTG_THROW
(
"Inner dimensions do not match"
);
RTG_THROW
(
"Inner dimensions do not match"
);
return
{
t
,
{
a
.
lens
()[
0
],
b
.
lens
()[
1
]}};
return
{
t
,
{
a
.
lens
()[
0
],
b
.
lens
()[
1
]}};
}
}
argument
compute
(
shape
,
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
argument
compute
(
shape
,
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
gemm
&
op
)
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
gemm
&
op
)
{
{
os
<<
op
.
name
()
<<
"["
;
os
<<
op
.
name
()
<<
"["
;
os
<<
"]"
;
os
<<
"]"
;
return
os
;
return
os
;
}
}
};
};
...
@@ -290,20 +290,20 @@ struct unary
...
@@ -290,20 +290,20 @@ struct unary
{
{
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
check_shapes
{
inputs
}.
has
(
1
);
check_shapes
{
inputs
}.
has
(
1
);
return
inputs
.
at
(
0
);
return
inputs
.
at
(
0
);
}
}
argument
compute
(
shape
,
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
argument
compute
(
shape
,
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
};
};
struct
identity
:
unary
struct
identity
:
unary
{
{
std
::
string
name
()
const
{
return
"identity"
;
}
std
::
string
name
()
const
{
return
"identity"
;
}
};
};
struct
abs
:
unary
struct
abs
:
unary
{
{
std
::
string
name
()
const
{
return
"abs"
;
}
std
::
string
name
()
const
{
return
"abs"
;
}
};
};
struct
exp
:
unary
struct
exp
:
unary
...
@@ -313,55 +313,55 @@ struct exp : unary
...
@@ -313,55 +313,55 @@ struct exp : unary
struct
sin
:
unary
struct
sin
:
unary
{
{
std
::
string
name
()
const
{
return
"sin"
;
}
std
::
string
name
()
const
{
return
"sin"
;
}
};
};
struct
cos
:
unary
struct
cos
:
unary
{
{
std
::
string
name
()
const
{
return
"cos"
;
}
std
::
string
name
()
const
{
return
"cos"
;
}
};
};
struct
tan
:
unary
struct
tan
:
unary
{
{
std
::
string
name
()
const
{
return
"tan"
;
}
std
::
string
name
()
const
{
return
"tan"
;
}
};
};
struct
asin
:
unary
struct
asin
:
unary
{
{
std
::
string
name
()
const
{
return
"asin"
;
}
std
::
string
name
()
const
{
return
"asin"
;
}
};
};
struct
acos
:
unary
struct
acos
:
unary
{
{
std
::
string
name
()
const
{
return
"acos"
;
}
std
::
string
name
()
const
{
return
"acos"
;
}
};
};
struct
atan
:
unary
struct
atan
:
unary
{
{
std
::
string
name
()
const
{
return
"atan"
;
}
std
::
string
name
()
const
{
return
"atan"
;
}
};
};
struct
softmax
:
unary
struct
softmax
:
unary
{
{
std
::
string
name
()
const
{
return
"softmax"
;
}
std
::
string
name
()
const
{
return
"softmax"
;
}
};
};
struct
tanh
:
unary
struct
tanh
:
unary
{
{
std
::
string
name
()
const
{
return
"tanh"
;
}
std
::
string
name
()
const
{
return
"tanh"
;
}
};
};
struct
sigmoid
:
unary
struct
sigmoid
:
unary
{
{
std
::
string
name
()
const
{
return
"sigmoid"
;
}
std
::
string
name
()
const
{
return
"sigmoid"
;
}
};
};
struct
neg
:
unary
struct
neg
:
unary
{
{
std
::
string
name
()
const
{
return
"neg"
;
}
std
::
string
name
()
const
{
return
"neg"
;
}
};
};
struct
flatten
struct
flatten
{
{
std
::
string
name
()
const
{
return
"flatten"
;
}
std
::
string
name
()
const
{
return
"flatten"
;
}
};
};
...
@@ -370,9 +370,9 @@ struct binary
...
@@ -370,9 +370,9 @@ struct binary
{
{
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
// TODO(wsttiger@gmail.com) Check this for numpy-style broadcasting operations
// TODO(wsttiger@gmail.com) Check this for numpy-style broadcasting operations
check_shapes
{
inputs
}.
has
(
2
).
same_type
().
same_dims
();
check_shapes
{
inputs
}.
has
(
2
).
same_type
().
same_dims
();
return
inputs
.
at
(
0
);
return
inputs
.
at
(
0
);
}
}
};
};
...
...
src/targets/cpu/cpu_target.cpp
View file @
8ace7fb5
...
@@ -8,7 +8,10 @@ namespace rtg {
...
@@ -8,7 +8,10 @@ namespace rtg {
namespace
cpu
{
namespace
cpu
{
template
<
typename
T
>
template
<
typename
T
>
T
zero
(
const
T
&
)
{
return
T
(
0
);
}
T
zero
(
const
T
&
)
{
return
T
(
0
);
}
struct
cpu_convolution
struct
cpu_convolution
{
{
...
@@ -53,14 +56,11 @@ struct cpu_convolution
...
@@ -53,14 +56,11 @@ struct cpu_convolution
struct
cpu_reshape
struct
cpu_reshape
{
{
reshape
op
;
reshape
op
;
std
::
string
name
()
const
{
return
"cpu::reshape"
;
}
std
::
string
name
()
const
{
return
"cpu::reshape"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
return
op
.
compute_shape
(
inputs
);
}
{
return
op
.
compute_shape
(
inputs
);
}
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
{
return
{
output_shape
,
std
::
move
(
args
.
front
().
data
)};
return
{
output_shape
,
std
::
move
(
args
.
front
().
data
)};
}
}
...
@@ -70,12 +70,9 @@ struct cpu_gemm
...
@@ -70,12 +70,9 @@ struct cpu_gemm
{
{
gemm
op
;
gemm
op
;
std
::
string
name
()
const
{
return
"cpu::gemm"
;
}
std
::
string
name
()
const
{
return
"cpu::gemm"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
return
op
.
compute_shape
(
inputs
);
}
{
return
op
.
compute_shape
(
inputs
);
}
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
{
argument
result
{
output_shape
};
argument
result
{
output_shape
};
visit_all
(
result
,
args
[
0
],
args
[
1
])([
&
](
auto
cmat
,
auto
amat
,
auto
bmat
)
{
visit_all
(
result
,
args
[
0
],
args
[
1
])([
&
](
auto
cmat
,
auto
amat
,
auto
bmat
)
{
...
@@ -86,20 +83,25 @@ struct cpu_gemm
...
@@ -86,20 +83,25 @@ struct cpu_gemm
auto
a
=
amat
.
data
();
auto
a
=
amat
.
data
();
auto
b
=
bmat
.
data
();
auto
b
=
bmat
.
data
();
auto
c
=
cmat
.
data
();
auto
c
=
cmat
.
data
();
for
(
int
ii
=
0
;
ii
<
m
;
ii
++
)
{
for
(
int
ii
=
0
;
ii
<
m
;
ii
++
)
for
(
int
jj
=
0
;
jj
<
n
;
jj
++
)
{
{
c
[
ii
*
n
+
jj
]
=
0
;
for
(
int
jj
=
0
;
jj
<
n
;
jj
++
)
}
{
c
[
ii
*
n
+
jj
]
=
0
;
}
}
}
for
(
int
ii
=
0
;
ii
<
m
;
ii
++
)
{
for
(
int
ii
=
0
;
ii
<
m
;
ii
++
)
for
(
int
kk
=
0
;
kk
<
k
;
kk
++
)
{
{
auto
aik
=
a
[
ii
*
k
+
kk
];
for
(
int
kk
=
0
;
kk
<
k
;
kk
++
)
auto
*
bkj
=
&
b
[
kk
*
n
];
{
auto
*
cij
=
&
c
[
ii
*
n
];
auto
aik
=
a
[
ii
*
k
+
kk
];
for
(
int
jj
=
0
;
jj
<
n
;
jj
++
,
cij
++
,
bkj
++
)
{
auto
*
bkj
=
&
b
[
kk
*
n
];
*
cij
+=
aik
*
(
*
bkj
);
auto
*
cij
=
&
c
[
ii
*
n
];
for
(
int
jj
=
0
;
jj
<
n
;
jj
++
,
cij
++
,
bkj
++
)
{
*
cij
+=
aik
*
(
*
bkj
);
}
}
}
}
}
}
});
});
return
result
;
return
result
;
...
@@ -108,176 +110,227 @@ struct cpu_gemm
...
@@ -108,176 +110,227 @@ struct cpu_gemm
struct
identity_op
struct
identity_op
{
{
std
::
string
name
()
const
{
return
"cpu::identity"
;
}
std
::
string
name
()
const
{
return
"cpu::identity"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
x
;
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
x
;
};
}
};
};
struct
abs_op
struct
abs_op
{
{
std
::
string
name
()
const
{
return
"cpu::abs"
;
}
std
::
string
name
()
const
{
return
"cpu::abs"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
abs
(
x
);
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
abs
(
x
);
};
}
};
};
struct
exp_op
struct
exp_op
{
{
std
::
string
name
()
const
{
return
"cpu::exp"
;
}
std
::
string
name
()
const
{
return
"cpu::exp"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
exp
(
x
);
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
exp
(
x
);
};
}
};
};
struct
sin_op
struct
sin_op
{
{
std
::
string
name
()
const
{
return
"cpu::sin"
;
}
std
::
string
name
()
const
{
return
"cpu::sin"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
sin
(
x
);
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
sin
(
x
);
};
}
};
};
struct
cos_op
struct
cos_op
{
{
std
::
string
name
()
const
{
return
"cpu::cos"
;
}
std
::
string
name
()
const
{
return
"cpu::cos"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
cos
(
x
);
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
cos
(
x
);
};
}
};
};
struct
tan_op
struct
tan_op
{
{
std
::
string
name
()
const
{
return
"cpu::tan"
;
}
std
::
string
name
()
const
{
return
"cpu::tan"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
tan
(
x
);
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
tan
(
x
);
};
}
};
};
struct
asin_op
struct
asin_op
{
{
std
::
string
name
()
const
{
return
"cpu::asin"
;
}
std
::
string
name
()
const
{
return
"cpu::asin"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
asin
(
x
);
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
asin
(
x
);
};
}
};
};
struct
acos_op
struct
acos_op
{
{
std
::
string
name
()
const
{
return
"cpu::acos"
;
}
std
::
string
name
()
const
{
return
"cpu::acos"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
acos
(
x
);
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
acos
(
x
);
};
}
};
};
struct
atan_op
struct
atan_op
{
{
std
::
string
name
()
const
{
return
"cpu::atan"
;
}
std
::
string
name
()
const
{
return
"cpu::atan"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
atan
(
x
);
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
atan
(
x
);
};
}
};
};
struct
tanh_op
struct
tanh_op
{
{
std
::
string
name
()
const
{
return
"cpu::tanh"
;
}
std
::
string
name
()
const
{
return
"cpu::tanh"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
tanh
(
x
);
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
tanh
(
x
);
};
}
};
};
struct
sigmoid_op
struct
sigmoid_op
{
{
std
::
string
name
()
const
{
return
"cpu::sigmoid"
;
}
std
::
string
name
()
const
{
return
"cpu::sigmoid"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
1.
f
/
(
1.
f
+
std
::
exp
(
-
x
));
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
1.
f
/
(
1.
f
+
std
::
exp
(
-
x
));
};
}
};
};
struct
neg_op
struct
neg_op
{
{
std
::
string
name
()
const
{
return
"cpu::neg"
;
}
std
::
string
name
()
const
{
return
"cpu::neg"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
-
x
;
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
-
x
;
};
}
};
};
struct
relu_op
struct
relu_op
{
{
std
::
string
name
()
const
{
return
"cpu::relu"
;
}
std
::
string
name
()
const
{
return
"cpu::relu"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
x
>
0
?
x
:
0
;
};
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
x
>
0
?
x
:
0
;
};
}
};
};
template
<
typename
Op
>
template
<
typename
Op
>
struct
cpu_unary
struct
cpu_unary
{
{
Op
op
;
Op
op
;
std
::
string
name
()
const
{
return
op
.
name
();
}
std
::
string
name
()
const
{
return
op
.
name
();
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
return
inputs
.
front
();
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
return
inputs
.
front
();
}
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
{
argument
result
{
output_shape
};
argument
result
{
output_shape
};
result
.
visit
([
&
](
auto
output
)
{
result
.
visit
([
&
](
auto
output
)
{
args
[
0
].
visit
([
&
](
auto
input
)
{
args
[
0
].
visit
([
&
](
auto
input
)
{
std
::
transform
(
input
.
begin
(),
input
.
end
(),
output
.
begin
(),
op
.
fcn
());
std
::
transform
(
input
.
begin
(),
input
.
end
(),
output
.
begin
(),
op
.
fcn
());
});
});
});
});
return
result
;
return
result
;
}
}
};
};
struct
softmax2d
struct
softmax2d
{
{
std
::
string
name
()
const
{
return
"cpu::softmax2d"
;
}
std
::
string
name
()
const
{
return
"cpu::softmax2d"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
return
inputs
.
front
();
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
return
inputs
.
front
();
}
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
{
argument
result
{
output_shape
};
argument
result
{
output_shape
};
visit_all
(
result
,
args
[
0
])([
&
](
auto
output
,
auto
input
)
{
visit_all
(
result
,
args
[
0
])([
&
](
auto
output
,
auto
input
)
{
using
value_type
=
typename
decltype
(
input
)
::
value_type
;
using
value_type
=
typename
decltype
(
input
)
::
value_type
;
auto
nb
=
input
.
get_shape
().
lens
()[
0
];
auto
nb
=
input
.
get_shape
().
lens
()[
0
];
auto
nc
=
input
.
get_shape
().
lens
()[
1
];
auto
nc
=
input
.
get_shape
().
lens
()[
1
];
auto
nh
=
input
.
get_shape
().
lens
()[
2
];
auto
nh
=
input
.
get_shape
().
lens
()[
2
];
auto
nw
=
input
.
get_shape
().
lens
()[
3
];
auto
nw
=
input
.
get_shape
().
lens
()[
3
];
for
(
int
b
=
0
;
b
<
nb
;
b
++
)
{
dfor
(
nb
,
nh
,
nw
)([
&
](
std
::
size_t
b
,
std
::
size_t
i
,
std
::
size_t
j
)
{
for
(
int
i
=
0
;
i
<
nh
;
i
++
)
{
value_type
cmax
=
std
::
numeric_limits
<
value_type
>::
lowest
();
for
(
int
j
=
0
;
j
<
n
w
;
j
++
)
{
for
(
int
c
=
0
;
c
<
n
c
;
c
++
)
value_type
cmax
=
std
::
numeric_limits
<
value_type
>::
lowest
();
{
for
(
int
c
=
0
;
c
<
nc
;
c
++
)
{
cmax
=
std
::
max
(
cmax
,
input
(
b
,
c
,
i
,
j
));
cmax
=
std
::
max
(
cmax
,
input
(
b
,
c
,
i
,
j
));
}
}
for
(
int
c
=
0
;
c
<
nc
;
c
++
)
for
(
int
c
=
0
;
c
<
nc
;
c
++
)
{
{
output
(
b
,
c
,
i
,
j
)
=
std
::
exp
(
input
(
b
,
c
,
i
,
j
)
-
cmax
);
output
(
b
,
c
,
i
,
j
)
=
std
::
exp
(
input
(
b
,
c
,
i
,
j
)
-
cmax
);
}
}
value_type
sum
=
value_type
(
0
);
value_type
sum
=
value_type
(
0
);
for
(
int
c
=
0
;
c
<
nc
;
c
++
)
{
for
(
int
c
=
0
;
c
<
nc
;
c
++
)
sum
+=
output
(
b
,
c
,
i
,
j
);
{
}
sum
+=
output
(
b
,
c
,
i
,
j
);
for
(
int
c
=
0
;
c
<
nc
;
c
++
)
{
}
output
(
b
,
c
,
i
,
j
)
=
output
(
b
,
c
,
i
,
j
)
/
sum
;
for
(
int
c
=
0
;
c
<
nc
;
c
++
)
}
{
}
output
(
b
,
c
,
i
,
j
)
=
output
(
b
,
c
,
i
,
j
)
/
sum
;
}
}
}
});
});
});
return
result
;
return
result
;
}
}
};
};
struct
add_op
struct
add_op
{
{
std
::
string
name
()
const
{
return
"add"
;
}
std
::
string
name
()
const
{
return
"add"
;
}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
+
y
;};}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
+
y
;
};
}
};
};
struct
sub_op
struct
sub_op
{
{
std
::
string
name
()
const
{
return
"sub"
;
}
std
::
string
name
()
const
{
return
"sub"
;
}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
-
y
;};}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
-
y
;
};
}
};
};
struct
mul_op
struct
mul_op
{
{
std
::
string
name
()
const
{
return
"mul"
;
}
std
::
string
name
()
const
{
return
"mul"
;
}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
*
y
;};}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
*
y
;
};
}
};
};
struct
div_op
struct
div_op
{
{
std
::
string
name
()
const
{
return
"div"
;
}
std
::
string
name
()
const
{
return
"div"
;
}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
/
y
;};}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
/
y
;
};
}
};
};
template
<
typename
Op
>
template
<
typename
Op
>
struct
cpu_binary
struct
cpu_binary
{
{
Op
op
;
Op
op
;
std
::
string
name
()
const
{
op
.
name
();
}
std
::
string
name
()
const
{
return
op
.
name
();
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
return
inputs
.
front
();
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
return
inputs
.
front
();
}
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
{
argument
result
{
output_shape
};
argument
result
{
output_shape
};
visit_all
(
result
,
args
[
0
],
args
[
1
])([
&
](
auto
output
,
auto
input1
,
auto
input2
)
{
visit_all
(
result
,
args
[
0
],
args
[
1
])([
&
](
auto
output
,
auto
input1
,
auto
input2
)
{
std
::
transform
(
input1
.
begin
(),
input1
.
end
(),
input2
.
begin
(),
output
.
begin
(),
op
.
fcn
());
std
::
transform
(
input1
.
begin
(),
input1
.
end
(),
input2
.
begin
(),
output
.
begin
(),
op
.
fcn
());
});
});
return
result
;
return
result
;
}
}
};
};
struct
cpu_apply
struct
cpu_apply
...
...
test/cpu_ops_test.cpp
View file @
8ace7fb5
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment