Skip to content

Commit

Permalink
[ETHOSN] Add support for Ethos-N 21.02 driver stack release.
Browse files Browse the repository at this point in the history
  - Updated default Ethos-N driver stack to 21.02
  - Fixed some test failures associated with this change
  • Loading branch information
tristan-arm committed Mar 11, 2021
1 parent c519863 commit d1b9c1e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docker/install/ubuntu_install_ethosn_driver_stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set -o pipefail

repo_url="https://github.com/Arm-software/ethos-n-driver-stack"
repo_dir="ethosn-driver"
repo_revision="20.08"
repo_revision="21.02"
install_path="/opt/arm/$repo_dir"

tmpdir=$(mktemp -d)
Expand Down
30 changes: 15 additions & 15 deletions src/relay/backend/contrib/ethosn/codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ sl::TensorsAndId MakeOps(const sl::TensorAndId<sl::Operand>& op) {

NetworkWithIDs ConstructNetworkVisitor::Construct(const Function& func) {
// Initialise everything
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
auto ctx = transform::PassContext::Current();
auto cfg = ctx->GetConfig<EthosnCompilerConfig>("relay.ext.ethos-n.options");
if (!cfg.defined()) {
cfg = AttrsWithDefaultValues<EthosnCompilerConfig>();
}
#endif
NetworkWithIDs network_with_ids;
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
network_ = sl::CreateNetwork(variants[cfg.value()->variant]);
#else
network_ = sl::CreateNetwork();
Expand Down Expand Up @@ -572,7 +572,7 @@ sl::CompilationOptions EthosnCompiler::CreateOptions() {
cfg = AttrsWithDefaultValues<EthosnCompilerConfig>();
}

#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
sl::CompilationOptions options;
#else
sl::CompilationOptions options(variants[cfg.value()->variant]);
Expand Down Expand Up @@ -619,7 +619,7 @@ std::pair<std::vector<uint32_t>, std::vector<uint32_t>> EthosnCompiler::GetInput
return std::make_pair(input_order, output_order);
}

#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
auto ctx = transform::PassContext::Current();
auto cfg = ctx -> GetConfig<EthosnCompilerConfig>("relay.ext.ethos-n.options").defined()
? ctx -> GetConfig<EthosnCompilerConfig>("relay.ext.ethos-n.options")
Expand All @@ -632,7 +632,7 @@ TVM_REGISTER_GLOBAL("relay.ethos-n.support.conv2d")
Call call = args[0];
ConvolutionParams params;
auto err = EthosnAPI::QnnConv2d(call, &params);
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
if (params.is_depthwise) {
*rv = !err &&
m_Queries.IsDepthwiseConvolutionSupported(params.bias_info, params.weights_info,
Expand All @@ -657,7 +657,7 @@ TVM_REGISTER_GLOBAL("relay.ethos-n.support.fc")
Call call = args[0];
FullyConnectedParams params;
auto err = EthosnAPI::QnnFullyConnected(call, &params);
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
*rv = !err && m_Queries.IsFullyConnectedSupported(params.bias_info, params.weights_info,
params.fc_info, params.input_info);
#else
Expand All @@ -671,7 +671,7 @@ TVM_REGISTER_GLOBAL("relay.ethos-n.support.max_pool2d")
Call call = args[0];
MaxPool2DParams params;
auto err = EthosnAPI::MaxPool2D(call, &params);
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
*rv = !err && m_Queries.IsPoolingSupported(params.pool_info, params.input_info);
#else
*rv = !err && sl::IsPoolingSupported(params.pool_info, params.input_info);
Expand All @@ -683,7 +683,7 @@ TVM_REGISTER_GLOBAL("relay.ethos-n.support.avg_pool2d")
Call call = args[0];
AvgPool2DParams params;
auto err = EthosnAPI::AvgPool2D(call, &params);
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
*rv = !err && m_Queries.IsPoolingSupported(params.pool_info, params.input_info);
#else
*rv = !err && sl::IsPoolingSupported(params.pool_info, params.input_info);
Expand All @@ -695,7 +695,7 @@ TVM_REGISTER_GLOBAL("relay.ethos-n.support.reshape")
Call call = args[0];
ReshapeParams params;
auto err = EthosnAPI::Reshape(call, &params);
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
*rv = !err && m_Queries.IsReshapeSupported(params.new_shape, params.input_info);
#else
*rv = !err && sl::IsReshapeSupported(params.new_shape, params.input_info);
Expand All @@ -707,7 +707,7 @@ TVM_REGISTER_GLOBAL("relay.ethos-n.support.addition")
Call call = args[0];
AdditionParams params;
auto err = EthosnAPI::Addition(call, &params);
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
*rv = !err && m_Queries.IsAdditionSupported(params.lhs_info, params.rhs_info,
params.output_quantization_info);
#else
Expand All @@ -721,7 +721,7 @@ TVM_REGISTER_GLOBAL("relay.ethos-n.support.sigmoid")
Call call = args[0];
SigmoidParams params;
auto err = EthosnAPI::Sigmoid(call, &params);
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
*rv = !err && m_Queries.IsSigmoidSupported(params.input_info);
#else
*rv = !err && sl::IsSigmoidSupported(params.input_info);
Expand All @@ -733,7 +733,7 @@ TVM_REGISTER_GLOBAL("relay.ethos-n.support.concatenate")
Call call = args[0];
ConcatenateParams params;
auto err = EthosnAPI::Concatenate(call, &params);
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
*rv = !err && m_Queries.IsConcatenationSupported(params.input_infos, params.concat_info);
#else
*rv = !err && sl::IsConcatenationSupported(params.input_infos, params.concat_info);
Expand All @@ -745,7 +745,7 @@ TVM_REGISTER_GLOBAL("relay.ethos-n.support.split")
Call call = args[0];
SplitParams params;
auto err = EthosnAPI::Split(call, &params);
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
*rv = !err && m_Queries.IsSplitSupported(params.input_info, params.split_info);
#else
*rv = !err && sl::IsSplitSupported(params.input_info, params.split_info);
Expand All @@ -757,7 +757,7 @@ TVM_REGISTER_GLOBAL("relay.ethos-n.support.depth_to_space")
Call call = args[0];
DepthToSpaceParams params;
auto err = EthosnAPI::DepthToSpace(call, &params);
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
*rv = !err && m_Queries.IsDepthToSpaceSupported(params.input_info, params.depth_info);
#else
*rv = !err && sl::IsDepthToSpaceSupported(params.input_info, params.depth_info);
Expand All @@ -769,7 +769,7 @@ TVM_REGISTER_GLOBAL("relay.ethos-n.support.relu")
Call call = args[0];
ReluParams params;
auto err = EthosnAPI::Relu(call, &params);
#if _ETHOSN_API_VERSION_ == 2011
#if _ETHOSN_API_VERSION_ >= 2011
*rv = !err && m_Queries.IsReluSupported(params.relu_info, params.input_info);
#else
*rv = !err && sl::IsReluSupported(params.relu_info, params.input_info);
Expand Down
4 changes: 4 additions & 0 deletions src/relay/backend/contrib/ethosn/ethosn_api_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@
* along with associated compatibility measures when no
* longer necessary.
*/
#if ETHOSN_SUPPORT_LIBRARY_VERSION_PATCH == 2
#define _ETHOSN_API_VERSION_ 2102
#else
#ifndef ETHOSN_API_VERSION
#define _ETHOSN_API_VERSION_ 2008
#elif ~(~ETHOSN_API_VERSION + 0) == 0 && ~(~ETHOSN_API_VERSION + 1) == 1
#define _ETHOSN_API_VERSION_ 2008
#else
#define _ETHOSN_API_VERSION_ ETHOSN_API_VERSION
#endif
#endif

#endif // TVM_RELAY_BACKEND_CONTRIB_ETHOSN_ETHOSN_API_VERSION_H_
16 changes: 12 additions & 4 deletions tests/python/contrib/test_ethosn/test_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ def test_mobilenet_v1():
# codegen, which could come about from either a change in Support Library
# version or a change in the Ethos-N codegen. To update this requires running
# on hardware that isn't available in CI.
_compile_hash = {"81637c89339201a07dc96e3b5dbf836a"}
_compile_hash = {"bfb5a50607edb50009c58ae9d4287e4d"}
if tei.get_ethosn_variant() == 3:
_compile_hash = {"896c28b4f06341ea638ead3a593e1aed"}
if tei.get_ethosn_api_version() == 2008:
_compile_hash = {"47e216d8ab2bf491708ccf5620bc0d02"}
if tei.get_ethosn_variant() == 3:
Expand Down Expand Up @@ -150,7 +152,9 @@ def test_inception_v3():
# codegen, which could come about from either a change in Support Library
# version or a change in the Ethos-N codegen. To update this requires running
# on hardware that isn't available in CI.
_compile_hash = {"de0e175af610ebd45ccb03d170dc9664"}
_compile_hash = {"96116d7e6c7385de0688074a3f889983"}
if tei.get_ethosn_variant() == 3:
_compile_hash = {"551cde850c6ef960d19be4f317fb8e68"}
if tei.get_ethosn_api_version() == 2008:
_compile_hash = {"8c9d75659cd7bc9ff6dd6d490d28f9b2"}
if tei.get_ethosn_variant() == 3:
Expand All @@ -177,7 +181,9 @@ def test_inception_v4():
# codegen, which could come about from either a change in Support Library
# version or a change in the Ethos-N codegen. To update this requires running
# on hardware that isn't available in CI.
_compile_hash = {"06bf6cb56344f3904bcb108e54edfe87"}
_compile_hash = {"b34aec2a48c591818761ed6b42c133e5"}
if tei.get_ethosn_variant() == 3:
_compile_hash = {"30f078bd42757e8686eafa1f28d0d352"}
if tei.get_ethosn_api_version() == 2008:
if not tei.get_ethosn_variant() == 0:
pytest.skip(
Expand Down Expand Up @@ -206,7 +212,9 @@ def test_ssd_mobilenet_v1():
# codegen, which could come about from either a change in Support Library
# version or a change in the Ethos-N codegen. To update this requires running
# on hardware that isn't available in CI.
_compile_hash = {"29aec6b184b09454b4323271aadf89b1", "6211d96103880b016baa85e638abddef"}
_compile_hash = {"c312edfc9a946ed4dc7c049d472dae6e", "3183f0fa5eba8f6b9557d14eaf47842d"}
if tei.get_ethosn_variant() == 3:
_compile_hash = {"deee52e136327436411fc725624ae2ea", "6526509d3cbee014e38c79e22bb29d7f"}
if tei.get_ethosn_api_version() == 2008:
_compile_hash = {"5999f26e140dee0d7866491997ef78c5", "24e3a690a7e95780052792d5626c85be"}
if tei.get_ethosn_variant() == 3:
Expand Down

0 comments on commit d1b9c1e

Please sign in to comment.