Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNNL] Add support of QNN primitives for DNNL runtime #9618

Closed
wants to merge 15 commits into from
Prev Previous commit
Next Next commit
fix lint
Signed-off-by: Alexander Peskov <[email protected]>
apeskov committed Jan 12, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 008f1a94e9048bb2503edef0f9123f8b3797262b
4 changes: 2 additions & 2 deletions src/relay/backend/contrib/dnnl/composite_op.h
Original file line number Diff line number Diff line change
@@ -165,7 +165,7 @@ qnn_arg_set_dnnl qnnReformulate(const qnn_arg_set_relay &origin) {
+ cast<float>(r.sum_out_zp) * r.sum_out_scl / r.sum_lh_scl * r.rq_out_scl / r.rq_in_scl;

return res.evalAndCollapseToScalar();
};
}

/*!
* @brief Specify optional QNN args and attrs if required
@@ -249,7 +249,7 @@ void optQnnArgsForRqSumPattern(const Expr &wgh, const Expr &bias, const OpSeq::L

(*attrs)["activation"] = dmlc_attr(clip_attr);
}
};
}

/*!
* Legalize bias shape to 1D form
2 changes: 1 addition & 1 deletion src/runtime/contrib/dnnl/dnnl_json_runtime.cc
Original file line number Diff line number Diff line change
@@ -502,7 +502,7 @@ class DNNLJSONRuntime : public JSONRuntimeBase {
// TODO(@apeskov): DNNL v2.5 and late has API for separate scale and shift
// it will eliminate requirements of data copy.
// Prepare concatenated Scale and Shift tensor
auto scale_shift_tr = node.makeTemp(bn_pd.weights_desc());
auto scale_shift_tr = node.makeTemp(bn_pd.weights_desc(), g_explorer_.generateUniqueEID());
auto sc_sh_dims = scale_shift_tr.dims();
ICHECK(sc_sh_dims.size() == 2);
ICHECK(sc_sh_dims[0] == 2);
8 changes: 4 additions & 4 deletions src/runtime/contrib/dnnl/dnnl_node_helper.h
Original file line number Diff line number Diff line change
@@ -691,7 +691,7 @@ struct GraphExplorer {

class NodeHelper {
public:
NodeHelper(const uint32_t& nid, GraphExplorer &graph_explorer)
NodeHelper(const uint32_t& nid, const GraphExplorer& graph_explorer)
: nid_(nid), node_(graph_explorer.nodes_[nid]), graph_explorer_(graph_explorer) {}

template <typename T>
@@ -775,8 +775,8 @@ class NodeHelper {
return {desc, nullptr, true, {}, eid, true};
}

TensorRequisite makeTemp(const dnnl::memory::desc& desc) {
return {desc, nullptr, false, {}, graph_explorer_.generateUniqueEID(), true};
TensorRequisite makeTemp(const dnnl::memory::desc& desc, uint32_t eid) {
return {desc, nullptr, false, {}, eid, true};
}

TensorRequisite makeScratchpad(const dnnl::memory::desc& desc) {
@@ -786,7 +786,7 @@ class NodeHelper {
private:
const uint32_t nid_;
const json::JSONGraphNode& node_;
GraphExplorer &graph_explorer_;
const GraphExplorer& graph_explorer_;
};

} // namespace contrib