Skip to content

Commit

Permalink
[BYOC][ACL] Add maximum support for float32 (apache#6506)
Browse files Browse the repository at this point in the history
* ACL integration: add maximum support for float32.

* Added the code generation flow in arm_compute_lib.py
* Added the runtime calls in acl_runtime.cc

Change-Id: I69c5522f05a46c1dd235da5d57fe499134de0425

* Add maximum to the list of supported functions

Change-Id: Ia49087756be4c3ac92a3dc76fe03fb00de468f8d
  • Loading branch information
Giuseppe Rossini authored and Tushar Dey committed Oct 15, 2020
1 parent 160fda0 commit 38f07e3
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 56 deletions.
4 changes: 0 additions & 4 deletions docs/deploy/arm_compute_lib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,6 @@ Operator support
+----------------------+-------------------------------------------------------------------------+
| maximum | fp32 |
+----------------------+-------------------------------------------------------------------------+
| add | fp32 |
+----------------------+-------------------------------------------------------------------------+
| qnn.add | uint8 |
+----------------------+-------------------------------------------------------------------------+

.. note::
A composite operator is a series of operators that map to a single Arm Compute Library operator. You can view this
Expand Down
20 changes: 0 additions & 20 deletions python/tvm/relay/op/contrib/arm_compute_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,23 +346,3 @@ def maximum(attrs, args):
type_a = args[0].checked_type
type_b = args[0].checked_type
return (type_a.dtype == "float32") and (type_b.dtype == "float32")


@tvm.ir.register_op_attr("add", "target.arm_compute_lib")
def add(attrs, args):
"""Check if the external ACL codegen for add should be used."""
for typ in [args[0].checked_type, args[1].checked_type]:
if typ.dtype != "float32":
return False

return True


@tvm.ir.register_op_attr("qnn.add", "target.arm_compute_lib")
def qnn_add(attrs, args):
"""Check if the external ACL codegen for add should be used."""
for typ in [args[0].checked_type, args[1].checked_type]:
if typ.dtype != "uint8":
return False

return True
32 changes: 0 additions & 32 deletions src/runtime/contrib/arm_compute_lib/acl_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ class ACLRuntime : public JSONRuntimeBase {
CreateReshapeLayer(&layer_, node);
} else if ("maximum" == op_name) {
CreateMaximumLayer(&layer_, node);
} else if ("add" == op_name || "qnn.add" == op_name) {
CreateAddLayer(&layer_, node);
} else {
LOG(FATAL) << "Unsupported op: " << op_name;
}
Expand Down Expand Up @@ -420,36 +418,6 @@ class ACLRuntime : public JSONRuntimeBase {
function->configure(&layer->inputs[0], &layer->inputs[1], &layer->outputs[0]);
layer->function = function;
}
/*!
* \brief Creates an add/qnn.add layer
*
* \param layer The ACL layer to build. Containing inputs, outputs and the ACL function.
* \param node The JSON representation of the operator.
*/
void CreateAddLayer(CachedLayer* layer, const JSONGraphNode& node) {
auto op_name = node.GetOpName();
if ("add" == op_name) {
layer->inputs.push_back(MakeACLTensorFromJSONEntry(node.GetInputs()[0]));
layer->inputs.push_back(MakeACLTensorFromJSONEntry(node.GetInputs()[1]));
layer->outputs.push_back(MakeACLTensorFromJSONNode(node));
} else if ("qnn.add" == op_name) {
layer->inputs.push_back(MakeACLTensorFromJSONEntry(node.GetInputs()[0], &node.GetInputs()[2],
&node.GetInputs()[3]));
layer->inputs.push_back(MakeACLTensorFromJSONEntry(node.GetInputs()[1], &node.GetInputs()[4],
&node.GetInputs()[5]));
layer->outputs.push_back(
MakeACLTensorFromJSONNode(node, &node.GetInputs()[6], &node.GetInputs()[7]));
} else {
throw std::runtime_error("Unsupported form of add op: " + op_name);
}

auto f = std::make_shared<arm_compute::NEArithmeticAddition>();

// SATURATE is used as add_QASYMM8_QASYMM8_QASYMM8 always saturates result
f->configure(&layer->inputs[0], &layer->inputs[1], &layer->outputs[0],
arm_compute::ConvertPolicy::SATURATE);
layer->function = f;
}

/*! \brief Allow ACL functions to request auxiliary memory from TVM. */
ACLAllocator allocator_;
Expand Down

0 comments on commit 38f07e3

Please sign in to comment.