Skip to content

Commit

Permalink
Merge branch 'dnnl-comosite-tmp' into dnnl-composite
Browse files Browse the repository at this point in the history
  • Loading branch information
masahi committed Apr 10, 2020
2 parents 575d536 + 284d344 commit 38f8564
Show file tree
Hide file tree
Showing 7 changed files with 505 additions and 210 deletions.
6 changes: 4 additions & 2 deletions src/relay/backend/contrib/codegen_c/codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@
#include <tvm/relay/expr_functor.h>
#include <tvm/relay/transform.h>
#include <tvm/relay/type.h>
#include <tvm/runtime/ndarray.h>
#include <tvm/runtime/module.h>
#include <tvm/runtime/ndarray.h>
#include <tvm/runtime/object.h>

#include <fstream>
#include <sstream>

#include "../../utils.h"
#include "codegen_c.h"

namespace tvm {
namespace relay {
namespace contrib {

using namespace backend;

/*!
* \brief An example codegen that is only used for quick prototyping and testing
* purpose. Only several binary options are covered. Users
Expand All @@ -58,7 +61,6 @@ class CodegenC : public ExprVisitor, public CodegenCBase {
return;
}

std::ostringstream decl_stream;
std::ostringstream buf_stream;

out_.clear();
Expand Down
35 changes: 0 additions & 35 deletions src/relay/backend/contrib/codegen_c/codegen_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,41 +169,6 @@ class CodegenCBase {
*/
virtual std::string JIT() = 0;

/*!
* \brief Extract the shape from a Relay tensor type.
*
* \param type The provided type.
*
* \return The extracted shape in a list.
*/
std::vector<int> GetShape(const Type& type) const {
const auto* ttype = type.as<TensorTypeNode>();
CHECK(ttype) << "Expect TensorTypeNode";
std::vector<int> shape;
for (size_t i = 0; i < ttype->shape.size(); ++i) {
auto* val = ttype->shape[i].as<IntImmNode>();
CHECK(val);
shape.push_back(val->value);
}
return shape;
}

/*!
* \brief Check if a call has the provided name.
*
* \param call A Relay call node.
* \param op_name The name of the expected call.
*
* \return true if the call's name is equivalent to the given name. Otherwise,
* false.
*/
bool IsOp(const CallNode* call, const std::string& op_name) const {
const auto* op_node = call->op.as<OpNode>();
CHECK(op_node) << "Expects a single op.";
Op op = GetRef<Op>(op_node);
return op == Op::Get(op_name);
}

/*!
* \brief A common interface that is used by various external runtime to
* generate the wrapper to invoke external kernels.
Expand Down
Loading

0 comments on commit 38f8564

Please sign in to comment.