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
ede578a6
Commit
ede578a6
authored
Aug 24, 2017
by
Bob Kimball
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
494b16cd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
52 deletions
+45
-52
element_type.hpp
src/ngraph/element_type.hpp
+32
-31
type.hpp
src/ngraph/type.hpp
+3
-3
element_type.cpp
src/types/element_type.cpp
+5
-13
build_graph.cpp
test/build_graph.cpp
+5
-5
No files found.
src/ngraph/element_type.hpp
View file @
ede578a6
...
...
@@ -23,36 +23,37 @@
namespace
ngraph
{
class
ElementType
;
}
class
ngraph
::
ElementType
{
public
:
ElementType
(
size_t
bitwidth
,
bool
is_float
,
bool
is_signed
,
const
std
::
string
&
cname
);
const
std
::
string
&
c_type_string
()
const
;
size_t
size
()
const
;
size_t
hash
()
const
namespace
element
{
std
::
hash
<
std
::
string
>
h
;
return
h
(
m_cname
);
class
Type
{
public
:
Type
(
size_t
bitwidth
,
bool
is_float
,
bool
is_signed
,
const
std
::
string
&
cname
);
const
std
::
string
&
c_type_string
()
const
;
size_t
size
()
const
;
size_t
hash
()
const
{
std
::
hash
<
std
::
string
>
h
;
return
h
(
m_cname
);
}
bool
operator
==
(
const
Type
&
other
)
const
;
private
:
static
std
::
map
<
std
::
string
,
Type
>
m_element_list
;
size_t
m_bitwidth
;
bool
m_is_float
;
bool
m_is_signed
;
const
std
::
string
m_cname
;
};
const
Type
float32_t
=
Type
(
32
,
true
,
true
,
"float"
);
const
Type
int8_t
=
Type
(
8
,
false
,
true
,
"int8_t"
);
const
Type
int32_t
=
Type
(
32
,
false
,
true
,
"int32_t"
);
const
Type
int64_t
=
Type
(
64
,
false
,
true
,
"int64_t"
);
const
Type
uint8_t
=
Type
(
8
,
false
,
false
,
"int8_t"
);
const
Type
uint32_t
=
Type
(
32
,
false
,
false
,
"int32_t"
);
const
Type
uint64_t
=
Type
(
64
,
false
,
false
,
"int64_t"
);
}
bool
operator
==
(
const
ElementType
&
other
)
const
;
private
:
static
std
::
map
<
std
::
string
,
ElementType
>
m_element_list
;
size_t
m_bitwidth
;
bool
m_is_float
;
bool
m_is_signed
;
const
std
::
string
m_cname
;
};
extern
const
ngraph
::
ElementType
element_type_float
;
extern
const
ngraph
::
ElementType
element_type_int8_t
;
extern
const
ngraph
::
ElementType
element_type_int32_t
;
extern
const
ngraph
::
ElementType
element_type_int64_t
;
extern
const
ngraph
::
ElementType
element_type_uint8_t
;
extern
const
ngraph
::
ElementType
element_type_uint32_t
;
extern
const
ngraph
::
ElementType
element_type_uint64_t
;
}
src/ngraph/type.hpp
View file @
ede578a6
...
...
@@ -51,14 +51,14 @@ namespace ngraph
** /param element_type The type of the tensor elements.
** /param shape The shape of the tensor.
**/
TensorViewType
(
const
Element
Type
&
element_type
,
const
Shape
&
shape
)
TensorViewType
(
const
element
::
Type
&
element_type
,
const
Shape
&
shape
)
:
m_element_type
(
element_type
)
,
m_shape
(
shape
)
{
}
protected
:
const
Element
Type
&
m_element_type
;
const
element
::
Type
&
m_element_type
;
Shape
m_shape
;
};
...
...
@@ -115,7 +115,7 @@ namespace ngraph
** /param element_type The type of the tensor elements
** /param shape The shape of the view
**/
void
type
(
const
Element
Type
&
element_type
,
const
Shape
&
shape
)
void
type
(
const
element
::
Type
&
element_type
,
const
Shape
&
shape
)
{
m_type
=
std
::
make_shared
<
TensorViewType
>
(
element_type
,
shape
);
}
...
...
src/types/element_type.cpp
View file @
ede578a6
...
...
@@ -17,17 +17,9 @@
#include "ngraph/element_type.hpp"
const
ngraph
::
ElementType
element_type_float
=
ngraph
::
ElementType
(
32
,
true
,
true
,
"float"
);
const
ngraph
::
ElementType
element_type_int8_t
=
ngraph
::
ElementType
(
8
,
false
,
true
,
"int8_t"
);
const
ngraph
::
ElementType
element_type_int32_t
=
ngraph
::
ElementType
(
32
,
false
,
true
,
"int32_t"
);
const
ngraph
::
ElementType
element_type_int64_t
=
ngraph
::
ElementType
(
64
,
false
,
true
,
"int64_t"
);
const
ngraph
::
ElementType
element_type_uint8_t
=
ngraph
::
ElementType
(
8
,
false
,
false
,
"int8_t"
);
const
ngraph
::
ElementType
element_type_uint32_t
=
ngraph
::
ElementType
(
32
,
false
,
false
,
"int32_t"
);
const
ngraph
::
ElementType
element_type_uint64_t
=
ngraph
::
ElementType
(
64
,
false
,
false
,
"int64_t"
);
std
::
map
<
std
::
string
,
ngraph
::
element
::
Type
>
ngraph
::
element
::
Type
::
m_element_list
;
std
::
map
<
std
::
string
,
ngraph
::
ElementType
>
ngraph
::
ElementType
::
m_element_list
;
ngraph
::
ElementType
::
ElementType
(
size_t
bitwidth
,
ngraph
::
element
::
Type
::
Type
(
size_t
bitwidth
,
bool
is_float
,
bool
is_signed
,
const
std
::
string
&
cname
)
...
...
@@ -39,18 +31,18 @@ ngraph::ElementType::ElementType(size_t bitwidth,
assert
(
m_bitwidth
%
8
==
0
);
}
const
std
::
string
&
ngraph
::
Element
Type
::
c_type_string
()
const
const
std
::
string
&
ngraph
::
element
::
Type
::
c_type_string
()
const
{
return
m_cname
;
}
bool
ngraph
::
ElementType
::
operator
==
(
const
Element
Type
&
other
)
const
bool
ngraph
::
element
::
Type
::
operator
==
(
const
element
::
Type
&
other
)
const
{
return
m_bitwidth
==
other
.
m_bitwidth
&&
m_is_float
==
other
.
m_is_float
&&
m_is_signed
==
other
.
m_is_signed
;
}
size_t
ngraph
::
Element
Type
::
size
()
const
size_t
ngraph
::
element
::
Type
::
size
()
const
{
return
std
::
ceil
((
float
)
m_bitwidth
/
8.0
);
}
test/build_graph.cpp
View file @
ede578a6
...
...
@@ -23,11 +23,11 @@ TEST(graph, build_simple)
{
// Function with 4 parameters
auto
cluster_0
=
make_shared
<
Function
>
(
4
);
cluster_0
->
result
()
->
type
(
element
_type_floa
t
,
{
32
,
3
});
cluster_0
->
parameter
(
0
)
->
type
(
element
_type_floa
t
,
{
7
,
3
});
cluster_0
->
parameter
(
1
)
->
type
(
element
_type_floa
t
,
{
3
});
cluster_0
->
parameter
(
2
)
->
type
(
element
_type_floa
t
,
{
32
,
7
});
cluster_0
->
parameter
(
3
)
->
type
(
element
_type_floa
t
,
{
32
,
7
});
cluster_0
->
result
()
->
type
(
element
::
float32_
t
,
{
32
,
3
});
cluster_0
->
parameter
(
0
)
->
type
(
element
::
float32_
t
,
{
7
,
3
});
cluster_0
->
parameter
(
1
)
->
type
(
element
::
float32_
t
,
{
3
});
cluster_0
->
parameter
(
2
)
->
type
(
element
::
float32_
t
,
{
32
,
7
});
cluster_0
->
parameter
(
3
)
->
type
(
element
::
float32_
t
,
{
32
,
7
});
auto
arg3
=
cluster_0
->
parameter
(
3
);
// call broadcast op on arg3, broadcasting on axis 1.
auto
broadcast_1
=
op
::
broadcast
(
arg3
,
1
);
...
...
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