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
076ff46f
Commit
076ff46f
authored
Jan 26, 2018
by
Jaikrishnan Menon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
d375f9a9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
206 additions
and
0 deletions
+206
-0
CMakeLists.txt
src/ngraph/CMakeLists.txt
+2
-0
cpu_layout_descriptor.cpp
src/ngraph/runtime/cpu/cpu_layout_descriptor.cpp
+62
-0
cpu_layout_descriptor.hpp
src/ngraph/runtime/cpu/cpu_layout_descriptor.hpp
+79
-0
cpu_layout.cpp
src/ngraph/runtime/cpu/pass/cpu_layout.cpp
+27
-0
cpu_layout.hpp
src/ngraph/runtime/cpu/pass/cpu_layout.hpp
+36
-0
No files found.
src/ngraph/CMakeLists.txt
View file @
076ff46f
...
@@ -169,6 +169,8 @@ if (NGRAPH_CPU_ENABLE AND LLVM_INCLUDE_DIR AND
...
@@ -169,6 +169,8 @@ if (NGRAPH_CPU_ENABLE AND LLVM_INCLUDE_DIR AND
runtime/cpu/cpu_emitter.cpp
runtime/cpu/cpu_emitter.cpp
runtime/cpu/cpu_external_function.cpp
runtime/cpu/cpu_external_function.cpp
runtime/cpu/cpu_tensor_view_wrapper.cpp
runtime/cpu/cpu_tensor_view_wrapper.cpp
runtime/cpu/cpu_layout_descriptor.cpp
runtime/cpu/pass/cpu_layout.cpp
)
)
# LLVM binary builds are typically built without RTTI
# LLVM binary builds are typically built without RTTI
# The built-in headers are in a version-specific directory
# The built-in headers are in a version-specific directory
...
...
src/ngraph/runtime/cpu/cpu_layout_descriptor.cpp
0 → 100644
View file @
076ff46f
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include "cpu_layout_descriptor.hpp"
namespace
ngraph
{
namespace
runtime
{
namespace
cpu
{
const
AxisVector
LayoutDescriptor
::
Native2DAxisOrder
{
0
,
1
};
const
AxisVector
LayoutDescriptor
::
Native4DAxisOrder
{
0
,
1
,
2
,
3
};
const
AxisVector
LayoutDescriptor
::
CHWNAxisOrder
{
1
,
2
,
3
,
0
};
size_t
LayoutDescriptor
::
get_index_offset
(
const
std
::
vector
<
size_t
>&
indices
)
{
if
(
indices
.
size
()
!=
strides
.
size
())
{
throw
ngraph_error
(
"Indices have the incorrect rank."
);
}
size_t
result
=
0
;
for
(
int
i
=
0
;
i
<
indices
.
size
();
i
++
)
{
result
+=
strides
[
i
]
+
indices
[
i
];
}
return
result
;
}
bool
LayoutDescriptor
::
operator
==
(
const
ngraph
::
descriptor
::
layout
::
TensorViewLayout
&
other
)
const
{
const
LayoutDescriptor
*
p_other
=
dynamic_cast
<
const
LayoutDescriptor
*>
(
&
other
);
if
(
!
p_other
)
return
false
;
if
(
get_element_type
()
!=
p_other
->
get_element_type
())
return
false
;
if
(
strides
!=
p_other
->
strides
)
return
false
;
if
(
offset
!=
p_other
->
offset
)
return
false
;
//TODO: Numeric backend-specific properties
return
true
;
}
}
}
}
src/ngraph/runtime/cpu/cpu_layout_descriptor.hpp
0 → 100644
View file @
076ff46f
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
#include <cstdint>
#include <mkldnn_types.h>
#include "ngraph/common.hpp"
#include "ngraph/shape.hpp"
#include "ngraph/descriptor/layout/tensor_view_layout.hpp"
#include "ngraph/types/type.hpp"
namespace
ngraph
{
namespace
runtime
{
namespace
cpu
{
class
LayoutDescriptor
:
public
ngraph
::
descriptor
::
layout
::
TensorViewLayout
{
public
:
LayoutDescriptor
(
const
ngraph
::
descriptor
::
TensorView
&
tv
,
const
AxisVector
&
tv_axis_order
)
:
TensorViewLayout
(
tv
)
,
axis_order
(
tv_axis_order
)
,
offset
(
0
)
,
size
(
ngraph
::
shape_size
(
tv
.
get_tensor_view_type
()
->
get_shape
()))
,
mkldnn_format
(
mkldnn_format_undef
)
{
if
(
tv_axis_order
==
Native2DAxisOrder
||
tv_axis_order
==
Native4DAxisOrder
)
{
strides
=
ngraph
::
row_major_strides
(
get_shape
());
}
else
{
throw
ngraph_error
(
"Axis ordering not handled yet"
);
}
}
size_t
get_size
()
override
{
return
size
;
}
size_t
get_offset
()
const
{
return
offset
;
}
size_t
get_index_offset
(
const
std
::
vector
<
size_t
>&
indices
)
override
;
const
Strides
&
get_strides
()
const
override
{
return
strides
;
}
bool
operator
==
(
const
TensorViewLayout
&
other
)
const
override
;
mkldnn_memory_format_t
get_mkldnn_format
()
const
{
return
mkldnn_format
;
}
static
const
AxisVector
Native2DAxisOrder
;
static
const
AxisVector
Native4DAxisOrder
;
static
const
AxisVector
CHWNAxisOrder
;
private
:
AxisVector
axis_order
;
Strides
strides
;
size_t
offset
;
size_t
size
;
// Numeric backend-specific fields
mkldnn_memory_format_t
mkldnn_format
;
};
}
}
}
src/ngraph/runtime/cpu/pass/cpu_layout.cpp
0 → 100644
View file @
076ff46f
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include "cpu_layout.hpp"
using
namespace
ngraph
::
runtime
::
cpu
::
pass
;
bool
CPULayout
::
run_on_call_graph
(
const
std
::
list
<
std
::
shared_ptr
<
Node
>>&
nodes
)
{
for
(
const
auto
&
node
:
nodes
)
{
}
return
false
;
}
src/ngraph/runtime/cpu/pass/cpu_layout.hpp
0 → 100644
View file @
076ff46f
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
#include "ngraph/pass/pass.hpp"
#include "ngraph/runtime/cpu/cpu_layout_descriptor.hpp"
namespace
ngraph
{
namespace
runtime
{
namespace
cpu
{
namespace
pass
{
class
CPULayout
:
public
ngraph
::
pass
::
CallGraphPass
{
public
:
virtual
bool
run_on_call_graph
(
const
std
::
list
<
std
::
shared_ptr
<
Node
>>&
nodes
)
override
;
};
}
}
}
}
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