Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
0e6aae41
Commit
0e6aae41
authored
Oct 23, 2017
by
Jaikrishnan Menon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CPU: Implement op::Abs
parent
d84d1557
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
4 deletions
+31
-4
emitter.cpp
src/ngraph/runtime/cpu/emitter.cpp
+20
-0
emitter.hpp
src/ngraph/runtime/cpu/emitter.hpp
+6
-0
external_function.cpp
src/ngraph/runtime/cpu/external_function.cpp
+2
-1
cpu.cpp
test/cpu.cpp
+3
-3
No files found.
src/ngraph/runtime/cpu/emitter.cpp
View file @
0e6aae41
...
@@ -148,3 +148,23 @@ void Emitter::EmitTuple(const ngraph::Node* n,
...
@@ -148,3 +148,23 @@ void Emitter::EmitTuple(const ngraph::Node* n,
}
}
TU
+=
" }
\n
"
;
TU
+=
" }
\n
"
;
}
}
void
Emitter
::
EmitAbs
(
const
ngraph
::
Node
*
n
,
ExternalFunction
*
ef
,
FunctionMap
&
function_map
,
const
std
::
vector
<
TensorViewInfo
>&
inputs
,
const
std
::
vector
<
TensorViewInfo
>&
outputs
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" Eigen::abs(EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
"));
\n
"
" }
\n
"
;
}
src/ngraph/runtime/cpu/emitter.hpp
View file @
0e6aae41
...
@@ -72,6 +72,12 @@ namespace ngraph
...
@@ -72,6 +72,12 @@ namespace ngraph
const
std
::
vector
<
TensorViewInfo
>&
inputs
,
const
std
::
vector
<
TensorViewInfo
>&
inputs
,
const
std
::
vector
<
TensorViewInfo
>&
outputs
);
const
std
::
vector
<
TensorViewInfo
>&
outputs
);
void
EmitAbs
(
const
ngraph
::
Node
*
,
ExternalFunction
*
,
FunctionMap
&
,
const
std
::
vector
<
TensorViewInfo
>&
inputs
,
const
std
::
vector
<
TensorViewInfo
>&
outputs
);
};
};
}
}
}
}
...
...
src/ngraph/runtime/cpu/external_function.cpp
View file @
0e6aae41
...
@@ -71,7 +71,8 @@ static const OpMap dispatcher{{TI(ngraph::op::Add), &Emitter::EmitAdd},
...
@@ -71,7 +71,8 @@ static const OpMap dispatcher{{TI(ngraph::op::Add), &Emitter::EmitAdd},
{
TI
(
ngraph
::
op
::
Multiply
),
&
Emitter
::
EmitMultiply
},
{
TI
(
ngraph
::
op
::
Multiply
),
&
Emitter
::
EmitMultiply
},
{
TI
(
ngraph
::
op
::
Parameter
),
&
Emitter
::
EmitNop
},
{
TI
(
ngraph
::
op
::
Parameter
),
&
Emitter
::
EmitNop
},
{
TI
(
ngraph
::
op
::
GetTupleElement
),
&
Emitter
::
EmitGetTupleElement
},
{
TI
(
ngraph
::
op
::
GetTupleElement
),
&
Emitter
::
EmitGetTupleElement
},
{
TI
(
ngraph
::
op
::
Tuple
),
&
Emitter
::
EmitTuple
}
{
TI
(
ngraph
::
op
::
Tuple
),
&
Emitter
::
EmitTuple
},
{
TI
(
ngraph
::
op
::
Abs
),
&
Emitter
::
EmitAbs
}
};
};
#undef TI
#undef TI
...
...
test/cpu.cpp
View file @
0e6aae41
...
@@ -240,15 +240,14 @@ TEST(cpu, tuple_result)
...
@@ -240,15 +240,14 @@ TEST(cpu, tuple_result)
ASSERT_EQ
((
vector
<
float
>
{
54
,
80
,
110
,
144
}),
r1
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
54
,
80
,
110
,
144
}),
r1
->
get_vector
());
}
}
/*
TEST
(
cpu
,
abs
)
TEST(execute, abs)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Abs
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Abs
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto manager = runtime::Manager::get("
NGVM
");
auto
manager
=
runtime
::
Manager
::
get
(
"
CPU
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -262,6 +261,7 @@ TEST(execute, abs)
...
@@ -262,6 +261,7 @@ TEST(execute, abs)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
0
,
4.8
f
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
0
,
4.8
f
}),
result
->
get_vector
());
}
}
/*
TEST(execute, concat_matrix_colwise)
TEST(execute, concat_matrix_colwise)
{
{
auto shape_a = Shape{2, 2};
auto shape_a = Shape{2, 2};
...
...
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