Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
af18be14
Unverified
Commit
af18be14
authored
Nov 03, 2017
by
Robert Kimball
Committed by
GitHub
Nov 03, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #206 from NervanaSystems/jmenon/cpu
CPU Backend
parents
88986222
60ea252d
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
2576 additions
and
193 deletions
+2576
-193
CMakeLists.txt
CMakeLists.txt
+1
-1
external_llvm.cmake
cmake/external_llvm.cmake
+61
-0
CMakeLists.txt
src/ngraph/CMakeLists.txt
+33
-0
compiler.cpp
src/ngraph/codegen/compiler.cpp
+225
-0
compiler.hpp
src/ngraph/codegen/compiler.hpp
+76
-0
assign_layout.hpp
src/ngraph/pass/assign_layout.hpp
+59
-0
call_frame.cpp
src/ngraph/runtime/cpu/call_frame.cpp
+66
-0
call_frame.hpp
src/ngraph/runtime/cpu/call_frame.hpp
+79
-0
cpu_backend.cpp
src/ngraph/runtime/cpu/cpu_backend.cpp
+24
-0
cpu_backend.hpp
src/ngraph/runtime/cpu/cpu_backend.hpp
+33
-0
cpu_manager.cpp
src/ngraph/runtime/cpu/cpu_manager.cpp
+37
-0
cpu_manager.hpp
src/ngraph/runtime/cpu/cpu_manager.hpp
+48
-0
eigen_utils.hpp
src/ngraph/runtime/cpu/eigen_utils.hpp
+171
-0
emitter.cpp
src/ngraph/runtime/cpu/emitter.cpp
+884
-0
emitter.hpp
src/ngraph/runtime/cpu/emitter.hpp
+81
-0
external_function.cpp
src/ngraph/runtime/cpu/external_function.cpp
+326
-0
external_function.hpp
src/ngraph/runtime/cpu/external_function.hpp
+70
-0
tensor_view_info.hpp
src/ngraph/runtime/tensor_view_info.hpp
+1
-1
CMakeLists.txt
test/CMakeLists.txt
+20
-1
backend_test.in.cpp
test/backend_test.in.cpp
+190
-190
codegen.cpp
test/codegen.cpp
+90
-0
CMakeLists.txt
third-party/CMakeLists.txt
+1
-0
No files found.
CMakeLists.txt
View file @
af18be14
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
cmake_minimum_required
(
VERSION
2.8
)
cmake_minimum_required
(
VERSION
3.1
)
set
(
NGRAPH_INCLUDE_PATH
set
(
NGRAPH_INCLUDE_PATH
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
...
...
cmake/external_llvm.cmake
0 → 100644
View file @
af18be14
# Copyright 2017 Nervana Systems Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include
(
ExternalProject
)
if
(
NGRAPH_CPU_ENABLE
AND
(
NOT
${
CMAKE_SYSTEM_NAME
}
MATCHES
"Darwin"
)
AND
(
NOT
${
CMAKE_SYSTEM_NAME
}
MATCHES
"Windows"
))
message
(
STATUS
"Fetching LLVM from llvm.org"
)
set
(
LLVM_RELEASE_URL http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu16.04.tar.xz
)
set
(
LLVM_SHA1_HASH 9cb81c92aa4d3f9707a9b8413c4d24b8dee90c59
)
# Override default LLVM binaries
if
(
PREBUILT_LLVM
)
if
(
NOT DEFINED PREBUILT_LLVM_HASH
)
message
(
FATAL_ERROR
"SHA1 hash of prebuilt llvm tarball not provided in PREBUILT_LLVM_HASH."
)
endif
()
set
(
LLVM_RELEASE_URL
${
PREBUILT_LLVM
}
)
set
(
LLVM_SHA1_HASH
${
PREBUILT_LLVM_HASH
}
)
endif
()
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if
(
${
CMAKE_VERSION
}
VERSION_LESS 3.2
)
ExternalProject_Add
(
ext_llvm
URL
${
LLVM_RELEASE_URL
}
URL_HASH SHA1=
${
LLVM_SHA1_HASH
}
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND
""
UPDATE_COMMAND
""
)
else
()
ExternalProject_Add
(
ext_llvm
URL
${
LLVM_RELEASE_URL
}
URL_HASH SHA1=
${
LLVM_SHA1_HASH
}
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND
""
UPDATE_COMMAND
""
BUILD_BYPRODUCTS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/ext_llvm-prefix/src/ext_llvm/lib/libLLVMCore.a"
)
endif
()
ExternalProject_Get_Property
(
ext_llvm source_dir
)
set
(
LLVM_INCLUDE_DIR
"
${
source_dir
}
/include"
PARENT_SCOPE
)
set
(
LLVM_LIB_DIR
"
${
source_dir
}
/lib"
PARENT_SCOPE
)
set
(
LLVM_LINK_LIBS clangTooling clangFrontendTool clangFrontend clangDriver clangSerialization clangCodeGen clangParse clangSema clangStaticAnalyzerFrontend clangStaticAnalyzerCheckers clangStaticAnalyzerCore clangAnalysis clangARCMigrate clangRewriteFrontend clangEdit clangAST clangLex clangBasic LLVMLTO LLVMPasses LLVMObjCARCOpts LLVMSymbolize LLVMDebugInfoPDB LLVMDebugInfoDWARF LLVMMIRParser LLVMCoverage LLVMTableGen LLVMDlltoolDriver LLVMOrcJIT LLVMXCoreDisassembler LLVMXCoreCodeGen LLVMXCoreDesc LLVMXCoreInfo LLVMXCoreAsmPrinter LLVMSystemZDisassembler LLVMSystemZCodeGen LLVMSystemZAsmParser LLVMSystemZDesc LLVMSystemZInfo LLVMSystemZAsmPrinter LLVMSparcDisassembler LLVMSparcCodeGen LLVMSparcAsmParser LLVMSparcDesc LLVMSparcInfo LLVMSparcAsmPrinter LLVMPowerPCDisassembler LLVMPowerPCCodeGen LLVMPowerPCAsmParser LLVMPowerPCDesc LLVMPowerPCInfo LLVMPowerPCAsmPrinter LLVMNVPTXCodeGen LLVMNVPTXDesc LLVMNVPTXInfo LLVMNVPTXAsmPrinter LLVMMSP430CodeGen LLVMMSP430Desc LLVMMSP430Info LLVMMSP430AsmPrinter LLVMMipsDisassembler LLVMMipsCodeGen LLVMMipsAsmParser LLVMMipsDesc LLVMMipsInfo LLVMMipsAsmPrinter LLVMLanaiDisassembler LLVMLanaiCodeGen LLVMLanaiAsmParser LLVMLanaiDesc LLVMLanaiAsmPrinter LLVMLanaiInfo LLVMHexagonDisassembler LLVMHexagonCodeGen LLVMHexagonAsmParser LLVMHexagonDesc LLVMHexagonInfo LLVMBPFDisassembler LLVMBPFCodeGen LLVMBPFDesc LLVMBPFInfo LLVMBPFAsmPrinter LLVMARMDisassembler LLVMARMCodeGen LLVMARMAsmParser LLVMARMDesc LLVMARMInfo LLVMARMAsmPrinter LLVMAMDGPUDisassembler LLVMAMDGPUCodeGen LLVMAMDGPUAsmParser LLVMAMDGPUDesc LLVMAMDGPUInfo LLVMAMDGPUAsmPrinter LLVMAMDGPUUtils LLVMAArch64Disassembler LLVMAArch64CodeGen LLVMAArch64AsmParser LLVMAArch64Desc LLVMAArch64Info LLVMAArch64AsmPrinter LLVMAArch64Utils LLVMObjectYAML LLVMLibDriver LLVMOption LLVMX86Disassembler LLVMX86AsmParser LLVMX86CodeGen LLVMGlobalISel LLVMSelectionDAG LLVMAsmPrinter LLVMDebugInfoCodeView LLVMDebugInfoMSF LLVMX86Desc LLVMMCDisassembler LLVMX86Info LLVMX86AsmPrinter LLVMX86Utils LLVMMCJIT LLVMLineEditor LLVMInterpreter LLVMExecutionEngine LLVMRuntimeDyld LLVMCodeGen LLVMTarget LLVMCoroutines LLVMipo LLVMInstrumentation LLVMVectorize LLVMScalarOpts LLVMLinker LLVMIRReader LLVMAsmParser LLVMInstCombine LLVMTransformUtils LLVMBitWriter LLVMAnalysis LLVMProfileData LLVMObject LLVMMCParser LLVMMC LLVMBitReader LLVMCore LLVMBinaryFormat LLVMSupport LLVMDemangle tinfo z m PARENT_SCOPE
)
endif
()
src/ngraph/CMakeLists.txt
View file @
af18be14
...
@@ -99,9 +99,38 @@ include_directories(
...
@@ -99,9 +99,38 @@ include_directories(
"
${
EIGEN_INCLUDE_DIR
}
"
"
${
EIGEN_INCLUDE_DIR
}
"
)
)
if
(
LLVM_INCLUDE_DIR
)
include_directories
(
SYSTEM
${
LLVM_INCLUDE_DIR
}
)
link_directories
(
${
LLVM_LIB_DIR
}
)
# Add sources for the CPU backend
# and all its dependencies
set
(
SRC
${
SRC
}
codegen/compiler.cpp
runtime/cpu/call_frame.cpp
runtime/cpu/cpu_manager.cpp
runtime/cpu/cpu_backend.cpp
runtime/cpu/emitter.cpp
runtime/cpu/external_function.cpp
)
# LLVM binary builds are typically built without RTTI
# The built-in headers are in a version-specific directory
# This must be kept in sync with the LLVM + Clang version in use
set_source_files_properties
(
codegen/compiler.cpp PROPERTIES COMPILE_FLAGS
"-fno-rtti"
)
set_source_files_properties
(
codegen/compiler.cpp PROPERTIES COMPILE_DEFINITIONS
"EIGEN_HEADERS_PATH=
\"
${
EIGEN_INCLUDE_DIR
}
\"
;CLANG_BUILTIN_HEADERS_PATH=
\"
${
LLVM_LIB_DIR
}
/clang/5.0.0/include
\"
;NGRAPH_HEADERS_PATH=
\"
${
NGRAPH_INCLUDE_PATH
}
\"
"
)
set
(
NGRAPH_CPU_PCH_ENABLE 0 CACHE STRING
"Enable pre-compiled headers in the CPU backend"
)
set
(
NGRAPH_CPU_DEBUGINFO_ENABLE 0 CACHE STRING
"Enable debuginfo in the CPU backend"
)
set_source_files_properties
(
runtime/cpu/external_function.cpp PROPERTIES COMPILE_DEFINITIONS
"NGCPU_PCH=
${
NGRAPH_CPU_PCH_ENABLE
}
;NGCPU_DEBUGINFO=
${
NGRAPH_CPU_DEBUGINFO_ENABLE
}
"
)
endif
()
add_library
(
ngraph SHARED
${
SRC
}
)
add_library
(
ngraph SHARED
${
SRC
}
)
target_include_directories
(
ngraph PUBLIC
"
${
NGRAPH_INCLUDE_PATH
}
"
)
target_include_directories
(
ngraph PUBLIC
"
${
NGRAPH_INCLUDE_PATH
}
"
)
if
(
LLVM_LINK_LIBS
)
target_link_libraries
(
ngraph LINK_PRIVATE
${
LLVM_LINK_LIBS
}
)
endif
()
if
(
APPLE
)
if
(
APPLE
)
set_property
(
TARGET ngraph PROPERTY PREFIX
"lib"
)
set_property
(
TARGET ngraph PROPERTY PREFIX
"lib"
)
set_property
(
TARGET ngraph PROPERTY OUTPUT_NAME
"ngraph.so"
)
set_property
(
TARGET ngraph PROPERTY OUTPUT_NAME
"ngraph.so"
)
...
@@ -146,3 +175,7 @@ install(DIRECTORY
...
@@ -146,3 +175,7 @@ install(DIRECTORY
endif
()
endif
()
add_dependencies
(
ngraph eigen
)
add_dependencies
(
ngraph eigen
)
if
(
NOT LLVM_PACKAGED AND LLVM_INCLUDE_DIR
)
add_dependencies
(
ngraph ext_llvm
)
endif
()
src/ngraph/codegen/compiler.cpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <clang/CodeGen/ObjectFilePCHContainerOperations.h>
#include <clang/Driver/DriverDiagnostic.h>
#include <clang/Driver/Options.h>
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/CompilerInvocation.h>
#include <clang/Frontend/FrontendDiagnostic.h>
#include <clang/Frontend/TextDiagnosticBuffer.h>
#include <clang/Frontend/TextDiagnosticPrinter.h>
#include <clang/Frontend/Utils.h>
#include <clang/FrontendTool/Utils.h>
#include <clang/Lex/Preprocessor.h>
#include <clang/Lex/PreprocessorOptions.h>
#include <llvm/ADT/Statistic.h>
#include <llvm/LinkAllPasses.h>
#include <llvm/Option/Arg.h>
#include <llvm/Option/ArgList.h>
#include <llvm/Option/OptTable.h>
#include <llvm/Support/ErrorHandling.h>
#include <llvm/Support/ManagedStatic.h>
#include <llvm/Support/Signals.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/Support/Timer.h>
#include <llvm/Support/raw_ostream.h>
#include <clang/Basic/DiagnosticOptions.h>
#include <clang/Basic/TargetInfo.h>
#include <clang/CodeGen/CodeGenAction.h>
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/TextDiagnosticPrinter.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/ExecutionEngine/SectionMemoryManager.h>
#include "ngraph/codegen/compiler.hpp"
// TODO: Fix leaks
using
namespace
clang
;
using
namespace
llvm
;
using
namespace
llvm
::
opt
;
using
namespace
std
;
using
namespace
ngraph
::
codegen
;
static
std
::
string
GetExecutablePath
(
const
char
*
Argv0
)
{
// This just needs to be some symbol in the binary; C++ doesn't
// allow taking the address of ::main however.
void
*
MainAddr
=
reinterpret_cast
<
void
*>
(
GetExecutablePath
);
return
llvm
::
sys
::
fs
::
getMainExecutable
(
Argv0
,
MainAddr
);
}
execution_state
::
execution_state
()
:
m_execution_engine
{
nullptr
}
,
precompiled_headers_enabled
(
false
)
,
debuginfo_enabled
(
false
)
{
}
execution_state
::~
execution_state
()
{
}
std
::
unique_ptr
<
llvm
::
Module
>
execution_state
::
compile
(
const
string
&
source
,
const
string
&
name
)
{
llvm
::
InitializeAllTargets
();
llvm
::
InitializeAllTargetMCs
();
llvm
::
InitializeAllAsmPrinters
();
llvm
::
InitializeAllAsmParsers
();
// Prepare compilation arguments
vector
<
const
char
*>
args
;
args
.
push_back
(
name
.
c_str
());
// Prepare DiagnosticEngine
DiagnosticOptions
DiagOpts
;
TextDiagnosticPrinter
*
textDiagPrinter
=
new
clang
::
TextDiagnosticPrinter
(
errs
(),
&
DiagOpts
);
IntrusiveRefCntPtr
<
clang
::
DiagnosticIDs
>
pDiagIDs
;
DiagnosticsEngine
*
pDiagnosticsEngine
=
new
DiagnosticsEngine
(
pDiagIDs
,
&
DiagOpts
,
textDiagPrinter
);
// Create and initialize CompilerInstance
std
::
unique_ptr
<
CompilerInstance
>
Clang
(
new
CompilerInstance
());
Clang
->
createDiagnostics
();
// Initialize CompilerInvocation
CompilerInvocation
::
CreateFromArgs
(
Clang
->
getInvocation
(),
&
args
[
0
],
&
args
[
0
]
+
args
.
size
(),
*
pDiagnosticsEngine
);
// Infer the builtin include path if unspecified.
if
(
Clang
->
getHeaderSearchOpts
().
UseBuiltinIncludes
&&
Clang
->
getHeaderSearchOpts
().
ResourceDir
.
empty
())
{
void
*
MainAddr
=
reinterpret_cast
<
void
*>
(
GetExecutablePath
);
auto
path
=
CompilerInvocation
::
GetResourcesPath
(
args
[
0
],
MainAddr
);
Clang
->
getHeaderSearchOpts
().
ResourceDir
=
path
;
}
auto
&
HSO
=
Clang
->
getInvocation
().
getHeaderSearchOpts
();
// Add base toolchain-supplied header paths
// Ideally one would use the Linux toolchain definition in clang/lib/Driver/ToolChains.h
// But that's a private header and isn't part of the public libclang API
// Instead of re-implementing all of that functionality in a custom toolchain
// just hardcode the paths relevant to frequently used build/test machines for now
HSO
.
AddPath
(
CLANG_BUILTIN_HEADERS_PATH
,
clang
::
frontend
::
System
,
false
,
false
);
HSO
.
AddPath
(
"/usr/include/x86_64-linux-gnu"
,
clang
::
frontend
::
System
,
false
,
false
);
HSO
.
AddPath
(
"/usr/include"
,
clang
::
frontend
::
System
,
false
,
false
);
// Add C++ standard library headers
// Debian-like + GCC 4.8 libstdc++
HSO
.
AddPath
(
"/usr/include/x86_64-linux-gnu/c++/4.8"
,
clang
::
frontend
::
System
,
false
,
false
);
HSO
.
AddPath
(
"/usr/include/c++/4.8"
,
clang
::
frontend
::
System
,
false
,
false
);
// Debian-like + GCC 5 libstdc++
HSO
.
AddPath
(
"/usr/include/x86_64-linux-gnu/c++/5"
,
clang
::
frontend
::
System
,
false
,
false
);
HSO
.
AddPath
(
"/usr/include/c++/5"
,
clang
::
frontend
::
System
,
false
,
false
);
HSO
.
AddPath
(
EIGEN_HEADERS_PATH
,
clang
::
frontend
::
System
,
false
,
false
);
HSO
.
AddPath
(
NGRAPH_HEADERS_PATH
,
clang
::
frontend
::
System
,
false
,
false
);
// Language options
// These are the C++ features needed to compile ngraph headers
// and any dependencies like Eigen
auto
LO
=
Clang
->
getInvocation
().
getLangOpts
();
LO
->
CPlusPlus
=
1
;
LO
->
CPlusPlus11
=
1
;
LO
->
Bool
=
1
;
LO
->
Exceptions
=
1
;
LO
->
CXXExceptions
=
1
;
LO
->
WChar
=
1
;
LO
->
RTTI
=
1
;
// Enable OpenMP for Eigen
LO
->
OpenMP
=
1
;
LO
->
OpenMPUseTLS
=
1
;
if
(
debuginfo_enabled
)
{
// CodeGen options
auto
&
CGO
=
Clang
->
getInvocation
().
getCodeGenOpts
();
CGO
.
setDebugInfo
(
codegenoptions
::
FullDebugInfo
);
}
if
(
precompiled_headers_enabled
)
{
// Preprocessor options
auto
&
PPO
=
Clang
->
getInvocation
().
getPreprocessorOpts
();
PPO
.
ImplicitPCHInclude
=
"ngcpu.pch"
;
PPO
.
DisablePCHValidation
=
1
;
}
// Enable various target features
// Most of these are for Eigen
auto
&
TO
=
Clang
->
getInvocation
().
getTargetOpts
();
TO
.
FeaturesAsWritten
.
emplace_back
(
"+sse4.1"
);
TO
.
FeaturesAsWritten
.
emplace_back
(
"+sse4.2"
);
TO
.
FeaturesAsWritten
.
emplace_back
(
"+avx"
);
TO
.
FeaturesAsWritten
.
emplace_back
(
"+avx2"
);
TO
.
FeaturesAsWritten
.
emplace_back
(
"+fma"
);
// Map code filename to a memoryBuffer
StringRef
source_ref
(
source
);
unique_ptr
<
MemoryBuffer
>
buffer
=
MemoryBuffer
::
getMemBufferCopy
(
source_ref
);
Clang
->
getInvocation
().
getPreprocessorOpts
().
addRemappedFile
(
name
,
buffer
.
get
());
// Create and execute action
CodeGenAction
*
compilerAction
=
new
EmitCodeGenOnlyAction
();
Clang
->
ExecuteAction
(
*
compilerAction
);
buffer
.
release
();
return
compilerAction
->
takeModule
();
}
bool
execution_state
::
add_module
(
std
::
unique_ptr
<
llvm
::
Module
>&
module
)
{
if
(
module
)
{
if
(
!
m_execution_engine
)
{
m_execution_engine
=
llvm
::
EngineBuilder
(
move
(
module
))
.
setEngineKind
(
llvm
::
EngineKind
::
JIT
)
.
setOptLevel
(
llvm
::
CodeGenOpt
::
Aggressive
)
.
setErrorStr
(
&
jit_error
)
.
create
();
if
(
!
m_execution_engine
)
{
return
false
;
}
}
}
else
{
return
false
;
}
return
true
;
}
void
execution_state
::
finalize
()
{
if
(
m_execution_engine
)
{
m_execution_engine
->
finalizeObject
();
m_execution_engine
->
runStaticConstructorsDestructors
(
false
);
}
else
{
throw
std
::
runtime_error
(
"Error in finalize: "
+
(
jit_error
.
empty
()
?
"Could not create an execution engine"
:
jit_error
));
}
}
src/ngraph/codegen/compiler.hpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
#include <functional>
#include <memory>
#include <string>
#include <llvm/ExecutionEngine/MCJIT.h> // forces JIT to link in
#include <llvm/ExecutionEngine/SectionMemoryManager.h>
#include <llvm/Option/Arg.h>
namespace
ngraph
{
namespace
codegen
{
class
module
;
class
execution_state
;
}
}
class
ngraph
::
codegen
::
module
{
public
:
private
:
std
::
unique_ptr
<
llvm
::
Module
>
m_module
;
};
class
ngraph
::
codegen
::
execution_state
:
public
llvm
::
SectionMemoryManager
{
public
:
execution_state
();
~
execution_state
();
void
set_precompiled_headers_enabled
(
bool
state
)
{
precompiled_headers_enabled
=
state
;
}
bool
is_precompiled_headers_enabled
()
{
return
precompiled_headers_enabled
;
}
void
set_debuginfo_enabled
(
bool
state
)
{
debuginfo_enabled
=
state
;
}
bool
is_debuginfo_enabled
()
{
return
debuginfo_enabled
;
}
std
::
unique_ptr
<
llvm
::
Module
>
compile
(
const
std
::
string
&
source
,
const
std
::
string
&
name
=
""
);
bool
add_module
(
std
::
unique_ptr
<
llvm
::
Module
>&
);
void
finalize
();
template
<
typename
ftype
>
std
::
function
<
ftype
>
find_function
(
const
std
::
string
&
func_name
)
{
auto
f
=
m_execution_engine
->
getPointerToNamedFunction
(
func_name
);
return
f_cast
<
ftype
>
(
f
);
}
private
:
llvm
::
ExecutionEngine
*
m_execution_engine
;
std
::
string
jit_error
;
bool
precompiled_headers_enabled
;
bool
debuginfo_enabled
;
template
<
typename
signature
>
std
::
function
<
signature
>
f_cast
(
void
*
f
)
{
return
static_cast
<
signature
*>
(
reinterpret_cast
<
signature
*>
(
f
));
}
};
src/ngraph/pass/assign_layout.hpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
#include <exception>
#include <sstream>
#include "ngraph/descriptor/output.hpp"
#include "ngraph/pass/pass.hpp"
namespace
ngraph
{
namespace
pass
{
template
<
typename
LT
>
class
AssignLayout
:
public
CallGraphPass
{
public
:
virtual
bool
run_on_call_graph
(
std
::
list
<
std
::
shared_ptr
<
Node
>>&
nodes
)
override
{
for
(
const
std
::
shared_ptr
<
Node
>&
node
:
nodes
)
{
try
{
for
(
const
descriptor
::
Output
&
output
:
node
->
get_outputs
())
{
auto
tv
=
output
.
get_tensor_view
();
if
(
nullptr
==
tv
->
get_tensor_view_layout
())
{
auto
layout
=
std
::
make_shared
<
LT
>
(
*
tv
);
tv
->
set_tensor_view_layout
(
layout
);
}
}
}
catch
(
const
std
::
exception
&
e
)
{
std
::
stringstream
ss
;
ss
<<
"Error with node "
<<
*
node
<<
": "
;
ss
<<
e
.
what
();
throw
std
::
invalid_argument
(
ss
.
str
());
}
}
return
false
;
}
};
}
}
src/ngraph/runtime/cpu/call_frame.cpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <algorithm>
#include "call_frame.hpp"
using
namespace
std
;
using
namespace
ngraph
::
runtime
::
cpu
;
CallFrame
::
CallFrame
(
EntryPoint
compiled_function
,
size_t
n_outputs
,
size_t
n_inputs
,
const
TensorViewPtrs
&
temps
)
:
m_n_outputs
(
n_outputs
)
,
m_n_inputs
(
n_inputs
)
,
m_tensor_views
(
n_inputs
+
n_outputs
+
temps
.
size
())
,
m_compiled_function
(
compiled_function
)
{
copy
(
temps
.
begin
(),
temps
.
end
(),
m_tensor_views
.
begin
()
+
m_n_outputs
+
m_n_inputs
);
}
void
CallFrame
::
tensor_call
(
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>&
inputs
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>&
outputs
)
{
copy
(
outputs
.
begin
(),
outputs
.
end
(),
m_tensor_views
.
begin
());
copy
(
inputs
.
begin
(),
inputs
.
end
(),
m_tensor_views
.
begin
()
+
m_n_outputs
);
// Invoke compiled computation
m_compiled_function
(
this
,
m_tensor_views
);
// Don't hold onto inputs/outputs
fill_n
(
m_tensor_views
.
begin
(),
m_n_outputs
+
m_n_inputs
,
nullptr
);
}
void
CallFrame
::
operator
()(
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Value
>>&
arguments
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Value
>>&
results
)
{
// TODO: Check types of args and result
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>
inputs
;
for
(
auto
argument
:
arguments
)
{
argument
->
collect_tensor_views
(
inputs
,
argument
);
}
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>
outputs
;
for
(
auto
result
:
results
)
{
result
->
collect_tensor_views
(
outputs
,
result
);
}
tensor_call
(
inputs
,
outputs
);
}
src/ngraph/runtime/cpu/call_frame.hpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
#include <functional>
#include <memory>
#include <vector>
#include "ngraph/function.hpp"
#include "ngraph/runtime/call_frame.hpp"
#include "ngraph/runtime/tensor_view.hpp"
namespace
ngraph
{
namespace
runtime
{
class
PrimaryTensorView
;
namespace
cpu
{
class
CallFrame
;
using
EntryPoint
=
std
::
function
<
void
(
ngraph
::
runtime
::
cpu
::
CallFrame
*
,
ngraph
::
runtime
::
TensorViewPtrs
&
)
>
;
// Compile and execute graphs
class
CallFrame
:
public
ngraph
::
runtime
::
CallFrame
{
public
:
CallFrame
(
EntryPoint
compiled_function
,
size_t
n_outputs
,
size_t
n_inputs
,
const
TensorViewPtrs
&
temps
);
/// @brief Invoke the function with values matching the signature of the function.
///
/// Tuples will be expanded into their tensor views to build the call frame.
void
operator
()(
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Value
>>&
inputs
,
const
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
Value
>>&
outputs
);
/// @brief Invoke the function with tuples pre-expanded to their underlying tensor views.
void
tensor_call
(
const
TensorViewPtrs
&
inputs
,
const
TensorViewPtrs
&
outputs
);
void
set_return
()
{
m_return
=
true
;
}
std
::
shared_ptr
<
TensorView
>
get_tensor_view
(
size_t
i
)
{
return
m_tensor_views
[
i
];
}
template
<
typename
ET
>
ParameterizedTensorView
<
ET
>*
get_parameterized_tensor_view
(
size_t
i
)
{
return
m_tensor_views
[
i
]
->
get_parameterized_tensor_view
<
ET
>
();
}
template
<
typename
ET
>
typename
ET
::
type
*
get_tensor_view_data
(
size_t
i
)
{
return
&
get_parameterized_tensor_view
<
ET
>
(
i
)
->
get_vector
()[
0
];
}
protected
:
size_t
m_n_outputs
;
size_t
m_n_inputs
;
TensorViewPtrs
m_tensor_views
;
bool
m_return
;
EntryPoint
m_compiled_function
;
};
}
}
}
src/ngraph/runtime/cpu/cpu_backend.cpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include "ngraph/runtime/cpu/cpu_backend.hpp"
#include "ngraph/runtime/external_function.hpp"
using
namespace
ngraph
::
runtime
::
cpu
;
std
::
shared_ptr
<
ngraph
::
runtime
::
CallFrame
>
CPUBackend
::
make_call_frame
(
const
std
::
shared_ptr
<
ExternalFunction
>&
external_function
)
{
return
external_function
->
make_call_frame
();
}
src/ngraph/runtime/cpu/cpu_backend.hpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
#include "ngraph/runtime/backend.hpp"
namespace
ngraph
{
namespace
runtime
{
namespace
cpu
{
class
CPUBackend
:
public
Backend
{
public
:
virtual
std
::
shared_ptr
<
ngraph
::
runtime
::
CallFrame
>
make_call_frame
(
const
std
::
shared_ptr
<
ngraph
::
runtime
::
ExternalFunction
>&
external_function
);
};
}
}
}
src/ngraph/runtime/cpu/cpu_manager.cpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <memory>
#include "ngraph/runtime/cpu/cpu_backend.hpp"
#include "ngraph/runtime/cpu/cpu_manager.hpp"
#include "ngraph/runtime/cpu/external_function.hpp"
using
namespace
ngraph
::
runtime
::
cpu
;
std
::
shared_ptr
<
ngraph
::
runtime
::
Backend
>
CPUManager
::
allocate_backend
()
{
return
std
::
make_shared
<
CPUBackend
>
();
}
std
::
shared_ptr
<
ngraph
::
runtime
::
ExternalFunction
>
CPUManager
::
compile
(
const
std
::
shared_ptr
<
ngraph
::
Function
>&
fun
)
{
return
std
::
make_shared
<
ExternalFunction
>
(
fun
);
}
ngraph
::
runtime
::
Manager
::
Factory
CPUManager
::
factory
=
ngraph
::
runtime
::
Manager
::
register_factory
(
"CPU"
,
[](
const
std
::
string
&
name
)
->
std
::
shared_ptr
<
ngraph
::
runtime
::
Manager
>
{
return
std
::
make_shared
<
CPUManager
>
();
});
src/ngraph/runtime/cpu/cpu_manager.hpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
#include <memory>
#include "ngraph/codegen/compiler.hpp"
#include "ngraph/runtime/manager.hpp"
namespace
ngraph
{
class
Function
;
namespace
runtime
{
class
ExternalFunction
;
namespace
cpu
{
/// @brief Transformer for the interpreted backend
class
CPUManager
:
public
Manager
{
protected
:
ngraph
::
codegen
::
execution_state
exec_state
;
public
:
virtual
std
::
shared_ptr
<
Backend
>
allocate_backend
()
override
;
virtual
std
::
shared_ptr
<
ngraph
::
runtime
::
ExternalFunction
>
compile
(
const
std
::
shared_ptr
<
ngraph
::
Function
>&
fun
)
override
;
static
Factory
factory
;
};
};
}
}
src/ngraph/runtime/cpu/eigen_utils.hpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
#include <memory>
#include <Eigen/Dense>
#include "ngraph/descriptor/layout/dense_tensor_view_layout.hpp"
#include "ngraph/runtime/cpu/call_frame.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
namespace
ngraph
{
namespace
runtime
{
class
TensorViewInfo
;
namespace
cpu
{
class
CallFrame
;
namespace
eigen
{
using
DynamicStrides
=
Eigen
::
Stride
<
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
;
using
VectorStrides
=
Eigen
::
Stride
<
Eigen
::
Dynamic
,
1
>
;
template
<
typename
ET
>
using
DynamicArray
=
Eigen
::
Array
<
typename
ET
::
type
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
;
template
<
typename
ET
>
using
EigenArrayBase
=
Eigen
::
Map
<
DynamicArray
<
ET
>
,
0
,
DynamicStrides
>
;
template
<
typename
ET
>
using
DynamicMatrix
=
Eigen
::
Matrix
<
typename
ET
::
type
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
,
Eigen
::
RowMajor
>
;
template
<
typename
ET
>
using
EigenMatrixBase
=
Eigen
::
Map
<
DynamicMatrix
<
ET
>
,
0
,
DynamicStrides
>
;
template
<
typename
ET
>
using
DynamicVector
=
Eigen
::
Matrix
<
typename
ET
::
type
,
Eigen
::
Dynamic
,
1
>
;
template
<
typename
ET
>
using
EigenVectorBase
=
Eigen
::
Map
<
DynamicVector
<
ET
>
,
0
,
VectorStrides
>
;
namespace
fmt
{
/// @brief vector format for Eigen wrappers.
class
V
{
public
:
V
(
const
TensorViewInfo
&
tensor_view_info
)
:
l0
(
tensor_view_info
.
get_layout
<
ngraph
::
descriptor
::
layout
::
DenseTensorViewLayout
>
()
->
get_size
())
{
}
V
(
size_t
s
)
:
l0
(
s
)
{
}
public
:
size_t
l0
;
size_t
l1
{
1
};
size_t
s0
{
1
};
size_t
s1
{
1
};
};
class
M
{
M
(
const
std
::
shared_ptr
<
ngraph
::
descriptor
::
layout
::
DenseTensorViewLayout
>&
layout
)
:
M
(
layout
->
get_shape
(),
layout
->
get_strides
())
{
}
public
:
M
(
const
Shape
&
shape
,
const
Strides
&
strides
)
:
l0
(
shape
.
at
(
0
))
,
l1
(
shape
.
at
(
1
))
,
s0
(
strides
.
at
(
0
))
,
s1
(
strides
.
at
(
1
))
{
}
M
(
const
TensorViewInfo
&
tensor_view_info
)
:
M
(
tensor_view_info
.
get_layout
<
ngraph
::
descriptor
::
layout
::
DenseTensorViewLayout
>
())
{
}
public
:
size_t
l0
;
size_t
l1
;
size_t
s0
;
size_t
s1
;
};
}
// ET element type
// FMT array format (fmt::V for vector, etc.)
// BASE select array/matrix
template
<
typename
ET
,
typename
FMT
,
typename
BASE
,
typename
STRIDES
=
DynamicStrides
>
class
EigenWrapper
:
public
BASE
{
using
base
=
BASE
;
public
:
EigenWrapper
(
typename
ET
::
type
*
t
,
const
FMT
&
fmt
)
:
base
(
t
,
fmt
.
l0
,
fmt
.
l1
,
STRIDES
(
fmt
.
s0
,
fmt
.
s1
))
{
}
EigenWrapper
(
typename
ET
::
type
*
t
,
const
std
::
shared_ptr
<
ngraph
::
descriptor
::
layout
::
DenseTensorViewLayout
>&
layout
)
:
base
(
t
,
layout
->
get_size
(),
1
,
DynamicStrides
(
1
,
1
))
{
}
EigenWrapper
(
CallFrame
*
call_frame
,
const
TensorViewInfo
&
tensor_view_info
)
:
EigenWrapper
(
call_frame
->
get_tensor_view_data
<
ET
>
(
tensor_view_info
.
get_index
()),
FMT
(
tensor_view_info
))
{
}
template
<
typename
U
>
EigenWrapper
&
operator
=
(
const
U
&
other
)
{
this
->
base
::
operator
=
(
other
);
return
*
this
;
}
};
template
<
typename
ET
,
typename
FMT
=
fmt
::
V
>
using
EigenArray1d
=
EigenWrapper
<
ET
,
FMT
,
EigenArrayBase
<
ET
>>
;
template
<
typename
ET
,
typename
FMT
=
fmt
::
M
>
using
EigenArray2d
=
EigenWrapper
<
ET
,
FMT
,
EigenArrayBase
<
ET
>>
;
template
<
typename
ET
,
typename
FMT
=
fmt
::
M
>
using
EigenMatrix
=
EigenWrapper
<
ET
,
FMT
,
EigenMatrixBase
<
ET
>>
;
template
<
typename
ET
,
typename
FMT
=
fmt
::
V
>
using
EigenVector
=
EigenWrapper
<
ET
,
FMT
,
EigenVectorBase
<
ET
>
,
VectorStrides
>
;
}
}
}
}
src/ngraph/runtime/cpu/emitter.cpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <iostream>
#include <string>
#include <typeindex>
#include <unordered_map>
#include <vector>
#include "ngraph/descriptor/layout/dense_tensor_view_layout.hpp"
#include "ngraph/node.hpp"
#include "ngraph/ops/broadcast.hpp"
#include "ngraph/ops/concatenate.hpp"
#include "ngraph/ops/constant.hpp"
#include "ngraph/ops/get_tuple_element.hpp"
#include "ngraph/runtime/cpu/emitter.hpp"
#include "ngraph/runtime/cpu/external_function.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
using
namespace
std
;
using
namespace
ngraph
::
runtime
::
cpu
;
using
ngraph
::
descriptor
::
layout
::
DenseTensorViewLayout
;
#define TI(x) type_index(typeid(x))
static
unordered_map
<
type_index
,
string
>
element_type_names
=
{
{
TI
(
ngraph
::
element
::
Bool
),
"Bool"
},
{
TI
(
ngraph
::
element
::
Float32
),
"Float32"
},
{
TI
(
ngraph
::
element
::
Int8
),
"Int8"
},
{
TI
(
ngraph
::
element
::
Int32
),
"Int32"
},
{
TI
(
ngraph
::
element
::
Int64
),
"Int64"
},
{
TI
(
ngraph
::
element
::
UInt8
),
"UInt8"
},
{
TI
(
ngraph
::
element
::
UInt32
),
"UInt32"
},
{
TI
(
ngraph
::
element
::
UInt64
),
"UInt64"
}};
#define EIGEN_VECTOR_FORMAT(x) "fmt::V{" + to_string(x) + "}"
static
std
::
string
EIGEN_MATRIX_FORMAT
(
const
ngraph
::
Shape
&
shape
,
const
ngraph
::
Strides
&
strides
)
{
std
::
string
I
;
for
(
size_t
i
=
0
;
i
<
shape
.
size
();
i
++
)
{
if
(
!
i
)
{
I
+=
"fmt::M{{"
+
to_string
(
shape
[
i
]);
}
else
{
I
+=
", "
+
to_string
(
shape
[
i
]);
}
}
I
+=
"}, "
;
for
(
size_t
i
=
0
;
i
<
strides
.
size
();
i
++
)
{
if
(
!
i
)
{
I
+=
"{"
+
to_string
(
strides
[
i
]);
}
else
{
I
+=
", "
+
to_string
(
strides
[
i
]);
}
}
I
+=
"}}"
;
return
I
;
}
void
Emitter
::
EMITTER_DECL
(
EmitNop
)
{
}
void
Emitter
::
EMITTER_DECL
(
EmitAdd
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") +
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
");
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitDot
)
{
auto
&
arg_nodes
=
n
->
get_arguments
();
assert
(
arg_nodes
.
size
()
==
2
);
auto
arg0_tensor_type
=
dynamic_pointer_cast
<
const
TensorViewType
>
(
arg_nodes
.
at
(
0
)
->
get_value_type
());
assert
(
arg0_tensor_type
);
auto
arg1_tensor_type
=
dynamic_pointer_cast
<
const
TensorViewType
>
(
arg_nodes
.
at
(
1
)
->
get_value_type
());
assert
(
arg1_tensor_type
);
auto
arg0_shape
=
arg0_tensor_type
->
get_shape
();
auto
arg1_shape
=
arg1_tensor_type
->
get_shape
();
auto
&
arg0_element_type
=
arg0_tensor_type
->
get_element_type
();
if
(
arg0_shape
.
empty
()
||
arg1_shape
.
empty
())
{
auto
&
first
=
(
arg0_shape
.
empty
()
?
inputs
[
0
]
:
inputs
[
1
]);
auto
&
second
=
(
arg0_shape
.
empty
()
?
inputs
[
1
]
:
inputs
[
0
]);
TU
+=
" {
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">("
+
to_string
(
second
.
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenVector<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") = "
"call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">("
+
to_string
(
first
.
get_index
())
+
")[0] * EigenVector<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
second
.
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
");
\n
"
" }
\n
"
;
}
else
if
((
arg0_shape
.
size
()
==
1
)
&&
(
arg1_shape
.
size
()
==
1
))
{
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenVector<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") <<
\n
"
" EigenVector<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
").dot("
"EigenVector<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
"));
\n
"
" }
\n
"
;
}
else
if
((
arg0_shape
.
size
()
==
2
)
&&
(
arg1_shape
.
size
()
==
1
))
{
auto
arg0_layout
=
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenVector<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" EigenMatrix<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">(arg0, "
+
EIGEN_MATRIX_FORMAT
(
arg0_layout
->
get_shape
(),
arg0_layout
->
get_strides
())
+
") * "
"EigenVector<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
");
\n
"
" }
\n
"
;
}
else
if
((
arg0_shape
.
size
()
==
2
)
&&
(
arg1_shape
.
size
()
==
2
))
{
auto
arg0_layout
=
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
();
auto
arg1_layout
=
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
();
auto
out_layout
=
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenMatrix<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">(out, "
+
EIGEN_MATRIX_FORMAT
(
out_layout
->
get_shape
(),
out_layout
->
get_strides
())
+
") =
\n
"
" EigenMatrix<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">(arg0, "
+
EIGEN_MATRIX_FORMAT
(
arg0_layout
->
get_shape
(),
arg0_layout
->
get_strides
())
+
") * "
"EigenMatrix<"
+
element_type_names
[
TI
(
arg0_element_type
)]
+
">(arg1, "
+
EIGEN_MATRIX_FORMAT
(
arg1_layout
->
get_shape
(),
arg1_layout
->
get_strides
())
+
");
\n
"
" }
\n
"
;
}
else
{
throw
ngraph_error
(
"Dot product not implemented for given inputs"
);
}
}
void
Emitter
::
EMITTER_DECL
(
EmitMultiply
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") *
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
");
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitGetTupleElement
)
{
auto
get_tuple_element
=
static_cast
<
const
op
::
GetTupleElement
*>
(
n
);
auto
result_tensor_type
=
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_value_type
());
assert
(
result_tensor_type
);
auto
&
result_element_type
=
result_tensor_type
->
get_element_type
();
TU
+=
" {
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
outputs
.
at
(
0
).
get_index
())
+
")->get_vector() =
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
inputs
.
at
(
get_tuple_element
->
get_n
()).
get_index
())
+
")->get_vector();
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitTuple
)
{
assert
(
inputs
.
size
()
==
outputs
.
size
());
TU
+=
" {
\n
"
;
for
(
size_t
i
=
0
;
i
<
inputs
.
size
();
++
i
)
{
auto
&
et
=
inputs
.
at
(
i
).
get_tensor_view_layout
()
->
get_element_type
();
TU
+=
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
outputs
.
at
(
i
).
get_index
())
+
")->get_vector() =
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
.
at
(
i
).
get_index
())
+
")->get_vector();
\n
"
;
}
TU
+=
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitAbs
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" Eigen::abs(EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
"));
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitConcat
)
{
auto
result_tensor_type
=
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_value_type
());
assert
(
result_tensor_type
);
auto
result_shape
=
result_tensor_type
->
get_shape
();
auto
&
result_element_type
=
result_tensor_type
->
get_element_type
();
if
(
result_shape
.
size
()
==
1
)
{
TU
+=
" {
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenVector<"
+
element_type_names
[
TI
(
result_element_type
)]
+
"> out_vector(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
");
\n
"
;
size_t
concat_pos
=
0
;
for
(
size_t
i
=
0
;
i
<
inputs
.
size
();
i
++
)
{
TU
+=
" out_vector.segment("
+
to_string
(
concat_pos
)
+
", "
+
to_string
(
inputs
[
i
].
get_tensor_view_layout
()
->
get_shape
().
at
(
0
))
+
") << "
"EigenVector<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">(call_frame->"
"get_tensor_view_data<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
inputs
[
i
].
get_index
())
+
"), "
EIGEN_VECTOR_FORMAT
(
inputs
[
i
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
");
\n
"
;
concat_pos
+=
inputs
[
i
].
get_tensor_view_layout
()
->
get_shape
().
at
(
0
);
}
TU
+=
" }
\n
"
;
}
else
if
(
result_shape
.
size
()
==
2
)
{
auto
out_layout
=
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
();
auto
axis
=
(
dynamic_cast
<
const
op
::
Concat
*>
(
n
))
->
get_concatenation_axis
();
TU
+=
" {
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenMatrix<"
+
element_type_names
[
TI
(
result_element_type
)]
+
"> out_matrix(out, "
+
EIGEN_MATRIX_FORMAT
(
out_layout
->
get_shape
(),
out_layout
->
get_strides
())
+
");
\n
"
;
size_t
concat_pos
[
2
]{
0
,
0
};
for
(
size_t
i
=
0
;
i
<
inputs
.
size
();
i
++
)
{
auto
arg_layout
=
inputs
[
i
].
get_layout
<
DenseTensorViewLayout
>
();
auto
&
arg_shape
=
inputs
[
i
].
get_tensor_view_layout
()
->
get_shape
();
TU
+=
" out_matrix.block("
+
to_string
(
concat_pos
[
0
])
+
", "
+
to_string
(
concat_pos
[
1
])
+
", "
+
to_string
(
arg_shape
.
at
(
0
))
+
", "
+
to_string
(
arg_shape
.
at
(
1
))
+
") << "
"EigenMatrix<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">(call_frame->"
"get_tensor_view_data<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
inputs
[
i
].
get_index
())
+
"), "
+
EIGEN_MATRIX_FORMAT
(
arg_layout
->
get_shape
(),
arg_layout
->
get_strides
())
+
");
\n
"
;
concat_pos
[
axis
]
+=
arg_shape
.
at
(
axis
);
}
TU
+=
" }
\n
"
;
}
}
void
Emitter
::
EMITTER_DECL
(
EmitDivide
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") /
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
");
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitEqual
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<Bool>("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<Bool>(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" (EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") ==
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
")).template cast<char>();
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitGreater
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<Bool>("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<Bool>(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" (EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") >
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
")).template cast<char>();
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitGreaterEq
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<Bool>("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<Bool>(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" (EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") >=
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
")).template cast<char>();
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitLess
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<Bool>("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<Bool>(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" (EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") <
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
")).template cast<char>();
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitLessEq
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<Bool>("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<Bool>(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" (EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") <=
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
")).template cast<char>();
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitLog
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" Eigen::log(EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
"));
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitMaximum
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
").max("
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
"));
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitNegative
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" -EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
");
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitNotEqual
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<Bool>("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<Bool>(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" (EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") !=
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
")).template cast<char>();
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitSelect
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
1
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<Bool>("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto arg2 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
2
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" EigenArray1d<Bool>(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
")
\n
"
".select(EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
"),
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg2, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
"));
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitSubtract
)
{
const
element
::
Type
&
et
=
(
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
()))
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto arg1 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
inputs
[
1
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
et
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") -
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
et
)]
+
">(arg1, "
EIGEN_VECTOR_FORMAT
(
inputs
[
1
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
");
\n
"
" }
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitParameterizedConstantBool
)
{
auto
value
=
dynamic_cast
<
const
op
::
ParameterizedConstant
<
ngraph
::
element
::
Bool
>*>
(
n
)
->
get_value
()
->
get_vector
();
TU
+=
" {
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
ngraph
::
element
::
Bool
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
")->get_vector() = std::vector<"
+
element_type_names
[
TI
(
ngraph
::
element
::
Bool
)]
+
"::type>{"
;
for
(
size_t
i
=
0
;
i
<
value
.
size
();
i
++
)
{
if
(
i
)
TU
+=
", "
;
if
(
value
[
i
])
{
TU
+=
"true"
;
}
else
{
TU
+=
"false"
;
}
}
TU
+=
"};
\n
}
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitParameterizedConstantFloat32
)
{
auto
value
=
dynamic_cast
<
const
op
::
ParameterizedConstant
<
ngraph
::
element
::
Float32
>*>
(
n
)
->
get_value
()
->
get_vector
();
TU
+=
" {
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
ngraph
::
element
::
Float32
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
")->get_vector() = std::vector<"
+
element_type_names
[
TI
(
ngraph
::
element
::
Float32
)]
+
"::type>{"
;
for
(
size_t
i
=
0
;
i
<
value
.
size
();
i
++
)
{
if
(
i
)
TU
+=
", "
;
TU
+=
to_string
(
value
[
i
])
+
"f"
;
}
TU
+=
"};
\n
}
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitParameterizedConstantInt8
)
{
auto
value
=
dynamic_cast
<
const
op
::
ParameterizedConstant
<
ngraph
::
element
::
Int8
>*>
(
n
)
->
get_value
()
->
get_vector
();
TU
+=
" {
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
ngraph
::
element
::
Int8
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
")->get_vector() = std::vector<"
+
element_type_names
[
TI
(
ngraph
::
element
::
Int8
)]
+
"::type>{"
;
for
(
size_t
i
=
0
;
i
<
value
.
size
();
i
++
)
{
if
(
i
)
TU
+=
", "
;
TU
+=
to_string
(
value
[
i
]);
}
TU
+=
"};
\n
}
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitParameterizedConstantInt32
)
{
auto
value
=
dynamic_cast
<
const
op
::
ParameterizedConstant
<
ngraph
::
element
::
Int32
>*>
(
n
)
->
get_value
()
->
get_vector
();
TU
+=
" {
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
ngraph
::
element
::
Int32
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
")->get_vector() = std::vector<"
+
element_type_names
[
TI
(
ngraph
::
element
::
Int32
)]
+
"::type>{"
;
for
(
size_t
i
=
0
;
i
<
value
.
size
();
i
++
)
{
if
(
i
)
TU
+=
", "
;
TU
+=
to_string
(
value
[
i
]);
}
TU
+=
"};
\n
}
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitParameterizedConstantInt64
)
{
auto
value
=
dynamic_cast
<
const
op
::
ParameterizedConstant
<
ngraph
::
element
::
Int64
>*>
(
n
)
->
get_value
()
->
get_vector
();
TU
+=
" {
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
ngraph
::
element
::
Int64
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
")->get_vector() = std::vector<"
+
element_type_names
[
TI
(
ngraph
::
element
::
Int64
)]
+
"::type>{"
;
for
(
size_t
i
=
0
;
i
<
value
.
size
();
i
++
)
{
if
(
i
)
TU
+=
", "
;
TU
+=
to_string
(
value
[
i
]);
}
TU
+=
"};
\n
}
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitParameterizedConstantUInt8
)
{
auto
value
=
dynamic_cast
<
const
op
::
ParameterizedConstant
<
ngraph
::
element
::
UInt8
>*>
(
n
)
->
get_value
()
->
get_vector
();
TU
+=
" {
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
ngraph
::
element
::
UInt8
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
")->get_vector() = std::vector<"
+
element_type_names
[
TI
(
ngraph
::
element
::
UInt8
)]
+
"::type>{"
;
for
(
size_t
i
=
0
;
i
<
value
.
size
();
i
++
)
{
if
(
i
)
TU
+=
", "
;
TU
+=
to_string
(
value
[
i
]);
}
TU
+=
"};
\n
}
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitParameterizedConstantUInt32
)
{
auto
value
=
dynamic_cast
<
const
op
::
ParameterizedConstant
<
ngraph
::
element
::
UInt32
>*>
(
n
)
->
get_value
()
->
get_vector
();
TU
+=
" {
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
ngraph
::
element
::
UInt32
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
")->get_vector() = std::vector<"
+
element_type_names
[
TI
(
ngraph
::
element
::
UInt32
)]
+
"::type>{"
;
for
(
size_t
i
=
0
;
i
<
value
.
size
();
i
++
)
{
if
(
i
)
TU
+=
", "
;
TU
+=
to_string
(
value
[
i
]);
}
TU
+=
"};
\n
}
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitParameterizedConstantUInt64
)
{
auto
value
=
dynamic_cast
<
const
op
::
ParameterizedConstant
<
ngraph
::
element
::
UInt64
>*>
(
n
)
->
get_value
()
->
get_vector
();
TU
+=
" {
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
ngraph
::
element
::
UInt64
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
")->get_vector() = std::vector<"
+
element_type_names
[
TI
(
ngraph
::
element
::
UInt64
)]
+
"::type>{"
;
for
(
size_t
i
=
0
;
i
<
value
.
size
();
i
++
)
{
if
(
i
)
TU
+=
", "
;
TU
+=
to_string
(
value
[
i
]);
}
TU
+=
"};
\n
}
\n
"
;
}
void
Emitter
::
EMITTER_DECL
(
EmitBroadcast
)
{
auto
broadcast
=
static_cast
<
const
op
::
Broadcast
*>
(
n
);
auto
arg_tensor_type
=
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_arguments
().
at
(
0
)
->
get_value_type
());
assert
(
arg_tensor_type
);
auto
result_tensor_type
=
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_value_type
());
assert
(
result_tensor_type
);
auto
arg_shape
=
arg_tensor_type
->
get_shape
();
auto
result_shape
=
result_tensor_type
->
get_shape
();
auto
&
result_element_type
=
result_tensor_type
->
get_element_type
();
if
(
broadcast
->
get_broadcast_axes
().
empty
())
{
TU
+=
" {
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
")->get_vector() =
\n
"
" call_frame->get_parameterized_tensor_view<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
")->get_vector();
\n
"
" }
\n
"
;
}
else
if
(
arg_shape
.
size
()
==
0
)
{
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
")(0, 0);
\n
"
" }
\n
"
;
}
else
if
(
arg_shape
.
size
()
==
1
&&
result_shape
.
size
()
==
2
)
{
if
(
broadcast
->
get_broadcast_axes
()
==
AxisSet
{
1
})
{
auto
out_layout
=
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenMatrix<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">(out, "
+
EIGEN_MATRIX_FORMAT
(
out_layout
->
get_shape
(),
out_layout
->
get_strides
())
+
").colwise() =
\n
"
" EigenVector<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
");
\n
"
" }
\n
"
;
}
else
if
(
broadcast
->
get_broadcast_axes
()
==
AxisSet
{
0
})
{
auto
out_layout
=
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenMatrix<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">(out, "
+
EIGEN_MATRIX_FORMAT
(
out_layout
->
get_shape
(),
out_layout
->
get_strides
())
+
").rowwise() =
\n
"
" EigenVector<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
").transpose();
\n
"
" }
\n
"
;
}
else
{
throw
ngraph_error
(
"Internal error: axis set for vector-matrix broadcast is neither {0} nor "
"{1}"
);
}
}
else
{
throw
ngraph_error
(
"Broadcast not implemented for given inputs"
);
}
}
void
Emitter
::
EMITTER_DECL
(
EmitConvert
)
{
auto
arg
=
n
->
get_arguments
().
at
(
0
);
auto
arg_tensor_type
=
dynamic_pointer_cast
<
const
TensorViewType
>
(
arg
->
get_value_type
());
assert
(
arg_tensor_type
);
auto
&
arg_element_type
=
arg_tensor_type
->
get_element_type
();
auto
result_tensor_type
=
dynamic_pointer_cast
<
const
TensorViewType
>
(
n
->
get_value_type
());
assert
(
result_tensor_type
);
auto
&
result_element_type
=
result_tensor_type
->
get_element_type
();
TU
+=
" {
\n
"
" auto arg0 = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
arg_element_type
)]
+
">("
+
to_string
(
inputs
[
0
].
get_index
())
+
");
\n
"
" auto out = call_frame->get_tensor_view_data<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">("
+
to_string
(
outputs
[
0
].
get_index
())
+
");
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
result_element_type
)]
+
">(out, "
EIGEN_VECTOR_FORMAT
(
outputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
") =
\n
"
" EigenArray1d<"
+
element_type_names
[
TI
(
arg_element_type
)]
+
">(arg0, "
EIGEN_VECTOR_FORMAT
(
inputs
[
0
].
get_layout
<
DenseTensorViewLayout
>
()
->
get_size
())
")
\n
"
".template cast<typename "
+
element_type_names
[
TI
(
result_element_type
)]
+
"::type>();
\n
"
" }
\n
"
;
}
src/ngraph/runtime/cpu/emitter.hpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
#include <string>
#include <vector>
#include "ngraph/node.hpp"
#include "ngraph/runtime/cpu/external_function.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
#define EMITTER_DECL(E) \
E(const ngraph::Node* n, \
ExternalFunction* ef, \
FunctionMap& function_map, \
const std::vector<TensorViewInfo>& inputs, \
const std::vector<TensorViewInfo>& outputs)
namespace
ngraph
{
namespace
runtime
{
namespace
cpu
{
class
Emitter
{
protected
:
std
::
string
TU
;
public
:
Emitter
()
:
TU
(
""
)
{
}
std
::
string
&
GetTU
()
{
return
TU
;
}
void
EMITTER_DECL
(
EmitNop
);
void
EMITTER_DECL
(
EmitAdd
);
void
EMITTER_DECL
(
EmitDot
);
void
EMITTER_DECL
(
EmitMultiply
);
void
EMITTER_DECL
(
EmitGetTupleElement
);
void
EMITTER_DECL
(
EmitTuple
);
void
EMITTER_DECL
(
EmitAbs
);
void
EMITTER_DECL
(
EmitConcat
);
void
EMITTER_DECL
(
EmitDivide
);
void
EMITTER_DECL
(
EmitEqual
);
void
EMITTER_DECL
(
EmitGreater
);
void
EMITTER_DECL
(
EmitGreaterEq
);
void
EMITTER_DECL
(
EmitLess
);
void
EMITTER_DECL
(
EmitLessEq
);
void
EMITTER_DECL
(
EmitLog
);
void
EMITTER_DECL
(
EmitMaximum
);
void
EMITTER_DECL
(
EmitNegative
);
void
EMITTER_DECL
(
EmitNotEqual
);
void
EMITTER_DECL
(
EmitSelect
);
void
EMITTER_DECL
(
EmitSubtract
);
void
EMITTER_DECL
(
EmitParameterizedConstantBool
);
void
EMITTER_DECL
(
EmitParameterizedConstantFloat32
);
void
EMITTER_DECL
(
EmitParameterizedConstantInt8
);
void
EMITTER_DECL
(
EmitParameterizedConstantInt32
);
void
EMITTER_DECL
(
EmitParameterizedConstantInt64
);
void
EMITTER_DECL
(
EmitParameterizedConstantUInt8
);
void
EMITTER_DECL
(
EmitParameterizedConstantUInt32
);
void
EMITTER_DECL
(
EmitParameterizedConstantUInt64
);
void
EMITTER_DECL
(
EmitBroadcast
);
void
EMITTER_DECL
(
EmitConvert
);
};
}
}
}
src/ngraph/runtime/cpu/external_function.cpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <fstream>
#include <memory>
#include <string>
#include <tuple>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include "ngraph/codegen/compiler.hpp"
#include "ngraph/descriptor/input.hpp"
#include "ngraph/descriptor/layout/dense_tensor_view_layout.hpp"
#include "ngraph/descriptor/output.hpp"
#include "ngraph/function.hpp"
#include "ngraph/node.hpp"
#include "ngraph/ops/abs.hpp"
#include "ngraph/ops/add.hpp"
#include "ngraph/ops/broadcast.hpp"
#include "ngraph/ops/concatenate.hpp"
#include "ngraph/ops/constant.hpp"
#include "ngraph/ops/convert.hpp"
#include "ngraph/ops/divide.hpp"
#include "ngraph/ops/dot.hpp"
#include "ngraph/ops/equal.hpp"
#include "ngraph/ops/function_call.hpp"
#include "ngraph/ops/get_tuple_element.hpp"
#include "ngraph/ops/greater.hpp"
#include "ngraph/ops/greater_eq.hpp"
#include "ngraph/ops/less.hpp"
#include "ngraph/ops/less_eq.hpp"
#include "ngraph/ops/log.hpp"
#include "ngraph/ops/maximum.hpp"
#include "ngraph/ops/multiply.hpp"
#include "ngraph/ops/negative.hpp"
#include "ngraph/ops/not_equal.hpp"
#include "ngraph/ops/reduce.hpp"
#include "ngraph/ops/select.hpp"
#include "ngraph/ops/subtract.hpp"
#include "ngraph/ops/tuple.hpp"
#include "ngraph/pass/assign_layout.hpp"
#include "ngraph/pass/assign_tensors.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pass/propagate_types.hpp"
#include "ngraph/pass/topological_sort.hpp"
#include "ngraph/runtime/cpu/call_frame.hpp"
#include "ngraph/runtime/cpu/emitter.hpp"
#include "ngraph/runtime/cpu/external_function.hpp"
#include "ngraph/runtime/utils.hpp"
using
namespace
std
;
using
namespace
ngraph
::
runtime
::
cpu
;
using
ngraph
::
descriptor
::
layout
::
DenseTensorViewLayout
;
#define TI(x) type_index(typeid(x))
static
const
OpMap
dispatcher
{
{
TI
(
ngraph
::
op
::
Add
),
&
Emitter
::
EmitAdd
},
{
TI
(
ngraph
::
op
::
Dot
),
&
Emitter
::
EmitDot
},
{
TI
(
ngraph
::
op
::
Multiply
),
&
Emitter
::
EmitMultiply
},
{
TI
(
ngraph
::
op
::
Parameter
),
&
Emitter
::
EmitNop
},
{
TI
(
ngraph
::
op
::
GetTupleElement
),
&
Emitter
::
EmitGetTupleElement
},
{
TI
(
ngraph
::
op
::
Tuple
),
&
Emitter
::
EmitTuple
},
{
TI
(
ngraph
::
op
::
Abs
),
&
Emitter
::
EmitAbs
},
{
TI
(
ngraph
::
op
::
Concat
),
&
Emitter
::
EmitConcat
},
{
TI
(
ngraph
::
op
::
Divide
),
&
Emitter
::
EmitDivide
},
{
TI
(
ngraph
::
op
::
Equal
),
&
Emitter
::
EmitEqual
},
{
TI
(
ngraph
::
op
::
Greater
),
&
Emitter
::
EmitGreater
},
{
TI
(
ngraph
::
op
::
GreaterEq
),
&
Emitter
::
EmitGreaterEq
},
{
TI
(
ngraph
::
op
::
Less
),
&
Emitter
::
EmitLess
},
{
TI
(
ngraph
::
op
::
LessEq
),
&
Emitter
::
EmitLessEq
},
{
TI
(
ngraph
::
op
::
Log
),
&
Emitter
::
EmitLog
},
{
TI
(
ngraph
::
op
::
Maximum
),
&
Emitter
::
EmitMaximum
},
{
TI
(
ngraph
::
op
::
Negative
),
&
Emitter
::
EmitNegative
},
{
TI
(
ngraph
::
op
::
NotEqual
),
&
Emitter
::
EmitNotEqual
},
{
TI
(
ngraph
::
op
::
Select
),
&
Emitter
::
EmitSelect
},
{
TI
(
ngraph
::
op
::
Subtract
),
&
Emitter
::
EmitSubtract
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Bool
>
),
&
Emitter
::
EmitParameterizedConstantBool
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Float32
>
),
&
Emitter
::
EmitParameterizedConstantFloat32
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Int8
>
),
&
Emitter
::
EmitParameterizedConstantInt8
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Int32
>
),
&
Emitter
::
EmitParameterizedConstantInt32
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
Int64
>
),
&
Emitter
::
EmitParameterizedConstantInt64
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
UInt8
>
),
&
Emitter
::
EmitParameterizedConstantUInt8
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
UInt32
>
),
&
Emitter
::
EmitParameterizedConstantUInt32
},
{
TI
(
ngraph
::
op
::
ParameterizedConstant
<
ngraph
::
element
::
UInt64
>
),
&
Emitter
::
EmitParameterizedConstantUInt64
},
{
TI
(
ngraph
::
op
::
Broadcast
),
&
Emitter
::
EmitBroadcast
},
{
TI
(
ngraph
::
op
::
Convert
),
&
Emitter
::
EmitConvert
},
};
#undef TI
ExternalFunction
::
ExternalFunction
(
const
std
::
shared_ptr
<
ngraph
::
Function
>&
function
,
bool
release_function
)
:
ngraph
::
runtime
::
ExternalFunction
(
function
,
release_function
)
,
compiled_function
(
nullptr
)
{
}
void
ExternalFunction
::
compile
(
FunctionMap
&
function_map
)
{
if
(
m_is_compiled
)
{
return
;
}
pass
::
Manager
pass_manager
;
pass_manager
.
register_pass
<
pass
::
TopologicalSort
>
();
pass_manager
.
register_pass
<
pass
::
PropagateTypes
>
();
pass_manager
.
register_pass
<
pass
::
AssignTensors
>
();
// For now, just make everyone row-major.
pass_manager
.
register_pass
<
pass
::
AssignLayout
<
DenseTensorViewLayout
>>
();
pass_manager
.
run_passes
(
m_function
);
// Determine tensor requirements for the call frame
unordered_map
<
shared_ptr
<
ngraph
::
descriptor
::
TensorView
>
,
size_t
>
tensor_index
;
// First come the function outputs
for
(
const
descriptor
::
Output
&
output
:
m_function
->
get_result
()
->
get_outputs
())
{
auto
tv
=
output
.
get_tensor_view
();
size_t
index
=
tensor_index
.
size
();
tensor_index
[
tv
]
=
index
;
}
m_n_outputs
=
tensor_index
.
size
();
// Next are the function inputs
for
(
auto
param
:
m_function
->
get_parameters
())
{
for
(
const
descriptor
::
Output
&
output
:
param
->
get_outputs
())
{
auto
tv
=
output
.
get_tensor_view
();
size_t
index
=
tensor_index
.
size
();
tensor_index
[
tv
]
=
index
;
}
}
m_n_inputs
=
tensor_index
.
size
()
-
m_n_outputs
;
// All remaining tensor views
for
(
shared_ptr
<
Node
>
node
:
m_function
->
get_ordered_ops
())
{
for
(
const
descriptor
::
Output
&
output
:
node
->
get_outputs
())
{
auto
tv
=
output
.
get_tensor_view
();
if
(
0
==
tensor_index
.
count
(
tv
))
{
size_t
index
=
tensor_index
.
size
();
tensor_index
[
tv
]
=
index
;
m_temp_views
.
push_back
(
tv
);
}
}
}
// Now we build the TU
Emitter
emitter
;
auto
&
TU
=
emitter
.
GetTU
();
TU
+=
R"(
#include <memory>
#include <vector>
#include <Eigen/Dense>
#include "ngraph/descriptor/layout/dense_tensor_view_layout.hpp"
#include "ngraph/runtime/cpu/call_frame.hpp"
#include "ngraph/runtime/cpu/eigen_utils.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
void *__dso_handle = 0;
using namespace ngraph::element;
using namespace ngraph::runtime;
using namespace ngraph::runtime::cpu::eigen;
extern "C" void __entrypoint(ngraph::runtime::cpu::CallFrame* call_frame,
ngraph::runtime::TensorViewPtrs& tensor_views)
{
)"
;
for
(
shared_ptr
<
Node
>
node
:
m_function
->
get_ordered_ops
())
{
auto
&
n
=
*
node
;
// Work around a compiler warning (*node inside typeid may have effects
// with shared pointers, which is fine here but clang doesn't like it.)
auto
handler
=
dispatcher
.
find
(
type_index
(
typeid
(
n
)));
if
(
handler
==
dispatcher
.
end
())
{
throw
ngraph_error
(
"Unhandled op during code generation : "
+
node
->
description
());
}
std
::
vector
<
TensorViewInfo
>
in
;
for
(
const
descriptor
::
Input
&
input
:
node
->
get_inputs
())
{
const
descriptor
::
Output
&
output
=
input
.
get_output
();
auto
tv
=
output
.
get_tensor_view
();
in
.
push_back
({
tensor_index
.
at
(
tv
),
tv
});
}
std
::
vector
<
TensorViewInfo
>
out
;
for
(
const
descriptor
::
Output
&
output
:
node
->
get_outputs
())
{
auto
tv
=
output
.
get_tensor_view
();
out
.
push_back
({
tensor_index
.
at
(
tv
),
tv
});
}
handler
->
second
(
&
emitter
,
node
.
get
(),
this
,
function_map
,
in
,
out
);
}
// End TU
TU
+=
"}
\n
"
;
// TODO: Cleanup and make this a utility function
ofstream
out
(
"__ngcpu_codegen.cpp"
);
out
<<
TU
;
out
.
close
();
ngraph
::
codegen
::
execution_state
estate
;
#if NGCPU_PCH
estate
.
set_precompiled_headers_enabled
(
true
);
#endif
#if NGCPU_DEBUGINFO
estate
.
set_debuginfo_enabled
(
true
);
#endif
auto
llvm_module
=
estate
.
compile
(
TU
,
"__ngcpu_codegen.cpp"
);
assert
(
llvm_module
);
estate
.
add_module
(
llvm_module
);
estate
.
finalize
();
compiled_function
=
estate
.
find_function
<
void
(
ngraph
::
runtime
::
cpu
::
CallFrame
*
,
ngraph
::
runtime
::
TensorViewPtrs
&
)
>
(
"__entrypoint"
);
assert
(
compiled_function
);
m_is_compiled
=
true
;
if
(
m_release_function
)
{
release_function
();
}
}
// Suppress Clang's complaints about the ,##__VA_ARGS__ token-pasting hack, which is a GNU extension
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#define DO_ON_ELEMENT_TYPE(et, err_msg, macro, ...) \
{ \
if (et == element::Bool::element_type()) \
{ \
macro(element::Bool, ##__VA_ARGS__); \
} \
else if (et == element::Float32::element_type()) \
{ \
macro(element::Float32, ##__VA_ARGS__); \
} \
else if (et == element::Int8::element_type()) \
{ \
macro(element::Int8, ##__VA_ARGS__); \
} \
else if (et == element::Int32::element_type()) \
{ \
macro(element::Int32, ##__VA_ARGS__); \
} \
else if (et == element::Int64::element_type()) \
{ \
macro(element::Int64, ##__VA_ARGS__); \
} \
else if (et == element::UInt8::element_type()) \
{ \
macro(element::UInt8, ##__VA_ARGS__); \
} \
else if (et == element::UInt32::element_type()) \
{ \
macro(element::UInt32, ##__VA_ARGS__); \
} \
else if (et == element::UInt64::element_type()) \
{ \
macro(element::UInt64, ##__VA_ARGS__); \
} \
else \
{ \
throw ngraph_error(err_msg); \
} \
}
// Turn off complaint suppression (see above)
#pragma clang diagnostic pop
shared_ptr
<
ngraph
::
runtime
::
CallFrame
>
ExternalFunction
::
make_call_frame
()
{
FunctionMap
function_map
;
if
(
!
m_is_compiled
)
{
compile
(
function_map
);
}
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
runtime
::
TensorView
>>
temps
;
for
(
auto
tv
:
m_temp_views
)
{
auto
&
et
=
tv
->
get_tensor_view_type
()
->
get_element_type
();
auto
shape
=
tv
->
get_tensor_view_type
()
->
get_shape
();
#define M(T) temps.push_back(ngraph::runtime::make_tensor<T>(shape));
DO_ON_ELEMENT_TYPE
(
et
,
"Internal error: tried to create temporary for unhandled element type"
,
M
);
#undef M
}
return
make_shared
<
ngraph
::
runtime
::
cpu
::
CallFrame
>
(
compiled_function
,
m_n_outputs
,
m_n_inputs
,
temps
);
}
src/ngraph/runtime/cpu/external_function.hpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
#include <functional>
#include <memory>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include "ngraph/codegen/compiler.hpp"
#include "ngraph/function.hpp"
#include "ngraph/runtime/external_function.hpp"
#include "ngraph/runtime/tensor_view_info.hpp"
namespace
ngraph
{
namespace
runtime
{
namespace
cpu
{
class
ExternalFunction
;
class
Emitter
;
class
CallFrame
;
using
FunctionMap
=
std
::
unordered_map
<
std
::
shared_ptr
<
Function
>
,
std
::
shared_ptr
<
ExternalFunction
>>
;
using
OpFunction
=
std
::
function
<
void
(
Emitter
*
,
const
ngraph
::
Node
*
,
ExternalFunction
*
,
FunctionMap
&
,
const
std
::
vector
<
TensorViewInfo
>&
inputs
,
const
std
::
vector
<
TensorViewInfo
>&
outputs
)
>
;
using
OpMap
=
std
::
unordered_map
<
std
::
type_index
,
OpFunction
>
;
using
EntryPoint
=
std
::
function
<
void
(
ngraph
::
runtime
::
cpu
::
CallFrame
*
,
ngraph
::
runtime
::
TensorViewPtrs
&
)
>
;
class
ExternalFunction
:
public
ngraph
::
runtime
::
ExternalFunction
{
public
:
ExternalFunction
(
const
std
::
shared_ptr
<
ngraph
::
Function
>&
function
,
bool
release_function
=
true
);
std
::
shared_ptr
<
ngraph
::
runtime
::
CallFrame
>
make_call_frame
();
protected
:
void
compile
(
FunctionMap
&
function_map
);
size_t
m_n_inputs
;
size_t
m_n_outputs
;
ngraph
::
descriptor
::
TensorViewPtrs
m_temp_views
;
EntryPoint
compiled_function
;
};
}
}
}
src/ngraph/runtime/tensor_view_info.hpp
View file @
af18be14
...
@@ -27,7 +27,7 @@ namespace ngraph
...
@@ -27,7 +27,7 @@ namespace ngraph
{
{
public
:
public
:
TensorViewInfo
(
size_t
index
,
TensorViewInfo
(
size_t
index
,
const
std
::
shared_ptr
<
ngraph
::
descriptor
::
TensorView
>&
descriptor
)
const
std
::
shared_ptr
<
const
ngraph
::
descriptor
::
TensorView
>&
descriptor
)
:
m_index
(
index
)
:
m_index
(
index
)
,
m_layout
(
descriptor
->
get_tensor_view_layout
())
,
m_layout
(
descriptor
->
get_tensor_view_layout
())
{
{
...
...
test/CMakeLists.txt
View file @
af18be14
...
@@ -25,7 +25,6 @@ set (SRC
...
@@ -25,7 +25,6 @@ set (SRC
autodiff.cpp
autodiff.cpp
build_graph.cpp
build_graph.cpp
eigen.cpp
eigen.cpp
execute.cpp
input_output_assign.cpp
input_output_assign.cpp
main.cpp
main.cpp
op.cpp
op.cpp
...
@@ -42,12 +41,32 @@ set (SRC
...
@@ -42,12 +41,32 @@ set (SRC
uuid.cpp
uuid.cpp
)
)
#================================================================================================
# To auto generate a suite of unit tests for a backend add a line like this
# set(BACKEND_NAMES ${BACKEND_NAMES} "BACKEND_NAME_GOES_HERE")
# and replace BACKEND_NAME_GOES_HERE with your backend name.
# The code for the unit test suite is in test/backend_test.in.cpp
#================================================================================================
set
(
BACKEND_NAMES
${
BACKEND_NAMES
}
"NGVM"
)
if
(
MKLDNN_INCLUDE_DIR
)
if
(
MKLDNN_INCLUDE_DIR
)
include_directories
(
SYSTEM
${
MKLDNN_INCLUDE_DIR
}
)
include_directories
(
SYSTEM
${
MKLDNN_INCLUDE_DIR
}
)
link_directories
(
${
MKLDNN_LIB_DIR
}
)
link_directories
(
${
MKLDNN_LIB_DIR
}
)
set
(
SRC
${
SRC
}
mkldnn.cpp
)
set
(
SRC
${
SRC
}
mkldnn.cpp
)
endif
()
endif
()
if
(
LLVM_INCLUDE_DIR
)
include_directories
(
SYSTEM
${
LLVM_INCLUDE_DIR
}
)
set
(
SRC
${
SRC
}
codegen.cpp
)
set
(
BACKEND_NAMES
${
BACKEND_NAMES
}
"CPU"
)
endif
()
foreach
(
BACKEND_NAME
${
BACKEND_NAMES
}
)
configure_file
(
backend_test.in.cpp backend_test_
${
BACKEND_NAME
}
.cpp
)
set
(
SRC
${
SRC
}
${
CMAKE_CURRENT_BINARY_DIR
}
/backend_test_
${
BACKEND_NAME
}
.cpp
)
message
(
STATUS
"Adding unit test for backend
${
BACKEND_NAME
}
"
)
endforeach
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DCURDIR=
\\\"
${
CMAKE_CURRENT_SOURCE_DIR
}
\\\"
"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DCURDIR=
\\\"
${
CMAKE_CURRENT_SOURCE_DIR
}
\\\"
"
)
...
...
test/
execute
.cpp
→
test/
backend_test.in
.cpp
View file @
af18be14
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
using
namespace
std
;
using
namespace
std
;
using
namespace
ngraph
;
using
namespace
ngraph
;
TEST
(
execute
,
abc
)
TEST
(
$
{
BACKEND_NAME
}
,
abc
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -30,7 +30,7 @@ TEST(execute, abc)
...
@@ -30,7 +30,7 @@ TEST(execute, abc)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
((
A
+
B
)
*
C
,
rt
,
op
::
Parameters
{
A
,
B
,
C
});
auto
f
=
make_shared
<
Function
>
((
A
+
B
)
*
C
,
rt
,
op
::
Parameters
{
A
,
B
,
C
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -54,7 +54,7 @@ TEST(execute, abc)
...
@@ -54,7 +54,7 @@ TEST(execute, abc)
ASSERT_EQ
(
*
result
,
(
runtime
::
NDArray
<
float
,
2
>
({{
50
,
72
},
{
98
,
128
}})));
ASSERT_EQ
(
*
result
,
(
runtime
::
NDArray
<
float
,
2
>
({{
50
,
72
},
{
98
,
128
}})));
}
}
TEST
(
execute
,
abc_int64
)
TEST
(
$
{
BACKEND_NAME
}
,
abc_int64
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Int64
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Int64
::
element_type
(),
shape
);
...
@@ -63,7 +63,7 @@ TEST(execute, abc_int64)
...
@@ -63,7 +63,7 @@ TEST(execute, abc_int64)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Int64
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Int64
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
((
A
+
B
)
*
C
,
rt
,
op
::
Parameters
{
A
,
B
,
C
});
auto
f
=
make_shared
<
Function
>
((
A
+
B
)
*
C
,
rt
,
op
::
Parameters
{
A
,
B
,
C
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -88,7 +88,7 @@ TEST(execute, abc_int64)
...
@@ -88,7 +88,7 @@ TEST(execute, abc_int64)
}
}
// Same as abc, but using tuples for input and output
// Same as abc, but using tuples for input and output
TEST
(
execute
,
abc_tuple
)
TEST
(
$
{
BACKEND_NAME
}
,
abc_tuple
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
...
@@ -103,7 +103,7 @@ TEST(execute, abc_tuple)
...
@@ -103,7 +103,7 @@ TEST(execute, abc_tuple)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Tuple
>
(
Nodes
{(
A
+
B
)
*
C
}),
tensor_view_type
,
op
::
Parameters
{
ABC
});
make_shared
<
op
::
Tuple
>
(
Nodes
{(
A
+
B
)
*
C
}),
tensor_view_type
,
op
::
Parameters
{
ABC
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -132,7 +132,7 @@ TEST(execute, abc_tuple)
...
@@ -132,7 +132,7 @@ TEST(execute, abc_tuple)
}
}
// Same as abc, but using tuples for input and output
// Same as abc, but using tuples for input and output
TEST
(
execute
,
abc_tuple_int64
)
TEST
(
$
{
BACKEND_NAME
}
,
abc_tuple_int64
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
...
@@ -147,7 +147,7 @@ TEST(execute, abc_tuple_int64)
...
@@ -147,7 +147,7 @@ TEST(execute, abc_tuple_int64)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Tuple
>
(
Nodes
{(
A
+
B
)
*
C
}),
tensor_view_type
,
op
::
Parameters
{
ABC
});
make_shared
<
op
::
Tuple
>
(
Nodes
{(
A
+
B
)
*
C
}),
tensor_view_type
,
op
::
Parameters
{
ABC
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -176,7 +176,7 @@ TEST(execute, abc_tuple_int64)
...
@@ -176,7 +176,7 @@ TEST(execute, abc_tuple_int64)
}
}
// Multiple retrive values
// Multiple retrive values
TEST
(
execute
,
tuple_result
)
TEST
(
$
{
BACKEND_NAME
}
,
tuple_result
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -191,7 +191,7 @@ TEST(execute, tuple_result)
...
@@ -191,7 +191,7 @@ TEST(execute, tuple_result)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Tuple
>
(
Nodes
{
A_add_B
,
A_add_B_mul_C
}),
rt
,
op
::
Parameters
{
A
,
B
,
C
});
make_shared
<
op
::
Tuple
>
(
Nodes
{
A_add_B
,
A_add_B_mul_C
}),
rt
,
op
::
Parameters
{
A
,
B
,
C
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -213,14 +213,14 @@ TEST(execute, tuple_result)
...
@@ -213,14 +213,14 @@ TEST(execute, tuple_result)
ASSERT_EQ
((
vector
<
float
>
{
54
,
80
,
110
,
144
}),
r1
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
54
,
80
,
110
,
144
}),
r1
->
get_vector
());
}
}
TEST
(
execute
,
abs
)
TEST
(
$
{
BACKEND_NAME
}
,
abs
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Abs
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Abs
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -234,7 +234,7 @@ TEST(execute, abs)
...
@@ -234,7 +234,7 @@ TEST(execute, abs)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
0
,
4.8
f
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
0
,
4.8
f
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
concat_matrix_colwise
)
TEST
(
$
{
BACKEND_NAME
}
,
concat_matrix_colwise
)
{
{
auto
shape_a
=
Shape
{
2
,
2
};
auto
shape_a
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -247,7 +247,7 @@ TEST(execute, concat_matrix_colwise)
...
@@ -247,7 +247,7 @@ TEST(execute, concat_matrix_colwise)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Concat
>
(
Nodes
{
A
,
B
,
C
},
1
),
rt
,
op
::
Parameters
{
A
,
B
,
C
});
make_shared
<
op
::
Concat
>
(
Nodes
{
A
,
B
,
C
},
1
),
rt
,
op
::
Parameters
{
A
,
B
,
C
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -266,7 +266,7 @@ TEST(execute, concat_matrix_colwise)
...
@@ -266,7 +266,7 @@ TEST(execute, concat_matrix_colwise)
result
->
get_vector
());
result
->
get_vector
());
}
}
TEST
(
execute
,
concat_matrix_rowwise
)
TEST
(
$
{
BACKEND_NAME
}
,
concat_matrix_rowwise
)
{
{
auto
shape_a
=
Shape
{
2
,
2
};
auto
shape_a
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -279,7 +279,7 @@ TEST(execute, concat_matrix_rowwise)
...
@@ -279,7 +279,7 @@ TEST(execute, concat_matrix_rowwise)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Concat
>
(
Nodes
{
A
,
B
,
C
},
0
),
rt
,
op
::
Parameters
{
A
,
B
,
C
});
make_shared
<
op
::
Concat
>
(
Nodes
{
A
,
B
,
C
},
0
),
rt
,
op
::
Parameters
{
A
,
B
,
C
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -298,7 +298,7 @@ TEST(execute, concat_matrix_rowwise)
...
@@ -298,7 +298,7 @@ TEST(execute, concat_matrix_rowwise)
result
->
get_vector
());
result
->
get_vector
());
}
}
TEST
(
execute
,
concat_matrix_int64
)
TEST
(
$
{
BACKEND_NAME
}
,
concat_matrix_int64
)
{
{
auto
shape_a
=
Shape
{
2
,
2
};
auto
shape_a
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Int64
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Int64
::
element_type
(),
shape_a
);
...
@@ -311,7 +311,7 @@ TEST(execute, concat_matrix_int64)
...
@@ -311,7 +311,7 @@ TEST(execute, concat_matrix_int64)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Concat
>
(
Nodes
{
A
,
B
,
C
},
0
),
rt
,
op
::
Parameters
{
A
,
B
,
C
});
make_shared
<
op
::
Concat
>
(
Nodes
{
A
,
B
,
C
},
0
),
rt
,
op
::
Parameters
{
A
,
B
,
C
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -330,7 +330,7 @@ TEST(execute, concat_matrix_int64)
...
@@ -330,7 +330,7 @@ TEST(execute, concat_matrix_int64)
result
->
get_vector
());
result
->
get_vector
());
}
}
TEST
(
execute
,
concat_vector
)
TEST
(
$
{
BACKEND_NAME
}
,
concat_vector
)
{
{
auto
shape_a
=
Shape
{
4
};
auto
shape_a
=
Shape
{
4
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -343,7 +343,7 @@ TEST(execute, concat_vector)
...
@@ -343,7 +343,7 @@ TEST(execute, concat_vector)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Concat
>
(
Nodes
{
A
,
B
,
C
},
0
),
rt
,
op
::
Parameters
{
A
,
B
,
C
});
make_shared
<
op
::
Concat
>
(
Nodes
{
A
,
B
,
C
},
0
),
rt
,
op
::
Parameters
{
A
,
B
,
C
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -361,9 +361,9 @@ TEST(execute, concat_vector)
...
@@ -361,9 +361,9 @@ TEST(execute, concat_vector)
ASSERT_EQ
((
vector
<
float
>
{
2
,
4
,
8
,
16
,
1
,
2
,
4
,
8
,
16
,
32
,
18
,
19
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
2
,
4
,
8
,
16
,
1
,
2
,
4
,
8
,
16
,
32
,
18
,
19
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
divide
)
TEST
(
$
{
BACKEND_NAME
}
,
divide
)
{
{
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
...
@@ -391,7 +391,7 @@ TEST(execute, divide)
...
@@ -391,7 +391,7 @@ TEST(execute, divide)
ASSERT_EQ
((
vector
<
float
>
{
2
,
2
,
2
,
2
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
2
,
2
,
2
,
2
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
equal
)
TEST
(
$
{
BACKEND_NAME
}
,
equal
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -399,7 +399,7 @@ TEST(execute, equal)
...
@@ -399,7 +399,7 @@ TEST(execute, equal)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Equal
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Equal
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -415,7 +415,7 @@ TEST(execute, equal)
...
@@ -415,7 +415,7 @@ TEST(execute, equal)
ASSERT_EQ
((
vector
<
char
>
{
1
,
1
,
0
,
0
,
0
,
1
,
1
,
0
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
char
>
{
1
,
1
,
0
,
0
,
0
,
1
,
1
,
0
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot_0_0
)
TEST
(
$
{
BACKEND_NAME
}
,
dot_0_0
)
{
{
auto
shape
=
Shape
{
0
};
auto
shape
=
Shape
{
0
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -424,7 +424,7 @@ TEST(execute, dot_0_0)
...
@@ -424,7 +424,7 @@ TEST(execute, dot_0_0)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -440,13 +440,13 @@ TEST(execute, dot_0_0)
...
@@ -440,13 +440,13 @@ TEST(execute, dot_0_0)
ASSERT_EQ
((
vector
<
float
>
{
0
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
0
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot_matrix_2x0_0x2
)
TEST
(
$
{
BACKEND_NAME
}
,
dot_matrix_2x0_0x2
)
{
{
auto
shape_a
=
Shape
{
2
,
0
};
auto
shape_a
=
Shape
{
2
,
0
};
auto
shape_b
=
Shape
{
0
,
2
};
auto
shape_b
=
Shape
{
0
,
2
};
auto
shape_r
=
Shape
{
2
,
2
};
auto
shape_r
=
Shape
{
2
,
2
};
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
make_external
=
[
&
]()
{
auto
make_external
=
[
&
]()
{
...
@@ -472,7 +472,7 @@ TEST(execute, dot_matrix_2x0_0x2)
...
@@ -472,7 +472,7 @@ TEST(execute, dot_matrix_2x0_0x2)
ASSERT_EQ
((
vector
<
float
>
{
0
,
0
,
0
,
0
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
0
,
0
,
0
,
0
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot_matrix_0x2_2x0
)
TEST
(
$
{
BACKEND_NAME
}
,
dot_matrix_0x2_2x0
)
{
{
auto
shape_a
=
Shape
{
0
,
2
};
auto
shape_a
=
Shape
{
0
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -482,7 +482,7 @@ TEST(execute, dot_matrix_0x2_2x0)
...
@@ -482,7 +482,7 @@ TEST(execute, dot_matrix_0x2_2x0)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -498,7 +498,7 @@ TEST(execute, dot_matrix_0x2_2x0)
...
@@ -498,7 +498,7 @@ TEST(execute, dot_matrix_0x2_2x0)
ASSERT_EQ
((
vector
<
float
>
{}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot_matrix_3x2_2x0
)
TEST
(
$
{
BACKEND_NAME
}
,
dot_matrix_3x2_2x0
)
{
{
auto
shape_a
=
Shape
{
3
,
2
};
auto
shape_a
=
Shape
{
3
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -508,7 +508,7 @@ TEST(execute, dot_matrix_3x2_2x0)
...
@@ -508,7 +508,7 @@ TEST(execute, dot_matrix_3x2_2x0)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -524,7 +524,7 @@ TEST(execute, dot_matrix_3x2_2x0)
...
@@ -524,7 +524,7 @@ TEST(execute, dot_matrix_3x2_2x0)
ASSERT_EQ
((
vector
<
float
>
{}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot_scalar_0x2
)
TEST
(
$
{
BACKEND_NAME
}
,
dot_scalar_0x2
)
{
{
auto
shape_a
=
Shape
{};
auto
shape_a
=
Shape
{};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -534,7 +534,7 @@ TEST(execute, dot_scalar_0x2)
...
@@ -534,7 +534,7 @@ TEST(execute, dot_scalar_0x2)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -550,7 +550,7 @@ TEST(execute, dot_scalar_0x2)
...
@@ -550,7 +550,7 @@ TEST(execute, dot_scalar_0x2)
ASSERT_EQ
((
vector
<
float
>
{}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot_2x0_0
)
TEST
(
$
{
BACKEND_NAME
}
,
dot_2x0_0
)
{
{
auto
shape_a
=
Shape
{
2
,
0
};
auto
shape_a
=
Shape
{
2
,
0
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -560,7 +560,7 @@ TEST(execute, dot_2x0_0)
...
@@ -560,7 +560,7 @@ TEST(execute, dot_2x0_0)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -576,7 +576,7 @@ TEST(execute, dot_2x0_0)
...
@@ -576,7 +576,7 @@ TEST(execute, dot_2x0_0)
ASSERT_EQ
((
vector
<
float
>
{
0
,
0
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
0
,
0
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot1d
)
TEST
(
$
{
BACKEND_NAME
}
,
dot1d
)
{
{
auto
shape
=
Shape
{
4
};
auto
shape
=
Shape
{
4
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -585,7 +585,7 @@ TEST(execute, dot1d)
...
@@ -585,7 +585,7 @@ TEST(execute, dot1d)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -601,7 +601,7 @@ TEST(execute, dot1d)
...
@@ -601,7 +601,7 @@ TEST(execute, dot1d)
ASSERT_EQ
((
vector
<
float
>
{
170
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
170
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot2d
)
TEST
(
$
{
BACKEND_NAME
}
,
dot2d
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -610,7 +610,7 @@ TEST(execute, dot2d)
...
@@ -610,7 +610,7 @@ TEST(execute, dot2d)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -626,7 +626,7 @@ TEST(execute, dot2d)
...
@@ -626,7 +626,7 @@ TEST(execute, dot2d)
ASSERT_EQ
((
vector
<
float
>
{
19
,
22
,
43
,
50
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
19
,
22
,
43
,
50
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot_scalar_tensor_arg0
)
TEST
(
$
{
BACKEND_NAME
}
,
dot_scalar_tensor_arg0
)
{
{
auto
shape_a
=
Shape
{};
auto
shape_a
=
Shape
{};
auto
shape_b
=
Shape
{
2
,
2
,
2
};
auto
shape_b
=
Shape
{
2
,
2
,
2
};
...
@@ -635,7 +635,7 @@ TEST(execute, dot_scalar_tensor_arg0)
...
@@ -635,7 +635,7 @@ TEST(execute, dot_scalar_tensor_arg0)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_b
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_b
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -651,7 +651,7 @@ TEST(execute, dot_scalar_tensor_arg0)
...
@@ -651,7 +651,7 @@ TEST(execute, dot_scalar_tensor_arg0)
ASSERT_EQ
((
vector
<
float
>
{
6
,
12
,
18
,
24
,
30
,
36
,
42
,
48
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
6
,
12
,
18
,
24
,
30
,
36
,
42
,
48
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot_scalar_tensor_arg1
)
TEST
(
$
{
BACKEND_NAME
}
,
dot_scalar_tensor_arg1
)
{
{
auto
shape_a
=
Shape
{
2
,
2
,
2
};
auto
shape_a
=
Shape
{
2
,
2
,
2
};
auto
shape_b
=
Shape
{};
auto
shape_b
=
Shape
{};
...
@@ -660,7 +660,7 @@ TEST(execute, dot_scalar_tensor_arg1)
...
@@ -660,7 +660,7 @@ TEST(execute, dot_scalar_tensor_arg1)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -676,7 +676,7 @@ TEST(execute, dot_scalar_tensor_arg1)
...
@@ -676,7 +676,7 @@ TEST(execute, dot_scalar_tensor_arg1)
ASSERT_EQ
((
vector
<
float
>
{
6
,
12
,
18
,
24
,
30
,
36
,
42
,
48
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
6
,
12
,
18
,
24
,
30
,
36
,
42
,
48
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot_scalar_scalar
)
TEST
(
$
{
BACKEND_NAME
}
,
dot_scalar_scalar
)
{
{
auto
shape
=
Shape
{};
auto
shape
=
Shape
{};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -684,7 +684,7 @@ TEST(execute, dot_scalar_scalar)
...
@@ -684,7 +684,7 @@ TEST(execute, dot_scalar_scalar)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -700,7 +700,7 @@ TEST(execute, dot_scalar_scalar)
...
@@ -700,7 +700,7 @@ TEST(execute, dot_scalar_scalar)
ASSERT_EQ
((
vector
<
float
>
{
48
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
48
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot_matrix_vector
)
TEST
(
$
{
BACKEND_NAME
}
,
dot_matrix_vector
)
{
{
auto
shape_a
=
Shape
{
4
,
4
};
auto
shape_a
=
Shape
{
4
,
4
};
auto
shape_b
=
Shape
{
4
};
auto
shape_b
=
Shape
{
4
};
...
@@ -710,7 +710,7 @@ TEST(execute, dot_matrix_vector)
...
@@ -710,7 +710,7 @@ TEST(execute, dot_matrix_vector)
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
shape_r
=
Shape
{
4
};
auto
shape_r
=
Shape
{
4
};
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -726,7 +726,7 @@ TEST(execute, dot_matrix_vector)
...
@@ -726,7 +726,7 @@ TEST(execute, dot_matrix_vector)
ASSERT_EQ
((
vector
<
float
>
{
190
,
486
,
782
,
1078
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
190
,
486
,
782
,
1078
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
dot_matrix_vector_int64
)
TEST
(
$
{
BACKEND_NAME
}
,
dot_matrix_vector_int64
)
{
{
auto
shape_a
=
Shape
{
4
,
4
};
auto
shape_a
=
Shape
{
4
,
4
};
auto
shape_b
=
Shape
{
4
};
auto
shape_b
=
Shape
{
4
};
...
@@ -736,7 +736,7 @@ TEST(execute, dot_matrix_vector_int64)
...
@@ -736,7 +736,7 @@ TEST(execute, dot_matrix_vector_int64)
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
shape_r
=
Shape
{
4
};
auto
shape_r
=
Shape
{
4
};
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -752,7 +752,7 @@ TEST(execute, dot_matrix_vector_int64)
...
@@ -752,7 +752,7 @@ TEST(execute, dot_matrix_vector_int64)
ASSERT_EQ
((
vector
<
element
::
Int64
::
type
>
{
190
,
486
,
782
,
1078
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
element
::
Int64
::
type
>
{
190
,
486
,
782
,
1078
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
greater
)
TEST
(
$
{
BACKEND_NAME
}
,
greater
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -760,7 +760,7 @@ TEST(execute, greater)
...
@@ -760,7 +760,7 @@ TEST(execute, greater)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Greater
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Greater
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -776,7 +776,7 @@ TEST(execute, greater)
...
@@ -776,7 +776,7 @@ TEST(execute, greater)
ASSERT_EQ
((
vector
<
char
>
{
0
,
1
,
0
,
1
,
0
,
1
,
1
,
0
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
char
>
{
0
,
1
,
0
,
1
,
0
,
1
,
1
,
0
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
greatereq
)
TEST
(
$
{
BACKEND_NAME
}
,
greatereq
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -784,7 +784,7 @@ TEST(execute, greatereq)
...
@@ -784,7 +784,7 @@ TEST(execute, greatereq)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
GreaterEq
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
GreaterEq
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -800,7 +800,7 @@ TEST(execute, greatereq)
...
@@ -800,7 +800,7 @@ TEST(execute, greatereq)
ASSERT_EQ
((
vector
<
char
>
{
1
,
1
,
1
,
1
,
0
,
1
,
1
,
0
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
char
>
{
1
,
1
,
1
,
1
,
0
,
1
,
1
,
0
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
less
)
TEST
(
$
{
BACKEND_NAME
}
,
less
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -808,7 +808,7 @@ TEST(execute, less)
...
@@ -808,7 +808,7 @@ TEST(execute, less)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Less
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Less
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -824,7 +824,7 @@ TEST(execute, less)
...
@@ -824,7 +824,7 @@ TEST(execute, less)
ASSERT_EQ
((
vector
<
char
>
{
0
,
0
,
1
,
0
,
1
,
0
,
0
,
1
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
char
>
{
0
,
0
,
1
,
0
,
1
,
0
,
0
,
1
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
lesseq
)
TEST
(
$
{
BACKEND_NAME
}
,
lesseq
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -832,7 +832,7 @@ TEST(execute, lesseq)
...
@@ -832,7 +832,7 @@ TEST(execute, lesseq)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
LessEq
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
LessEq
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -848,7 +848,7 @@ TEST(execute, lesseq)
...
@@ -848,7 +848,7 @@ TEST(execute, lesseq)
ASSERT_EQ
((
vector
<
char
>
{
1
,
0
,
1
,
0
,
1
,
1
,
0
,
1
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
char
>
{
1
,
0
,
1
,
0
,
1
,
1
,
0
,
1
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
lesseq_bool
)
TEST
(
$
{
BACKEND_NAME
}
,
lesseq_bool
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Bool
::
element_type
(),
shape
);
...
@@ -856,7 +856,7 @@ TEST(execute, lesseq_bool)
...
@@ -856,7 +856,7 @@ TEST(execute, lesseq_bool)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
LessEq
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
LessEq
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -872,14 +872,14 @@ TEST(execute, lesseq_bool)
...
@@ -872,14 +872,14 @@ TEST(execute, lesseq_bool)
ASSERT_EQ
((
vector
<
char
>
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
char
>
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
log
)
TEST
(
$
{
BACKEND_NAME
}
,
log
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Log
>
(
A
),
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Log
>
(
A
),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -898,7 +898,7 @@ TEST(execute, log)
...
@@ -898,7 +898,7 @@ TEST(execute, log)
ASSERT_EQ
(
loga
,
result
->
get_vector
());
ASSERT_EQ
(
loga
,
result
->
get_vector
());
}
}
TEST
(
execute
,
maximum
)
TEST
(
$
{
BACKEND_NAME
}
,
maximum
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -906,7 +906,7 @@ TEST(execute, maximum)
...
@@ -906,7 +906,7 @@ TEST(execute, maximum)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Maximum
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Maximum
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -922,7 +922,7 @@ TEST(execute, maximum)
...
@@ -922,7 +922,7 @@ TEST(execute, maximum)
ASSERT_EQ
((
vector
<
float
>
{
1
,
8
,
4
,
17
,
0
,
0.5
,
2
,
1.5
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
8
,
4
,
17
,
0
,
0.5
,
2
,
1.5
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
minimum
)
TEST
(
$
{
BACKEND_NAME
}
,
minimum
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -930,7 +930,7 @@ TEST(execute, minimum)
...
@@ -930,7 +930,7 @@ TEST(execute, minimum)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Minimum
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Minimum
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -946,14 +946,14 @@ TEST(execute, minimum)
...
@@ -946,14 +946,14 @@ TEST(execute, minimum)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
-
8
,
8
,
-
.5
,
0
,
1
,
1
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
-
8
,
8
,
-
.5
,
0
,
1
,
1
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
negative
)
TEST
(
$
{
BACKEND_NAME
}
,
negative
)
{
{
auto
shape
=
Shape
{
2
,
3
};
auto
shape
=
Shape
{
2
,
3
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Negative
>
(
A
),
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Negative
>
(
A
),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -967,7 +967,7 @@ TEST(execute, negative)
...
@@ -967,7 +967,7 @@ TEST(execute, negative)
ASSERT_EQ
((
vector
<
float
>
{
-
1
,
2
,
0
,
4.8
f
,
-
8.6
f
,
8.6
f
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
-
1
,
2
,
0
,
4.8
f
,
-
8.6
f
,
8.6
f
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
notequal
)
TEST
(
$
{
BACKEND_NAME
}
,
notequal
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -975,7 +975,7 @@ TEST(execute, notequal)
...
@@ -975,7 +975,7 @@ TEST(execute, notequal)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
NotEqual
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
NotEqual
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -991,7 +991,7 @@ TEST(execute, notequal)
...
@@ -991,7 +991,7 @@ TEST(execute, notequal)
ASSERT_EQ
((
vector
<
char
>
{
0
,
0
,
1
,
1
,
1
,
0
,
0
,
1
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
char
>
{
0
,
0
,
1
,
1
,
1
,
0
,
0
,
1
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
select
)
TEST
(
$
{
BACKEND_NAME
}
,
select
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Bool
::
element_type
(),
shape
);
...
@@ -1000,7 +1000,7 @@ TEST(execute, select)
...
@@ -1000,7 +1000,7 @@ TEST(execute, select)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Select
>
(
A
,
B
,
C
),
rt
,
op
::
Parameters
{
A
,
B
,
C
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Select
>
(
A
,
B
,
C
),
rt
,
op
::
Parameters
{
A
,
B
,
C
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1018,7 +1018,7 @@ TEST(execute, select)
...
@@ -1018,7 +1018,7 @@ TEST(execute, select)
ASSERT_EQ
((
vector
<
float
>
{
11
,
2
,
3
,
14
,
15
,
6
,
17
,
8
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
11
,
2
,
3
,
14
,
15
,
6
,
17
,
8
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
subtract
)
TEST
(
$
{
BACKEND_NAME
}
,
subtract
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -1026,7 +1026,7 @@ TEST(execute, subtract)
...
@@ -1026,7 +1026,7 @@ TEST(execute, subtract)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Subtract
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Subtract
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1042,7 +1042,7 @@ TEST(execute, subtract)
...
@@ -1042,7 +1042,7 @@ TEST(execute, subtract)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
4
,
8
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
4
,
8
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
scalar_constant
)
TEST
(
$
{
BACKEND_NAME
}
,
scalar_constant
)
{
{
auto
shape
=
Shape
{};
auto
shape
=
Shape
{};
auto
t
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape
);
auto
t
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape
);
...
@@ -1051,7 +1051,7 @@ TEST(execute, scalar_constant)
...
@@ -1051,7 +1051,7 @@ TEST(execute, scalar_constant)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
A
,
rt
,
op
::
Parameters
{});
auto
f
=
make_shared
<
Function
>
(
A
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1063,7 +1063,7 @@ TEST(execute, scalar_constant)
...
@@ -1063,7 +1063,7 @@ TEST(execute, scalar_constant)
ASSERT_EQ
((
vector
<
float
>
{
-
3.0
f
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
-
3.0
f
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
tensor_constant
)
TEST
(
$
{
BACKEND_NAME
}
,
tensor_constant
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
t
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape
);
auto
t
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape
);
...
@@ -1072,7 +1072,7 @@ TEST(execute, tensor_constant)
...
@@ -1072,7 +1072,7 @@ TEST(execute, tensor_constant)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
A
,
rt
,
op
::
Parameters
{});
auto
f
=
make_shared
<
Function
>
(
A
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1084,7 +1084,7 @@ TEST(execute, tensor_constant)
...
@@ -1084,7 +1084,7 @@ TEST(execute, tensor_constant)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
tensor_constant_with_op
)
TEST
(
$
{
BACKEND_NAME
}
,
tensor_constant_with_op
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
t
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape
);
auto
t
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape
);
...
@@ -1093,7 +1093,7 @@ TEST(execute, tensor_constant_with_op)
...
@@ -1093,7 +1093,7 @@ TEST(execute, tensor_constant_with_op)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Abs
>
(
A
),
rt
,
op
::
Parameters
{});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Abs
>
(
A
),
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1105,7 +1105,7 @@ TEST(execute, tensor_constant_with_op)
...
@@ -1105,7 +1105,7 @@ TEST(execute, tensor_constant_with_op)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
function_call
)
TEST
(
$
{
BACKEND_NAME
}
,
function_call
)
{
{
// First create "f(A,B,C) = (A+B)*C".
// First create "f(A,B,C) = (A+B)*C".
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
...
@@ -1126,7 +1126,7 @@ TEST(execute, function_call)
...
@@ -1126,7 +1126,7 @@ TEST(execute, function_call)
op
::
Parameters
{
X
,
Y
,
Z
});
op
::
Parameters
{
X
,
Y
,
Z
});
// Now call g on some test vectors.
// Now call g on some test vectors.
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
g
);
auto
external
=
manager
->
compile
(
g
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1149,7 +1149,7 @@ TEST(execute, function_call)
...
@@ -1149,7 +1149,7 @@ TEST(execute, function_call)
ASSERT_EQ
((
vector
<
float
>
{
100
,
144
,
196
,
256
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
100
,
144
,
196
,
256
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
broadcast_scalar_vector
)
TEST
(
$
{
BACKEND_NAME
}
,
broadcast_scalar_vector
)
{
{
auto
shape_a
=
Shape
{};
auto
shape_a
=
Shape
{};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -1158,7 +1158,7 @@ TEST(execute, broadcast_scalar_vector)
...
@@ -1158,7 +1158,7 @@ TEST(execute, broadcast_scalar_vector)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Broadcast
>
(
A
,
shape_r
,
AxisSet
{
0
}),
rt
,
op
::
Parameters
{
A
});
make_shared
<
op
::
Broadcast
>
(
A
,
shape_r
,
AxisSet
{
0
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1172,7 +1172,7 @@ TEST(execute, broadcast_scalar_vector)
...
@@ -1172,7 +1172,7 @@ TEST(execute, broadcast_scalar_vector)
ASSERT_EQ
((
vector
<
float
>
{
6
,
6
,
6
,
6
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
6
,
6
,
6
,
6
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
broadcast_scalar_matrix
)
TEST
(
$
{
BACKEND_NAME
}
,
broadcast_scalar_matrix
)
{
{
auto
shape_a
=
Shape
{};
auto
shape_a
=
Shape
{};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -1181,7 +1181,7 @@ TEST(execute, broadcast_scalar_matrix)
...
@@ -1181,7 +1181,7 @@ TEST(execute, broadcast_scalar_matrix)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Broadcast
>
(
A
,
shape_r
,
AxisSet
{
0
,
1
}),
rt
,
op
::
Parameters
{
A
});
make_shared
<
op
::
Broadcast
>
(
A
,
shape_r
,
AxisSet
{
0
,
1
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1195,7 +1195,7 @@ TEST(execute, broadcast_scalar_matrix)
...
@@ -1195,7 +1195,7 @@ TEST(execute, broadcast_scalar_matrix)
ASSERT_EQ
((
vector
<
float
>
{
6
,
6
,
6
,
6
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
6
,
6
,
6
,
6
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
broadcast_scalar_tensor
)
TEST
(
$
{
BACKEND_NAME
}
,
broadcast_scalar_tensor
)
{
{
auto
shape_a
=
Shape
{};
auto
shape_a
=
Shape
{};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -1204,7 +1204,7 @@ TEST(execute, broadcast_scalar_tensor)
...
@@ -1204,7 +1204,7 @@ TEST(execute, broadcast_scalar_tensor)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Broadcast
>
(
A
,
shape_r
,
AxisSet
{
0
,
1
,
2
}),
rt
,
op
::
Parameters
{
A
});
make_shared
<
op
::
Broadcast
>
(
A
,
shape_r
,
AxisSet
{
0
,
1
,
2
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1218,7 +1218,7 @@ TEST(execute, broadcast_scalar_tensor)
...
@@ -1218,7 +1218,7 @@ TEST(execute, broadcast_scalar_tensor)
ASSERT_EQ
((
vector
<
float
>
{
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
broadcast_trivial
)
TEST
(
$
{
BACKEND_NAME
}
,
broadcast_trivial
)
{
{
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
shape
=
Shape
{
2
,
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -1226,7 +1226,7 @@ TEST(execute, broadcast_trivial)
...
@@ -1226,7 +1226,7 @@ TEST(execute, broadcast_trivial)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Broadcast
>
(
A
,
shape
,
AxisSet
{}),
rt
,
op
::
Parameters
{
A
});
make_shared
<
op
::
Broadcast
>
(
A
,
shape
,
AxisSet
{}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1240,7 +1240,7 @@ TEST(execute, broadcast_trivial)
...
@@ -1240,7 +1240,7 @@ TEST(execute, broadcast_trivial)
ASSERT_EQ
((
vector
<
float
>
{
2
,
4
,
6
,
8
,
16
,
32
,
64
,
128
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
2
,
4
,
6
,
8
,
16
,
32
,
64
,
128
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
broadcast_vector_colwise
)
TEST
(
$
{
BACKEND_NAME
}
,
broadcast_vector_colwise
)
{
{
auto
shape_a
=
Shape
{
3
};
auto
shape_a
=
Shape
{
3
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -1249,7 +1249,7 @@ TEST(execute, broadcast_vector_colwise)
...
@@ -1249,7 +1249,7 @@ TEST(execute, broadcast_vector_colwise)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Broadcast
>
(
A
,
shape_r
,
AxisSet
{
1
}),
rt
,
op
::
Parameters
{
A
});
make_shared
<
op
::
Broadcast
>
(
A
,
shape_r
,
AxisSet
{
1
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1263,7 +1263,7 @@ TEST(execute, broadcast_vector_colwise)
...
@@ -1263,7 +1263,7 @@ TEST(execute, broadcast_vector_colwise)
ASSERT_EQ
((
vector
<
float
>
{
1
,
1
,
1
,
1
,
2
,
2
,
2
,
2
,
3
,
3
,
3
,
3
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
1
,
1
,
1
,
2
,
2
,
2
,
2
,
3
,
3
,
3
,
3
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
broadcast_vector_rowwise
)
TEST
(
$
{
BACKEND_NAME
}
,
broadcast_vector_rowwise
)
{
{
auto
shape_a
=
Shape
{
4
};
auto
shape_a
=
Shape
{
4
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -1272,7 +1272,7 @@ TEST(execute, broadcast_vector_rowwise)
...
@@ -1272,7 +1272,7 @@ TEST(execute, broadcast_vector_rowwise)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Broadcast
>
(
A
,
shape_r
,
AxisSet
{
0
}),
rt
,
op
::
Parameters
{
A
});
make_shared
<
op
::
Broadcast
>
(
A
,
shape_r
,
AxisSet
{
0
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1286,7 +1286,7 @@ TEST(execute, broadcast_vector_rowwise)
...
@@ -1286,7 +1286,7 @@ TEST(execute, broadcast_vector_rowwise)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
1
,
2
,
3
,
4
,
1
,
2
,
3
,
4
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
1
,
2
,
3
,
4
,
1
,
2
,
3
,
4
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
broadcast_vector_rowwise_int64
)
TEST
(
$
{
BACKEND_NAME
}
,
broadcast_vector_rowwise_int64
)
{
{
auto
shape_a
=
Shape
{
4
};
auto
shape_a
=
Shape
{
4
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Int64
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Int64
::
element_type
(),
shape_a
);
...
@@ -1295,7 +1295,7 @@ TEST(execute, broadcast_vector_rowwise_int64)
...
@@ -1295,7 +1295,7 @@ TEST(execute, broadcast_vector_rowwise_int64)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Broadcast
>
(
A
,
shape_r
,
AxisSet
{
0
}),
rt
,
op
::
Parameters
{
A
});
make_shared
<
op
::
Broadcast
>
(
A
,
shape_r
,
AxisSet
{
0
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1310,7 +1310,7 @@ TEST(execute, broadcast_vector_rowwise_int64)
...
@@ -1310,7 +1310,7 @@ TEST(execute, broadcast_vector_rowwise_int64)
result
->
get_vector
());
result
->
get_vector
());
}
}
TEST
(
execute
,
convert_int32_float32
)
TEST
(
$
{
BACKEND_NAME
}
,
convert_int32_float32
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Int32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Int32
::
element_type
(),
shape
);
...
@@ -1318,7 +1318,7 @@ TEST(execute, convert_int32_float32)
...
@@ -1318,7 +1318,7 @@ TEST(execute, convert_int32_float32)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Convert
>
(
A
,
element
::
Float32
::
element_type
()),
rt
,
op
::
Parameters
{
A
});
make_shared
<
op
::
Convert
>
(
A
,
element
::
Float32
::
element_type
()),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1332,7 +1332,7 @@ TEST(execute, convert_int32_float32)
...
@@ -1332,7 +1332,7 @@ TEST(execute, convert_int32_float32)
ASSERT_EQ
((
vector
<
element
::
Float32
::
type
>
{
1
,
2
,
3
,
4
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
element
::
Float32
::
type
>
{
1
,
2
,
3
,
4
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
convert_int32_bool
)
TEST
(
$
{
BACKEND_NAME
}
,
convert_int32_bool
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Int32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Int32
::
element_type
(),
shape
);
...
@@ -1340,7 +1340,7 @@ TEST(execute, convert_int32_bool)
...
@@ -1340,7 +1340,7 @@ TEST(execute, convert_int32_bool)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Convert
>
(
A
,
element
::
Bool
::
element_type
()),
rt
,
op
::
Parameters
{
A
});
make_shared
<
op
::
Convert
>
(
A
,
element
::
Bool
::
element_type
()),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1354,7 +1354,7 @@ TEST(execute, convert_int32_bool)
...
@@ -1354,7 +1354,7 @@ TEST(execute, convert_int32_bool)
ASSERT_EQ
((
vector
<
element
::
Bool
::
type
>
{
1
,
2
,
3
,
4
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
element
::
Bool
::
type
>
{
1
,
2
,
3
,
4
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
convert_float32_bool
)
TEST
(
$
{
BACKEND_NAME
}
,
convert_float32_bool
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -1362,7 +1362,7 @@ TEST(execute, convert_float32_bool)
...
@@ -1362,7 +1362,7 @@ TEST(execute, convert_float32_bool)
auto
f
=
make_shared
<
Function
>
(
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Convert
>
(
A
,
element
::
Bool
::
element_type
()),
rt
,
op
::
Parameters
{
A
});
make_shared
<
op
::
Convert
>
(
A
,
element
::
Bool
::
element_type
()),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1377,7 +1377,7 @@ TEST(execute, convert_float32_bool)
...
@@ -1377,7 +1377,7 @@ TEST(execute, convert_float32_bool)
}
}
// Trivial case with no reduction axes.
// Trivial case with no reduction axes.
TEST
(
execute
,
reduce_trivial
)
TEST
(
$
{
BACKEND_NAME
}
,
reduce_trivial
)
{
{
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
...
@@ -1393,7 +1393,7 @@ TEST(execute, reduce_trivial)
...
@@ -1393,7 +1393,7 @@ TEST(execute, reduce_trivial)
auto
g
=
make_shared
<
Function
>
(
auto
g
=
make_shared
<
Function
>
(
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
g
);
auto
external
=
manager
->
compile
(
g
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1409,7 +1409,7 @@ TEST(execute, reduce_trivial)
...
@@ -1409,7 +1409,7 @@ TEST(execute, reduce_trivial)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
reduce_to_scalar
)
TEST
(
$
{
BACKEND_NAME
}
,
reduce_to_scalar
)
{
{
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
...
@@ -1425,7 +1425,7 @@ TEST(execute, reduce_to_scalar)
...
@@ -1425,7 +1425,7 @@ TEST(execute, reduce_to_scalar)
auto
g
=
make_shared
<
Function
>
(
auto
g
=
make_shared
<
Function
>
(
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
0
,
1
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
0
,
1
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
g
);
auto
external
=
manager
->
compile
(
g
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1446,7 +1446,7 @@ TEST(execute, reduce_to_scalar)
...
@@ -1446,7 +1446,7 @@ TEST(execute, reduce_to_scalar)
ASSERT_EQ
((
vector
<
float
>
{
0
}),
b
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
0
}),
b
->
get_vector
());
}
}
TEST
(
execute
,
reduce_matrix_columns
)
TEST
(
$
{
BACKEND_NAME
}
,
reduce_matrix_columns
)
{
{
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
...
@@ -1463,7 +1463,7 @@ TEST(execute, reduce_matrix_columns)
...
@@ -1463,7 +1463,7 @@ TEST(execute, reduce_matrix_columns)
auto
g
=
make_shared
<
Function
>
(
auto
g
=
make_shared
<
Function
>
(
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
0
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
0
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
g
);
auto
external
=
manager
->
compile
(
g
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1484,7 +1484,7 @@ TEST(execute, reduce_matrix_columns)
...
@@ -1484,7 +1484,7 @@ TEST(execute, reduce_matrix_columns)
ASSERT_EQ
((
vector
<
float
>
{
0
}),
b
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
0
}),
b
->
get_vector
());
}
}
TEST
(
execute
,
reduce_matrix_rows
)
TEST
(
$
{
BACKEND_NAME
}
,
reduce_matrix_rows
)
{
{
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
...
@@ -1501,7 +1501,7 @@ TEST(execute, reduce_matrix_rows)
...
@@ -1501,7 +1501,7 @@ TEST(execute, reduce_matrix_rows)
auto
g
=
make_shared
<
Function
>
(
auto
g
=
make_shared
<
Function
>
(
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
1
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
1
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
g
);
auto
external
=
manager
->
compile
(
g
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1522,7 +1522,7 @@ TEST(execute, reduce_matrix_rows)
...
@@ -1522,7 +1522,7 @@ TEST(execute, reduce_matrix_rows)
ASSERT_EQ
((
vector
<
float
>
{
0
}),
b
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
0
}),
b
->
get_vector
());
}
}
TEST
(
execute
,
reduce_matrix_rows_zero
)
TEST
(
$
{
BACKEND_NAME
}
,
reduce_matrix_rows_zero
)
{
{
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
...
@@ -1539,7 +1539,7 @@ TEST(execute, reduce_matrix_rows_zero)
...
@@ -1539,7 +1539,7 @@ TEST(execute, reduce_matrix_rows_zero)
auto
g
=
make_shared
<
Function
>
(
auto
g
=
make_shared
<
Function
>
(
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
1
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
1
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
g
);
auto
external
=
manager
->
compile
(
g
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1560,7 +1560,7 @@ TEST(execute, reduce_matrix_rows_zero)
...
@@ -1560,7 +1560,7 @@ TEST(execute, reduce_matrix_rows_zero)
ASSERT_EQ
((
vector
<
float
>
{
66
}),
b
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
66
}),
b
->
get_vector
());
}
}
TEST
(
execute
,
reduce_matrix_cols_zero
)
TEST
(
$
{
BACKEND_NAME
}
,
reduce_matrix_cols_zero
)
{
{
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
...
@@ -1577,7 +1577,7 @@ TEST(execute, reduce_matrix_cols_zero)
...
@@ -1577,7 +1577,7 @@ TEST(execute, reduce_matrix_cols_zero)
auto
g
=
make_shared
<
Function
>
(
auto
g
=
make_shared
<
Function
>
(
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
0
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
0
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
g
);
auto
external
=
manager
->
compile
(
g
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1598,7 +1598,7 @@ TEST(execute, reduce_matrix_cols_zero)
...
@@ -1598,7 +1598,7 @@ TEST(execute, reduce_matrix_cols_zero)
ASSERT_EQ
((
vector
<
float
>
{
77
}),
b
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
77
}),
b
->
get_vector
());
}
}
TEST
(
execute
,
reduce_vector_zero
)
TEST
(
$
{
BACKEND_NAME
}
,
reduce_vector_zero
)
{
{
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
...
@@ -1615,7 +1615,7 @@ TEST(execute, reduce_vector_zero)
...
@@ -1615,7 +1615,7 @@ TEST(execute, reduce_vector_zero)
auto
g
=
make_shared
<
Function
>
(
auto
g
=
make_shared
<
Function
>
(
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
0
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
0
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
g
);
auto
external
=
manager
->
compile
(
g
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1636,7 +1636,7 @@ TEST(execute, reduce_vector_zero)
...
@@ -1636,7 +1636,7 @@ TEST(execute, reduce_vector_zero)
ASSERT_EQ
((
vector
<
float
>
{
88
}),
b
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
88
}),
b
->
get_vector
());
}
}
TEST
(
execute
,
reduce_matrix_to_scalar_zero_by_zero
)
TEST
(
$
{
BACKEND_NAME
}
,
reduce_matrix_to_scalar_zero_by_zero
)
{
{
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
// First, the reduction function (f(x:float32[],y:float32[]) = x+y).
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
f_A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
Shape
{});
...
@@ -1653,7 +1653,7 @@ TEST(execute, reduce_matrix_to_scalar_zero_by_zero)
...
@@ -1653,7 +1653,7 @@ TEST(execute, reduce_matrix_to_scalar_zero_by_zero)
auto
g
=
make_shared
<
Function
>
(
auto
g
=
make_shared
<
Function
>
(
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
0
,
1
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
make_shared
<
op
::
Reduce
>
(
g_A
,
g_B
,
f
,
AxisSet
{
0
,
1
}),
g_rt
,
op
::
Parameters
{
g_A
,
g_B
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
g
);
auto
external
=
manager
->
compile
(
g
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1674,7 +1674,7 @@ TEST(execute, reduce_matrix_to_scalar_zero_by_zero)
...
@@ -1674,7 +1674,7 @@ TEST(execute, reduce_matrix_to_scalar_zero_by_zero)
ASSERT_EQ
((
vector
<
float
>
{
99
}),
b
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
99
}),
b
->
get_vector
());
}
}
TEST
(
execute
,
reshape_t2v_012
)
TEST
(
$
{
BACKEND_NAME
}
,
reshape_t2v_012
)
{
{
auto
shape_a
=
Shape
{
2
,
2
,
3
};
auto
shape_a
=
Shape
{
2
,
2
,
3
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -1684,7 +1684,7 @@ TEST(execute, reshape_t2v_012)
...
@@ -1684,7 +1684,7 @@ TEST(execute, reshape_t2v_012)
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
0
,
1
,
2
},
shape_r
);
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
0
,
1
,
2
},
shape_r
);
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1698,7 +1698,7 @@ TEST(execute, reshape_t2v_012)
...
@@ -1698,7 +1698,7 @@ TEST(execute, reshape_t2v_012)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
reshape_t2s_012
)
TEST
(
$
{
BACKEND_NAME
}
,
reshape_t2s_012
)
{
{
auto
shape_a
=
Shape
{
1
,
1
,
1
};
auto
shape_a
=
Shape
{
1
,
1
,
1
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -1708,7 +1708,7 @@ TEST(execute, reshape_t2s_012)
...
@@ -1708,7 +1708,7 @@ TEST(execute, reshape_t2s_012)
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
0
,
1
,
2
},
shape_r
);
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
0
,
1
,
2
},
shape_r
);
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1722,7 +1722,7 @@ TEST(execute, reshape_t2s_012)
...
@@ -1722,7 +1722,7 @@ TEST(execute, reshape_t2s_012)
ASSERT_EQ
((
vector
<
float
>
{
6
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
6
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
reshape_t2s_120
)
TEST
(
$
{
BACKEND_NAME
}
,
reshape_t2s_120
)
{
{
auto
shape_a
=
Shape
{
1
,
1
,
1
};
auto
shape_a
=
Shape
{
1
,
1
,
1
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -1732,7 +1732,7 @@ TEST(execute, reshape_t2s_120)
...
@@ -1732,7 +1732,7 @@ TEST(execute, reshape_t2s_120)
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
1
,
2
,
0
},
shape_r
);
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
1
,
2
,
0
},
shape_r
);
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1746,7 +1746,7 @@ TEST(execute, reshape_t2s_120)
...
@@ -1746,7 +1746,7 @@ TEST(execute, reshape_t2s_120)
ASSERT_EQ
((
vector
<
float
>
{
6
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
6
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
reshape_s2t
)
TEST
(
$
{
BACKEND_NAME
}
,
reshape_s2t
)
{
{
auto
shape_a
=
Shape
{};
auto
shape_a
=
Shape
{};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -1756,7 +1756,7 @@ TEST(execute, reshape_s2t)
...
@@ -1756,7 +1756,7 @@ TEST(execute, reshape_s2t)
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{},
shape_r
);
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{},
shape_r
);
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1770,7 +1770,7 @@ TEST(execute, reshape_s2t)
...
@@ -1770,7 +1770,7 @@ TEST(execute, reshape_s2t)
ASSERT_EQ
((
vector
<
float
>
{
42
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
42
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
reshape_v2m_col
)
TEST
(
$
{
BACKEND_NAME
}
,
reshape_v2m_col
)
{
{
auto
shape_a
=
Shape
{
3
};
auto
shape_a
=
Shape
{
3
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -1780,7 +1780,7 @@ TEST(execute, reshape_v2m_col)
...
@@ -1780,7 +1780,7 @@ TEST(execute, reshape_v2m_col)
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
0
},
shape_r
);
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
0
},
shape_r
);
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1794,7 +1794,7 @@ TEST(execute, reshape_v2m_col)
...
@@ -1794,7 +1794,7 @@ TEST(execute, reshape_v2m_col)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
reshape_v2m_row
)
TEST
(
$
{
BACKEND_NAME
}
,
reshape_v2m_row
)
{
{
auto
shape_a
=
Shape
{
3
};
auto
shape_a
=
Shape
{
3
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -1804,7 +1804,7 @@ TEST(execute, reshape_v2m_row)
...
@@ -1804,7 +1804,7 @@ TEST(execute, reshape_v2m_row)
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
0
},
shape_r
);
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
0
},
shape_r
);
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1818,7 +1818,7 @@ TEST(execute, reshape_v2m_row)
...
@@ -1818,7 +1818,7 @@ TEST(execute, reshape_v2m_row)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
reshape_v2t_middle
)
TEST
(
$
{
BACKEND_NAME
}
,
reshape_v2t_middle
)
{
{
auto
shape_a
=
Shape
{
3
};
auto
shape_a
=
Shape
{
3
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -1828,7 +1828,7 @@ TEST(execute, reshape_v2t_middle)
...
@@ -1828,7 +1828,7 @@ TEST(execute, reshape_v2t_middle)
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
0
},
shape_r
);
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
0
},
shape_r
);
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1842,7 +1842,7 @@ TEST(execute, reshape_v2t_middle)
...
@@ -1842,7 +1842,7 @@ TEST(execute, reshape_v2t_middle)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
reshape_m2m_same
)
TEST
(
$
{
BACKEND_NAME
}
,
reshape_m2m_same
)
{
{
auto
shape_a
=
Shape
{
3
,
3
};
auto
shape_a
=
Shape
{
3
,
3
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -1852,7 +1852,7 @@ TEST(execute, reshape_m2m_same)
...
@@ -1852,7 +1852,7 @@ TEST(execute, reshape_m2m_same)
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
0
,
1
},
shape_r
);
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
0
,
1
},
shape_r
);
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1866,7 +1866,7 @@ TEST(execute, reshape_m2m_same)
...
@@ -1866,7 +1866,7 @@ TEST(execute, reshape_m2m_same)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
reshape_m2m_transpose
)
TEST
(
$
{
BACKEND_NAME
}
,
reshape_m2m_transpose
)
{
{
auto
shape_a
=
Shape
{
3
,
3
};
auto
shape_a
=
Shape
{
3
,
3
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -1876,7 +1876,7 @@ TEST(execute, reshape_m2m_transpose)
...
@@ -1876,7 +1876,7 @@ TEST(execute, reshape_m2m_transpose)
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
1
,
0
},
shape_r
);
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
1
,
0
},
shape_r
);
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1890,7 +1890,7 @@ TEST(execute, reshape_m2m_transpose)
...
@@ -1890,7 +1890,7 @@ TEST(execute, reshape_m2m_transpose)
ASSERT_EQ
((
vector
<
float
>
{
1
,
4
,
7
,
2
,
5
,
8
,
3
,
6
,
9
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
4
,
7
,
2
,
5
,
8
,
3
,
6
,
9
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
reshape_m2m_dim_change_transpose
)
TEST
(
$
{
BACKEND_NAME
}
,
reshape_m2m_dim_change_transpose
)
{
{
auto
shape_a
=
Shape
{
3
,
2
};
auto
shape_a
=
Shape
{
3
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -1900,7 +1900,7 @@ TEST(execute, reshape_m2m_dim_change_transpose)
...
@@ -1900,7 +1900,7 @@ TEST(execute, reshape_m2m_dim_change_transpose)
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
1
,
0
},
shape_r
);
auto
r
=
make_shared
<
op
::
Reshape
>
(
A
,
AxisVector
{
1
,
0
},
shape_r
);
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1914,14 +1914,14 @@ TEST(execute, reshape_m2m_dim_change_transpose)
...
@@ -1914,14 +1914,14 @@ TEST(execute, reshape_m2m_dim_change_transpose)
ASSERT_EQ
((
vector
<
float
>
{
1
,
3
,
5
,
2
,
4
,
6
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
3
,
5
,
2
,
4
,
6
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
sin
)
TEST
(
$
{
BACKEND_NAME
}
,
sin
)
{
{
auto
shape
=
Shape
{
6
};
auto
shape
=
Shape
{
6
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sin
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sin
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1940,14 +1940,14 @@ TEST(execute, sin)
...
@@ -1940,14 +1940,14 @@ TEST(execute, sin)
ASSERT_EQ
(
input
,
result
->
get_vector
());
ASSERT_EQ
(
input
,
result
->
get_vector
());
}
}
TEST
(
execute
,
cos
)
TEST
(
$
{
BACKEND_NAME
}
,
cos
)
{
{
auto
shape
=
Shape
{
6
};
auto
shape
=
Shape
{
6
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Cos
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Cos
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1966,14 +1966,14 @@ TEST(execute, cos)
...
@@ -1966,14 +1966,14 @@ TEST(execute, cos)
ASSERT_EQ
(
input
,
result
->
get_vector
());
ASSERT_EQ
(
input
,
result
->
get_vector
());
}
}
TEST
(
execute
,
tan
)
TEST
(
$
{
BACKEND_NAME
}
,
tan
)
{
{
auto
shape
=
Shape
{
6
};
auto
shape
=
Shape
{
6
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Tan
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Tan
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -1992,14 +1992,14 @@ TEST(execute, tan)
...
@@ -1992,14 +1992,14 @@ TEST(execute, tan)
ASSERT_EQ
(
input
,
result
->
get_vector
());
ASSERT_EQ
(
input
,
result
->
get_vector
());
}
}
TEST
(
execute
,
asin
)
TEST
(
$
{
BACKEND_NAME
}
,
asin
)
{
{
auto
shape
=
Shape
{
6
};
auto
shape
=
Shape
{
6
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Asin
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Asin
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2017,14 +2017,14 @@ TEST(execute, asin)
...
@@ -2017,14 +2017,14 @@ TEST(execute, asin)
ASSERT_EQ
(
input
,
result
->
get_vector
());
ASSERT_EQ
(
input
,
result
->
get_vector
());
}
}
TEST
(
execute
,
acos
)
TEST
(
$
{
BACKEND_NAME
}
,
acos
)
{
{
auto
shape
=
Shape
{
6
};
auto
shape
=
Shape
{
6
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Acos
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Acos
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2042,14 +2042,14 @@ TEST(execute, acos)
...
@@ -2042,14 +2042,14 @@ TEST(execute, acos)
ASSERT_EQ
(
input
,
result
->
get_vector
());
ASSERT_EQ
(
input
,
result
->
get_vector
());
}
}
TEST
(
execute
,
atan
)
TEST
(
$
{
BACKEND_NAME
}
,
atan
)
{
{
auto
shape
=
Shape
{
6
};
auto
shape
=
Shape
{
6
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Atan
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Atan
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2067,14 +2067,14 @@ TEST(execute, atan)
...
@@ -2067,14 +2067,14 @@ TEST(execute, atan)
ASSERT_EQ
(
input
,
result
->
get_vector
());
ASSERT_EQ
(
input
,
result
->
get_vector
());
}
}
TEST
(
execute
,
sinh
)
TEST
(
$
{
BACKEND_NAME
}
,
sinh
)
{
{
auto
shape
=
Shape
{
6
};
auto
shape
=
Shape
{
6
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sinh
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sinh
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2092,14 +2092,14 @@ TEST(execute, sinh)
...
@@ -2092,14 +2092,14 @@ TEST(execute, sinh)
ASSERT_EQ
(
input
,
result
->
get_vector
());
ASSERT_EQ
(
input
,
result
->
get_vector
());
}
}
TEST
(
execute
,
cosh
)
TEST
(
$
{
BACKEND_NAME
}
,
cosh
)
{
{
auto
shape
=
Shape
{
6
};
auto
shape
=
Shape
{
6
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Cosh
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Cosh
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2117,14 +2117,14 @@ TEST(execute, cosh)
...
@@ -2117,14 +2117,14 @@ TEST(execute, cosh)
ASSERT_EQ
(
input
,
result
->
get_vector
());
ASSERT_EQ
(
input
,
result
->
get_vector
());
}
}
TEST
(
execute
,
tanh
)
TEST
(
$
{
BACKEND_NAME
}
,
tanh
)
{
{
auto
shape
=
Shape
{
6
};
auto
shape
=
Shape
{
6
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Tanh
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Tanh
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2142,14 +2142,14 @@ TEST(execute, tanh)
...
@@ -2142,14 +2142,14 @@ TEST(execute, tanh)
ASSERT_EQ
(
input
,
result
->
get_vector
());
ASSERT_EQ
(
input
,
result
->
get_vector
());
}
}
TEST
(
execute
,
exp
)
TEST
(
$
{
BACKEND_NAME
}
,
exp
)
{
{
auto
shape
=
Shape
{
8
};
auto
shape
=
Shape
{
8
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Exp
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Exp
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2165,7 +2165,7 @@ TEST(execute, exp)
...
@@ -2165,7 +2165,7 @@ TEST(execute, exp)
result
->
get_vector
());
result
->
get_vector
());
}
}
TEST
(
execute
,
slice_scalar
)
TEST
(
$
{
BACKEND_NAME
}
,
slice_scalar
)
{
{
auto
shape_a
=
Shape
{};
auto
shape_a
=
Shape
{};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -2175,7 +2175,7 @@ TEST(execute, slice_scalar)
...
@@ -2175,7 +2175,7 @@ TEST(execute, slice_scalar)
auto
r
=
make_shared
<
op
::
Slice
>
(
A
,
Coordinate
{},
Coordinate
{});
auto
r
=
make_shared
<
op
::
Slice
>
(
A
,
Coordinate
{},
Coordinate
{});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2189,7 +2189,7 @@ TEST(execute, slice_scalar)
...
@@ -2189,7 +2189,7 @@ TEST(execute, slice_scalar)
ASSERT_EQ
((
vector
<
float
>
{
312
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
312
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
slice_matrix
)
TEST
(
$
{
BACKEND_NAME
}
,
slice_matrix
)
{
{
auto
shape_a
=
Shape
{
4
,
4
};
auto
shape_a
=
Shape
{
4
,
4
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -2199,7 +2199,7 @@ TEST(execute, slice_matrix)
...
@@ -2199,7 +2199,7 @@ TEST(execute, slice_matrix)
auto
r
=
make_shared
<
op
::
Slice
>
(
A
,
Coordinate
{
0
,
1
},
Coordinate
{
3
,
3
});
auto
r
=
make_shared
<
op
::
Slice
>
(
A
,
Coordinate
{
0
,
1
},
Coordinate
{
3
,
3
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2213,7 +2213,7 @@ TEST(execute, slice_matrix)
...
@@ -2213,7 +2213,7 @@ TEST(execute, slice_matrix)
ASSERT_EQ
((
vector
<
float
>
{
2
,
3
,
6
,
7
,
10
,
11
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
2
,
3
,
6
,
7
,
10
,
11
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
slice_vector
)
TEST
(
$
{
BACKEND_NAME
}
,
slice_vector
)
{
{
auto
shape_a
=
Shape
{
16
};
auto
shape_a
=
Shape
{
16
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
auto
A
=
make_shared
<
op
::
Parameter
>
(
...
@@ -2223,7 +2223,7 @@ TEST(execute, slice_vector)
...
@@ -2223,7 +2223,7 @@ TEST(execute, slice_vector)
auto
r
=
make_shared
<
op
::
Slice
>
(
A
,
Coordinate
{
2
},
Coordinate
{
14
});
auto
r
=
make_shared
<
op
::
Slice
>
(
A
,
Coordinate
{
2
},
Coordinate
{
14
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2237,13 +2237,13 @@ TEST(execute, slice_vector)
...
@@ -2237,13 +2237,13 @@ TEST(execute, slice_vector)
ASSERT_EQ
((
vector
<
float
>
{
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
scalar_constant_float32
)
TEST
(
$
{
BACKEND_NAME
}
,
scalar_constant_float32
)
{
{
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
r
=
make_shared
<
op
::
Constant
>
(
element
::
Float32
::
element_type
(),
Shape
{},
"4.8"
);
auto
r
=
make_shared
<
op
::
Constant
>
(
element
::
Float32
::
element_type
(),
Shape
{},
"4.8"
);
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2255,13 +2255,13 @@ TEST(execute, scalar_constant_float32)
...
@@ -2255,13 +2255,13 @@ TEST(execute, scalar_constant_float32)
ASSERT_EQ
(
vector
<
float
>
{
std
::
strtof
(
"4.8"
,
NULL
)},
result
->
get_vector
());
ASSERT_EQ
(
vector
<
float
>
{
std
::
strtof
(
"4.8"
,
NULL
)},
result
->
get_vector
());
}
}
TEST
(
execute
,
scalar_constant_int64
)
TEST
(
$
{
BACKEND_NAME
}
,
scalar_constant_int64
)
{
{
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Int64
::
element_type
(),
Shape
{});
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Int64
::
element_type
(),
Shape
{});
auto
r
=
make_shared
<
op
::
Constant
>
(
element
::
Int64
::
element_type
(),
Shape
{},
"2112"
);
auto
r
=
make_shared
<
op
::
Constant
>
(
element
::
Int64
::
element_type
(),
Shape
{},
"2112"
);
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2273,7 +2273,7 @@ TEST(execute, scalar_constant_int64)
...
@@ -2273,7 +2273,7 @@ TEST(execute, scalar_constant_int64)
ASSERT_EQ
(
vector
<
element
::
Int64
::
type
>
{
std
::
strtol
(
"2112"
,
NULL
,
10
)},
result
->
get_vector
());
ASSERT_EQ
(
vector
<
element
::
Int64
::
type
>
{
std
::
strtol
(
"2112"
,
NULL
,
10
)},
result
->
get_vector
());
}
}
TEST
(
execute
,
tensor_constant_float32
)
TEST
(
$
{
BACKEND_NAME
}
,
tensor_constant_float32
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
...
@@ -2282,7 +2282,7 @@ TEST(execute, tensor_constant_float32)
...
@@ -2282,7 +2282,7 @@ TEST(execute, tensor_constant_float32)
std
::
vector
<
std
::
string
>
{
"4.8"
,
"4.7"
,
"-5.3"
,
"0"
});
std
::
vector
<
std
::
string
>
{
"4.8"
,
"4.7"
,
"-5.3"
,
"0"
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2298,7 +2298,7 @@ TEST(execute, tensor_constant_float32)
...
@@ -2298,7 +2298,7 @@ TEST(execute, tensor_constant_float32)
result
->
get_vector
());
result
->
get_vector
());
}
}
TEST
(
execute
,
tensor_constant_int64
)
TEST
(
$
{
BACKEND_NAME
}
,
tensor_constant_int64
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Int64
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Int64
::
element_type
(),
shape
);
...
@@ -2307,7 +2307,7 @@ TEST(execute, tensor_constant_int64)
...
@@ -2307,7 +2307,7 @@ TEST(execute, tensor_constant_int64)
std
::
vector
<
std
::
string
>
{
"2112"
,
"1848"
,
"1776"
,
"1964"
});
std
::
vector
<
std
::
string
>
{
"2112"
,
"1848"
,
"1776"
,
"1964"
});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{});
auto
f
=
make_shared
<
Function
>
(
r
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2324,14 +2324,14 @@ TEST(execute, tensor_constant_int64)
...
@@ -2324,14 +2324,14 @@ TEST(execute, tensor_constant_int64)
}
}
// Trivial case with no summed axes.
// Trivial case with no summed axes.
TEST
(
execute
,
sum_trivial
)
TEST
(
$
{
BACKEND_NAME
}
,
sum_trivial
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{}),
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2345,14 +2345,14 @@ TEST(execute, sum_trivial)
...
@@ -2345,14 +2345,14 @@ TEST(execute, sum_trivial)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
}),
result
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
}),
result
->
get_vector
());
}
}
TEST
(
execute
,
sum_to_scalar
)
TEST
(
$
{
BACKEND_NAME
}
,
sum_to_scalar
)
{
{
auto
shape
=
Shape
{
2
,
2
};
auto
shape
=
Shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
0
,
1
}),
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
0
,
1
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2370,7 +2370,7 @@ TEST(execute, sum_to_scalar)
...
@@ -2370,7 +2370,7 @@ TEST(execute, sum_to_scalar)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
}),
a
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
}),
a
->
get_vector
());
}
}
TEST
(
execute
,
sum_matrix_columns
)
TEST
(
$
{
BACKEND_NAME
}
,
sum_matrix_columns
)
{
{
auto
shape_a
=
Shape
{
3
,
2
};
auto
shape_a
=
Shape
{
3
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -2378,7 +2378,7 @@ TEST(execute, sum_matrix_columns)
...
@@ -2378,7 +2378,7 @@ TEST(execute, sum_matrix_columns)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_rt
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_rt
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
0
}),
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
0
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2396,7 +2396,7 @@ TEST(execute, sum_matrix_columns)
...
@@ -2396,7 +2396,7 @@ TEST(execute, sum_matrix_columns)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
}),
a
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
}),
a
->
get_vector
());
}
}
TEST
(
execute
,
sum_matrix_rows
)
TEST
(
$
{
BACKEND_NAME
}
,
sum_matrix_rows
)
{
{
auto
shape_a
=
Shape
{
3
,
2
};
auto
shape_a
=
Shape
{
3
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -2404,7 +2404,7 @@ TEST(execute, sum_matrix_rows)
...
@@ -2404,7 +2404,7 @@ TEST(execute, sum_matrix_rows)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_rt
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_rt
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
1
}),
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
1
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2422,7 +2422,7 @@ TEST(execute, sum_matrix_rows)
...
@@ -2422,7 +2422,7 @@ TEST(execute, sum_matrix_rows)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
}),
a
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
}),
a
->
get_vector
());
}
}
TEST
(
execute
,
sum_matrix_rows_zero
)
TEST
(
$
{
BACKEND_NAME
}
,
sum_matrix_rows_zero
)
{
{
auto
shape_a
=
Shape
{
3
,
0
};
auto
shape_a
=
Shape
{
3
,
0
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -2430,7 +2430,7 @@ TEST(execute, sum_matrix_rows_zero)
...
@@ -2430,7 +2430,7 @@ TEST(execute, sum_matrix_rows_zero)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_rt
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_rt
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
1
}),
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
1
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2448,7 +2448,7 @@ TEST(execute, sum_matrix_rows_zero)
...
@@ -2448,7 +2448,7 @@ TEST(execute, sum_matrix_rows_zero)
ASSERT_EQ
((
vector
<
float
>
{}),
a
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{}),
a
->
get_vector
());
}
}
TEST
(
execute
,
sum_matrix_cols_zero
)
TEST
(
$
{
BACKEND_NAME
}
,
sum_matrix_cols_zero
)
{
{
// Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})).
// Now the reduction (g(x:float32[2,2],y:float32[]) = reduce(x,y,f,axes={})).
auto
shape_a
=
Shape
{
0
,
2
};
auto
shape_a
=
Shape
{
0
,
2
};
...
@@ -2457,7 +2457,7 @@ TEST(execute, sum_matrix_cols_zero)
...
@@ -2457,7 +2457,7 @@ TEST(execute, sum_matrix_cols_zero)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_rt
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_rt
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
0
}),
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
0
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2475,7 +2475,7 @@ TEST(execute, sum_matrix_cols_zero)
...
@@ -2475,7 +2475,7 @@ TEST(execute, sum_matrix_cols_zero)
ASSERT_EQ
((
vector
<
float
>
{}),
a
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{}),
a
->
get_vector
());
}
}
TEST
(
execute
,
sum_vector_zero
)
TEST
(
$
{
BACKEND_NAME
}
,
sum_vector_zero
)
{
{
auto
shape_a
=
Shape
{
0
};
auto
shape_a
=
Shape
{
0
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -2483,7 +2483,7 @@ TEST(execute, sum_vector_zero)
...
@@ -2483,7 +2483,7 @@ TEST(execute, sum_vector_zero)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_rt
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_rt
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
0
}),
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
0
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2501,7 +2501,7 @@ TEST(execute, sum_vector_zero)
...
@@ -2501,7 +2501,7 @@ TEST(execute, sum_vector_zero)
ASSERT_EQ
((
vector
<
float
>
{}),
a
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{}),
a
->
get_vector
());
}
}
TEST
(
execute
,
sum_matrix_to_scalar_zero_by_zero
)
TEST
(
$
{
BACKEND_NAME
}
,
sum_matrix_to_scalar_zero_by_zero
)
{
{
auto
shape_a
=
Shape
{
0
,
0
};
auto
shape_a
=
Shape
{
0
,
0
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
...
@@ -2509,7 +2509,7 @@ TEST(execute, sum_matrix_to_scalar_zero_by_zero)
...
@@ -2509,7 +2509,7 @@ TEST(execute, sum_matrix_to_scalar_zero_by_zero)
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_rt
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_rt
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
0
,
1
}),
rt
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sum
>
(
A
,
AxisSet
{
0
,
1
}),
rt
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
@@ -2527,14 +2527,14 @@ TEST(execute, sum_matrix_to_scalar_zero_by_zero)
...
@@ -2527,14 +2527,14 @@ TEST(execute, sum_matrix_to_scalar_zero_by_zero)
ASSERT_EQ
((
vector
<
float
>
{}),
a
->
get_vector
());
ASSERT_EQ
((
vector
<
float
>
{}),
a
->
get_vector
());
}
}
TEST
(
execute
,
sign
)
TEST
(
$
{
BACKEND_NAME
}
,
sign
)
{
{
auto
shape
=
Shape
{
2
,
3
};
auto
shape
=
Shape
{
2
,
3
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
result_type
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sign
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Sign
>
(
A
),
result_type
,
op
::
Parameters
{
A
});
auto
manager
=
runtime
::
Manager
::
get
(
"
NGVM
"
);
auto
manager
=
runtime
::
Manager
::
get
(
"
${BACKEND_NAME}
"
);
auto
external
=
manager
->
compile
(
f
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
auto
cf
=
backend
->
make_call_frame
(
external
);
...
...
test/codegen.cpp
0 → 100644
View file @
af18be14
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
#include "ngraph/codegen/compiler.hpp"
using
namespace
std
;
TEST
(
codegen
,
simple_return
)
{
constexpr
auto
name
=
"test.cpp"
;
constexpr
auto
source
=
R"(extern "C" int test() { return 2+5; })"
;
ngraph
::
codegen
::
execution_state
estate
;
auto
module
=
estate
.
compile
(
source
,
name
);
ASSERT_NE
(
nullptr
,
module
);
estate
.
add_module
(
module
);
estate
.
finalize
();
auto
func
=
estate
.
find_function
<
int
()
>
(
"test"
);
ASSERT_NE
(
nullptr
,
func
);
int
result
=
func
();
EXPECT_EQ
(
7
,
result
);
}
TEST
(
codegen
,
pass_args
)
{
constexpr
auto
name
=
"test.cpp"
;
constexpr
auto
source
=
R"(extern "C" int test(int a, int b) { return a+b; })"
;
ngraph
::
codegen
::
execution_state
estate
;
auto
module
=
estate
.
compile
(
source
,
name
);
ASSERT_NE
(
nullptr
,
module
);
estate
.
add_module
(
module
);
estate
.
finalize
();
auto
func
=
estate
.
find_function
<
int
(
int
,
int
)
>
(
"test"
);
ASSERT_NE
(
nullptr
,
func
);
int
result
=
func
(
20
,
22
);
EXPECT_EQ
(
42
,
result
);
}
TEST
(
codegen
,
include
)
{
constexpr
auto
name
=
"test.cpp"
;
constexpr
auto
source
=
R"(
#include <cmath>
extern "C" int test(int a, int b)
{
return (int)pow((double)a,(double)b);
}
)"
;
ngraph
::
codegen
::
execution_state
estate
;
auto
module
=
estate
.
compile
(
source
,
name
);
ASSERT_NE
(
nullptr
,
module
);
estate
.
add_module
(
module
);
estate
.
finalize
();
auto
func
=
estate
.
find_function
<
int
(
int
,
int
)
>
(
"test"
);
ASSERT_NE
(
nullptr
,
func
);
int
result
=
func
(
20
,
2
);
EXPECT_EQ
(
400
,
result
);
}
third-party/CMakeLists.txt
View file @
af18be14
...
@@ -14,3 +14,4 @@
...
@@ -14,3 +14,4 @@
include
(
../cmake/external_gtest.cmake
)
include
(
../cmake/external_gtest.cmake
)
include
(
../cmake/external_eigen.cmake
)
include
(
../cmake/external_eigen.cmake
)
include
(
../cmake/external_mkldnn.cmake
)
include
(
../cmake/external_mkldnn.cmake
)
include
(
../cmake/external_llvm.cmake
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment