Skip to content

Commit

Permalink
[luci/pass] Apply VerifyQuantizedNodeType (Samsung#8350)
Browse files Browse the repository at this point in the history
This commit applies `VerifyQuantizedNodeType` to `QuantizedModelVerifier`.

ONE-DCO-1.0-Signed-off-by: Seok NamKoong <[email protected]>
  • Loading branch information
llFreetimell authored Feb 3, 2022
1 parent 5ca0a4f commit e952b4d
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions compiler/luci/pass/src/QuantizedModelVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
#include "QuantizedModelVerifier.h"

#include "VerifyQuantizedNodeGranularity.h"
#include "VerifyQuantizedNodeU8Type.h"
#include "VerifyQuantizedNodeS16Type.h"
#include "VerifyQuantizedNodeType.h"

#include <luci/IR/CircleNodes.h>
#include <luci/IR/CircleNodeVisitor.h>
Expand All @@ -27,9 +26,6 @@ namespace luci

void QuantizedModelVerifier::verify(loco::Graph *g)
{
if (_quantized_dtype != Type::U8 && _quantized_dtype != Type::S16)
throw std::runtime_error("Unsupported quantized dtype");

if (_granularity != Granularity::ChannelWise && _granularity != Granularity::LayerWise)
throw std::runtime_error("Unsupported granularity");

Expand All @@ -45,18 +41,8 @@ void QuantizedModelVerifier::verify(loco::Graph *g)
};

// Verify Type
if (_quantized_dtype == Type::U8)
{
VerifyQuantizedNodeU8Type vt;
if (!circle_node->accept(&vt))
throw std::runtime_error("Wrong data type detected in " + node_name());
}
else if (_quantized_dtype == Type::S16)
{
VerifyQuantizedNodeS16Type vt;
if (!circle_node->accept(&vt))
throw std::runtime_error("Wrong data type detected in " + node_name());
}
if (!VerifyQuantizedNodeType::create(_quantized_dtype)->verify(circle_node))
throw std::runtime_error("Wrong data type detected in " + node_name());

// Verify Granularity
if (!circle_node->accept(VerifyQuantizedNodeGranularity::create(_granularity).get()))
Expand Down

0 comments on commit e952b4d

Please sign in to comment.