Permalink
Browse files

Merge pull request #120 from ONNC/nvdla_harness

Scaffolding of NVDLA backend
  • Loading branch information...
champyen committed Dec 19, 2018
2 parents 21cf1b5 + 8d64658 commit 7196344bc009ad9b5efbd1a6b83017e8acd2fdaa
BIN +1.38 KB (120%) docs/onnc.dia
Binary file not shown.
@@ -0,0 +1,42 @@
//===- Platform.h ---------------------------------------------------------===//
//
// The ONNC Project
//
// See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef ONNC_TARGET_PLATFORM_H
#define ONNC_TARGET_PLATFORM_H
#include <onnc/Target/TargetBackend.h>

namespace onnc {

/** \class Platform
* \brief Platform collects information of a target platform.
*
* One platform is made of multiple target backends.
*/
class Platform
{
public:
/// Constructor.
Platform(const std::string& pName);

const std::string& name() const { return m_Name; }

void setShortDescription(const std::string& pDesc) { m_ShortDesc = pDesc; }

const std::string& getShortDescription() const { return m_ShortDesc; }

private:
typedef std::vector<TargetBackend*> TargetBackendList;

private:
std::string m_Name;
std::string m_ShortDesc;
TargetBackendList m_TargetBackends;
};

} // namespace of onnc

#endif
@@ -488,7 +488,8 @@ AM_LFLAGS = -olex.yy.c

#####################################
# Target-depednet files and settings
ONNC_TARGET_SOURCES = Target/Target.cpp \
ONNC_TARGET_SOURCES = Target/Platform.cpp \
Target/Target.cpp \
Target/TargetOptions.cpp \
Target/TargetRegistry.cpp \
Target/TargetStandardPasses.cpp \
@@ -498,6 +499,10 @@ if ENABLE_X86_TARGET
include $(srcdir)/Target/X86/Makefile.am
endif

if ENABLE_NVDLA_TARGET
include $(srcdir)/Target/NVDLA/Makefile.am
endif

# FIXME: embraced by flag?
include $(srcdir)/Target/Vanilla/Makefile.am

@@ -1,4 +1,5 @@
add_libonnc_src(
Platform.cpp
Target.cpp
TargetOptions.cpp
TargetRegistry.cpp
@@ -0,0 +1,2 @@
ONNC_TARGET_SOURCES += \
Target/NVDLA/NVDLABackend.cpp
@@ -0,0 +1,48 @@
//===- NVDLABackend.cpp -----------------------------------------------------===//
//
// The ONNC Project
//
// See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "NVDLABackend.h"

using namespace onnc;

//===----------------------------------------------------------------------===//
// NVDLABackend
//===----------------------------------------------------------------------===//
NVDLABackend::NVDLABackend(const TargetOptions& pOptions)
: DLATargetBackend(pOptions) {
}

NVDLABackend::~NVDLABackend()
{
}

void NVDLABackend::addTensorSel(PassManager& pPM)
{
}

void NVDLABackend::addMemAlloc(PassManager& pPM)
{
}

void NVDLABackend::addCodeEmit(PassManager& pPM, const Path& pOutput)
{
}

void NVDLABackend::RegisterLowers(LowerRegistry& pRegistry) const
{
}

//===----------------------------------------------------------------------===//
// Non-member functions
//===----------------------------------------------------------------------===//
extern "C" void InitializeNVDLAONNCBackend()
{
}

extern "C" void InitializeNVDLAONNCPlatform()
{
}
@@ -0,0 +1,33 @@
//===- NVDLABackend.h -----------------------------------------------------===//
//
// The ONNC Project
//
// See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef TARGET_NVDLA_NVDLA_BACKEND_H
#define TARGET_NVDLA_NVDLA_BACKEND_H
#include <string>
#include <onnc/Target/DLATargetBackend.h>

namespace onnc {

class NVDLABackend : public DLATargetBackend
{
public:
NVDLABackend(const TargetOptions& pOptions);

virtual ~NVDLABackend();

void addTensorSel(PassManager& pPM) override;

void addMemAlloc(PassManager& pPM) override;

void addCodeEmit(PassManager& pPM, const Path& pOutput) override;

void RegisterLowers(LowerRegistry& pRegistry) const override;
};

} // namespace onnc

#endif
@@ -0,0 +1,19 @@
//===-- Platform.cpp ------------------------------------------------------===//
//
// The ONNC Project
//
// See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <onnc/Target/Platform.h>

using namespace onnc;

//===----------------------------------------------------------------------===//
// Platform
//===----------------------------------------------------------------------===//
onnc::Platform::Platform(const std::string& pName)
: m_Name(pName),
m_ShortDesc(),
m_TargetBackends() {
}
@@ -16,13 +16,13 @@ AC_DEFUN([ENUM_ONNC_TARGETS],
[AS_HELP_STRING([--enable-targets],
[Build specific host targets: all or target1,target2,... Valid targets are:
host, vanilla, x86, x86_64, sparc, powerpc, alpha, aarch64, arm,
arm64, mips, spu, hexagon, xcore, msp430, systemz, blackfin, ptx, cbe, and cpp (default=all)])],
arm64, nvdla, mips, spu, hexagon, xcore, msp430, systemz, blackfin, ptx, cbe, and cpp (default=all)])],
[],
[enableval=all])

AC_MSG_CHECKING([target backends])
case "$enableval" in
all) TARGETS_TO_BUILD="Vanilla X86 Sparc PowerPC Alpha AArch64 ARM Mips Hexagon CellSPU XCore MSP430 SystemZ Blackfin CBackend CppBackend MBlaze PTX"
all) TARGETS_TO_BUILD="Vanilla X86 Sparc PowerPC Alpha AArch64 ARM NVDLA Mips Hexagon CellSPU XCore MSP430 SystemZ Blackfin CBackend CppBackend MBlaze PTX"
;;
*)for a_target in `echo $enableval|sed -e 's/,/ /g' ` ; do
case "$a_target" in
@@ -50,6 +50,10 @@ AC_DEFUN([ENUM_ONNC_TARGETS],
TARGETS_TO_BUILD="ARM $TARGETS_TO_BUILD"
AC_DEFINE(ENABLE_ARM_TARGET, 1, [define ARM target])
;;
nvdla)
TARGETS_TO_BUILD="NVDLA $TARGETS_TO_BUILD"
AC_DEFINE(ENABLE_NVDLA_TARGET, 1, [define NVDLA target])
;;
mips) TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
hexagon) TARGETS_TO_BUILD="Hexagon $TARGETS_TO_BUILD" ;;
spu) TARGETS_TO_BUILD="CellSPU $TARGETS_TO_BUILD" ;;
@@ -92,6 +96,7 @@ AC_DEFUN([ENUM_ONNC_TARGETS],
AM_CONDITIONAL([ENABLE_X86_TARGET], [ test "${TARGETS_TO_BUILD/X86}" != "${TARGETS_TO_BUILD}" ])
AM_CONDITIONAL([ENABLE_AArch64_TARGET], [ test "${TARGETS_TO_BUILD/AArch64}" != "${TARGETS_TO_BUILD}" ])
AM_CONDITIONAL([ENABLE_ARM_TARGET], [ test "${TARGETS_TO_BUILD/ARM}" != "${TARGETS_TO_BUILD}" ])
AM_CONDITIONAL([ENABLE_NVDLA_TARGET], [ test "${TARGETS_TO_BUILD/NVDLA}" != "${TARGETS_TO_BUILD}" ])

dnl include target-dependent autoconf function calls.
AM_COND_IF([ENABLE_X86_TARGET], [m4_include(m4/targets/x86.m4)])

0 comments on commit 7196344

Please sign in to comment.