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
919d9ec2
Commit
919d9ec2
authored
Mar 12, 2019
by
Ashok Emani
Committed by
Robert Kimball
Mar 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add QuantizedConcat varying min/max test (#2571)
parent
fb7e61da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
2 deletions
+50
-2
quantization_util.hpp
src/ngraph/builder/quantization_util.hpp
+2
-2
builder_quantization.cpp
test/builder_quantization.cpp
+48
-0
No files found.
src/ngraph/builder/quantization_util.hpp
View file @
919d9ec2
...
...
@@ -268,9 +268,9 @@ namespace ngraph
throw
ngraph_error
(
"check_concat: min and max must have same type"
);
}
if
(
min
->
get_shape
()
!=
Shape
{
1
}
||
m
in
->
get_shape
()
!=
Shape
{
1
})
if
(
min
->
get_shape
()
!=
Shape
{
1
}
||
m
ax
->
get_shape
()
!=
Shape
{
1
})
{
throw
ngraph_error
(
"check_concat: min
and max must have same shape
"
+
throw
ngraph_error
(
"check_concat: min
/max shape not Shape{1}:
"
+
vector_to_string
(
min
->
get_shape
())
+
vector_to_string
(
max
->
get_shape
()));
}
...
...
test/builder_quantization.cpp
View file @
919d9ec2
...
...
@@ -1133,3 +1133,51 @@ TEST(builder, scaled_quantize_concat_signed)
EXPECT_EQ
((
vector
<
int8_t
>
{
-
2
,
4
,
8
,
16
,
-
2
,
2
,
4
,
8
,
16
,
15
,
-
2
,
3
,
5
,
7
,
11
,
16
}),
read_vector
<
int8_t
>
(
result
));
}
TEST
(
builder
,
scaled_quantize_concat_unsigned_varying
)
{
Shape
shape_a
{
2
,
3
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
u8
,
shape_a
);
auto
An
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
1
});
auto
Ax
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
1
});
Shape
shape_b
{
2
,
3
};
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
u8
,
shape_b
);
auto
Bn
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
1
});
auto
Bx
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
1
});
Shape
shape_c
{
2
,
3
};
auto
C
=
make_shared
<
op
::
Parameter
>
(
element
::
u8
,
shape_c
);
auto
Cn
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
1
});
auto
Cx
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
1
});
Shape
shape_r
{
2
,
9
};
auto
QConcat
=
ngraph
::
builder
::
ScaledQuantizedConcat
(
NodeVector
{
A
,
B
,
C
},
1
,
NodeVector
{
An
,
Bn
,
Cn
},
NodeVector
{
Ax
,
Bx
,
Cx
});
auto
f
=
make_shared
<
Function
>
(
NodeVector
{
QConcat
},
ParameterVector
{
A
,
B
,
C
,
An
,
Bn
,
Cn
,
Ax
,
Bx
,
Cx
});
auto
backend
=
runtime
::
Backend
::
create
(
"CPU"
);
// Create some tensors for input/output
auto
a
=
backend
->
create_tensor
(
element
::
u8
,
shape_a
);
copy_data
(
a
,
vector
<
uint8_t
>
{
5
,
1
,
0
,
1
,
5
,
100
});
auto
b
=
backend
->
create_tensor
(
element
::
u8
,
shape_b
);
copy_data
(
b
,
vector
<
uint8_t
>
{
0
,
2
,
4
,
6
,
8
,
10
});
auto
c
=
backend
->
create_tensor
(
element
::
u8
,
shape_c
);
copy_data
(
c
,
vector
<
uint8_t
>
{
1
,
3
,
5
,
7
,
9
,
50
});
// min/max vectors
auto
an
=
backend
->
create_tensor
(
element
::
f32
,
Shape
{
1
});
copy_data
(
an
,
vector
<
float
>
{
-
3.0
});
auto
ax
=
backend
->
create_tensor
(
element
::
f32
,
Shape
{
1
});
copy_data
(
ax
,
vector
<
float
>
{
1.0
});
auto
bn
=
backend
->
create_tensor
(
element
::
f32
,
Shape
{
1
});
copy_data
(
bn
,
vector
<
float
>
{
-
3.0
});
auto
bx
=
backend
->
create_tensor
(
element
::
f32
,
Shape
{
1
});
copy_data
(
bx
,
vector
<
float
>
{
2.0
});
auto
cn
=
backend
->
create_tensor
(
element
::
f32
,
Shape
{
1
});
copy_data
(
cn
,
vector
<
float
>
{
-
3.0
});
auto
cx
=
backend
->
create_tensor
(
element
::
f32
,
Shape
{
1
});
copy_data
(
cx
,
vector
<
float
>
{
1.0
});
// result
auto
result
=
backend
->
create_tensor
(
element
::
u8
,
shape_r
);
auto
handle
=
backend
->
compile
(
f
);
handle
->
call_with_validate
({
result
},
{
a
,
b
,
c
,
an
,
bn
,
cn
,
ax
,
bx
,
cx
});
EXPECT_EQ
((
vector
<
uint8_t
>
{
5
,
1
,
0
,
0
,
2
,
4
,
1
,
3
,
5
,
1
,
5
,
100
,
6
,
8
,
10
,
7
,
9
,
50
}),
read_vector
<
uint8_t
>
(
result
));
}
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