[WIP] CUDA tests (#95)

* one more CI test

Signed-off-by: raver119 <raver119@gmail.com>

* export additional symbols

Signed-off-by: raver119 <raver119@gmail.com>

* few more tweaks

Signed-off-by: raver119 <raver119@gmail.com>

* one more tweak for linux

Signed-off-by: raver119 <raver119@gmail.com>

* fix dtype in few tests

Signed-off-by: raver119 <raver119@gmail.com>

* missing sync and memset in couple of tests

Signed-off-by: raver119 <raver119@gmail.com>

* copy step for libnd4j cuda

Signed-off-by: raver119 <raver119@gmail.com>

* no-op on empty for adjust hue/contrast/saturation

Signed-off-by: raver119 <raver119@gmail.com>

* CUDA_VERBOSE Off

Signed-off-by: raver119 <raver119@gmail.com>

* BroadcastBool fix + few tests

Signed-off-by: raver119 <raver119@gmail.com>

* trigger jenkins

Signed-off-by: raver119 <raver119@gmail.com>

* trigger jenkins

Signed-off-by: raver119 <raver119@gmail.com>

* - ignore couple of warnings
- remove redundant compiler options

Signed-off-by: raver119 <raver119@gmail.com>
master
raver119 2019-12-02 21:37:21 +03:00 committed by GitHub
parent 5e152c0d9a
commit 25b3cd9b80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 673 additions and 518 deletions

View File

@ -25,8 +25,8 @@ elseif (APPLE)
elseif(WIN32) elseif(WIN32)
set(X86_BUILD true) set(X86_BUILD true)
if (CUDA_BLAS) if (CUDA_BLAS)
set(CMAKE_CXX_FLAGS_RELEASE "-D_RELEASE=true /wd4804") set(CMAKE_CXX_FLAGS_RELEASE "-D_RELEASE=true")
set(CMAKE_CXX_FLAGS_DEBUG " /FS /EHsc /wd4661 /wd4804 /wd4267 /wd4244 /wd4251 /wd4305") set(CMAKE_CXX_FLAGS_DEBUG " /FS /EHsc")
else() else()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fPIC -std=c++11 -fmax-errors=2 -D_RELEASE=true") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fPIC -std=c++11 -fmax-errors=2 -D_RELEASE=true")
set(CMAKE_CXX_FLAGS_DEBUG " -g -O2 -fPIC -std=c++11 -fmax-errors=2") set(CMAKE_CXX_FLAGS_DEBUG " -g -O2 -fPIC -std=c++11 -fmax-errors=2")

View File

@ -111,7 +111,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# using Visual Studio C++ # using Visual Studio C++
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc ${ARCH_TUNE}") set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_TUNE}")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC # using GCC
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_TUNE}") SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_TUNE}")
@ -158,7 +158,7 @@ if(CUDA_BLAS)
include_directories(${CUDA_INCLUDE_DIRS}) include_directories(${CUDA_INCLUDE_DIRS})
message("CUDA found!") message("CUDA found!")
set( CUDA_ARCHITECTURE_MINIMUM "3.0" CACHE STRING "Minimum required CUDA compute capability" ) set( CUDA_ARCHITECTURE_MINIMUM "3.0" CACHE STRING "Minimum required CUDA compute capability" )
SET(CUDA_VERBOSE_BUILD ON) SET(CUDA_VERBOSE_BUILD OFF)
SET(CUDA_SEPARABLE_COMPILATION OFF) SET(CUDA_SEPARABLE_COMPILATION OFF)
#set(CUDA_COMPUTE_CAPABILITY "61") #set(CUDA_COMPUTE_CAPABILITY "61")
set(CUDA_COMPUTE_CAPABILITY "35") set(CUDA_COMPUTE_CAPABILITY "35")
@ -264,24 +264,13 @@ if(CUDA_BLAS)
file(GLOB_RECURSE LOOPS_SOURCES false ../include/loops/impl/*.cpp ../include/loops/*.h) file(GLOB_RECURSE LOOPS_SOURCES false ../include/loops/impl/*.cpp ../include/loops/*.h)
file(GLOB_RECURSE LOOPS_SOURCES_CUDA false ../include/loops/*.cu) file(GLOB_RECURSE LOOPS_SOURCES_CUDA false ../include/loops/*.cu)
if (NOT BUILD_TESTS)
CUDA_ADD_LIBRARY(${LIBND4J_NAME} SHARED cuda/NativeOps.cu cuda/NativeOpExecutioner.cu cuda/BlasVersionHelper.cu Environment.cpp ${LOOPS_SOURCES_CUDA} CUDA_ADD_LIBRARY(${LIBND4J_NAME} SHARED cuda/NativeOps.cu cuda/NativeOpExecutioner.cu cuda/BlasVersionHelper.cu Environment.cpp ${LOOPS_SOURCES_CUDA}
${CUSTOMOPS_HELPERS_SOURCES} ${HELPERS_SOURCES} ${EXEC_SOURCES} ${CUSTOMOPS_HELPERS_SOURCES} ${HELPERS_SOURCES} ${EXEC_SOURCES}
../include/cnpy/cnpy.cpp ../include/nd4jmemset.h ../include/nd4jmalloc.h ../include/cnpy/cnpy.cpp ../include/nd4jmemset.h ../include/nd4jmalloc.h
cpu/GraphExecutioner.cpp cuda/NDArray.cu cpu/NDArrayFactory.cpp cpu/GraphExecutioner.cpp cuda/NDArray.cu cpu/NDArrayFactory.cpp
Environment.h ${LOOPS_SOURCES} ${ARRAY_SOURCES} ${TYPES_SOURCES} Environment.h ${LOOPS_SOURCES} ${ARRAY_SOURCES} ${TYPES_SOURCES}
${MEMORY_SOURCES} ${GRAPH_SOURCES} ${CUSTOMOPS_SOURCES} ${INDEXING_SOURCES} ${EXCEPTIONS_SOURCES} ${OPS_SOURCES} ${PERF_SOURCES}) ${MEMORY_SOURCES} ${GRAPH_SOURCES} ${CUSTOMOPS_SOURCES} ${INDEXING_SOURCES} ${EXCEPTIONS_SOURCES} ${OPS_SOURCES} ${PERF_SOURCES})
else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_TESTS=true")
CUDA_ADD_LIBRARY(${LIBND4J_NAME} STATIC cuda/NativeOps.cu cuda/NativeOpExecutioner.cu cuda/BlasVersionHelper.cu Environment.cpp ${LOOPS_SOURCES_CUDA}
${CUSTOMOPS_HELPERS_SOURCES} ${HELPERS_SOURCES} ${EXEC_SOURCES}
../include/cnpy/cnpy.cpp ../include/nd4jmemset.h ../include/nd4jmalloc.h
cpu/GraphExecutioner.cpp cuda/NDArray.cu cpu/NDArrayFactory.cpp
Environment.h ${LOOPS_SOURCES} ${ARRAY_SOURCES} ${TYPES_SOURCES}
${MEMORY_SOURCES} ${GRAPH_SOURCES} ${CUSTOMOPS_SOURCES} ${INDEXING_SOURCES} ${EXCEPTIONS_SOURCES} ${OPS_SOURCES} ${PERF_SOURCES})
endif()
if(WIN32) if(WIN32)
message("CUDA on Windows: enabling /EHsc") message("CUDA on Windows: enabling /EHsc")
@ -289,11 +278,16 @@ if(CUDA_BLAS)
SET_TARGET_PROPERTIES(${LIBND4J_NAME} PROPERTIES COMPILER_FLAGS "/EHsc /bigobj /std:c++14") SET_TARGET_PROPERTIES(${LIBND4J_NAME} PROPERTIES COMPILER_FLAGS "/EHsc /bigobj /std:c++14")
endif() endif()
target_link_libraries(${LIBND4J_NAME} ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_cusolver_LIBRARY}) target_link_libraries(${LIBND4J_NAME} ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_cusolver_LIBRARY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/cuda) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/cuda)
install(TARGETS ${LIBND4J_NAME} DESTINATION .) install(TARGETS ${LIBND4J_NAME} DESTINATION .)
add_custom_command(
TARGET ${LIBND4J_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:${LIBND4J_NAME}>
${PROJECT_BINARY_DIR}/../../tests_cpu/)
endif(CUDA_FOUND) endif(CUDA_FOUND)
elseif(CPU_BLAS) elseif(CPU_BLAS)

View File

@ -31,9 +31,9 @@
namespace nd4j { namespace nd4j {
template <> template <>
utf8string NDArray::e(const Nd4jLong i) const; ND4J_EXPORT utf8string NDArray::e(const Nd4jLong i) const;
template <> template <>
std::string NDArray::e(const Nd4jLong i) const; ND4J_EXPORT std::string NDArray::e(const Nd4jLong i) const;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
template <typename T> template <typename T>
@ -48,7 +48,7 @@ NDArray* NDArray::asT() const{
return result; return result;
} }
BUILD_SINGLE_TEMPLATE(template NDArray* NDArray::asT, () const, LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT NDArray* NDArray::asT, () const, LIBND4J_TYPES);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// copy constructor // copy constructor
@ -435,7 +435,7 @@ std::vector<T> NDArray::getBufferAsVector() {
vector[e] = this->e<T>(e); vector[e] = this->e<T>(e);
return vector; return vector;
} }
BUILD_SINGLE_TEMPLATE(template std::vector, NDArray::getBufferAsVector(), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT std::vector, NDArray::getBufferAsVector(), LIBND4J_TYPES);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
std::vector<int64_t> NDArray::getShapeAsFlatVector() { std::vector<int64_t> NDArray::getShapeAsFlatVector() {
@ -813,7 +813,7 @@ void NDArray::templatedSet(void *buffer, const Nd4jLong *indices, const void *va
auto xOffset = shape::getOffset(getShapeInfo(), indices); auto xOffset = shape::getOffset(getShapeInfo(), indices);
t[xOffset] = static_cast<T>(y); t[xOffset] = static_cast<T>(y);
} }
BUILD_DOUBLE_TEMPLATE(template void NDArray::templatedSet, (void *buffer, const Nd4jLong *indices, const void *value), LIBND4J_TYPES, LIBND4J_TYPES); BUILD_DOUBLE_TEMPLATE(template ND4J_EXPORT void NDArray::templatedSet, (void *buffer, const Nd4jLong *indices, const void *value), LIBND4J_TYPES, LIBND4J_TYPES);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
template <typename T, typename Y> template <typename T, typename Y>
@ -823,7 +823,7 @@ void NDArray::templatedSet(void *buffer, const Nd4jLong offset, const void *valu
t[offset] = static_cast<T>(y); t[offset] = static_cast<T>(y);
} }
BUILD_DOUBLE_TEMPLATE(template void NDArray::templatedSet, (void *buffer, const Nd4jLong offset, const void *value), LIBND4J_TYPES, LIBND4J_TYPES); BUILD_DOUBLE_TEMPLATE(template ND4J_EXPORT void NDArray::templatedSet, (void *buffer, const Nd4jLong offset, const void *value), LIBND4J_TYPES, LIBND4J_TYPES);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void NDArray::setContext(nd4j::LaunchContext *context) { void NDArray::setContext(nd4j::LaunchContext *context) {
@ -1301,7 +1301,7 @@ template <typename T>
void* NDArray::templatedPointerShift(const Nd4jLong offset) const { void* NDArray::templatedPointerShift(const Nd4jLong offset) const {
return reinterpret_cast<T*>(getBuffer()) + offset; return reinterpret_cast<T*>(getBuffer()) + offset;
} }
BUILD_SINGLE_TEMPLATE(template void* NDArray::templatedPointerShift, (const Nd4jLong offset) const, LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT void* NDArray::templatedPointerShift, (const Nd4jLong offset) const, LIBND4J_TYPES);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// method makes copy of this array and applies to the copy transpose operation, this array remains unaffected // method makes copy of this array and applies to the copy transpose operation, this array remains unaffected
@ -1608,7 +1608,7 @@ bool NDArray::isUnitary() {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
template <> template <>
std::string* NDArray::bufferAsT() const { std::string* ND4J_EXPORT NDArray::bufferAsT() const {
throw std::runtime_error("This method is NOT supposed to be used"); throw std::runtime_error("This method is NOT supposed to be used");
} }
@ -1620,7 +1620,7 @@ T* NDArray::bufferAsT() const {
return reinterpret_cast<T*>(getBuffer()); return reinterpret_cast<T*>(getBuffer());
} }
BUILD_SINGLE_UNCHAINED_TEMPLATE(template, * NDArray::bufferAsT() const, LIBND4J_TYPES); BUILD_SINGLE_UNCHAINED_TEMPLATE(template ND4J_EXPORT , * NDArray::bufferAsT() const, LIBND4J_TYPES);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
NDArray* NDArray::subarray(IndicesList& idx) const { NDArray* NDArray::subarray(IndicesList& idx) const {
@ -1797,16 +1797,16 @@ NDArray NDArray::operator+(const T& scalar) const {
return result; return result;
} }
template NDArray NDArray::operator+(const double& scalar) const; template ND4J_EXPORT NDArray NDArray::operator+(const double& scalar) const;
template NDArray NDArray::operator+(const float& scalar) const; template ND4J_EXPORT NDArray NDArray::operator+(const float& scalar) const;
template NDArray NDArray::operator+(const float16& scalar) const; template ND4J_EXPORT NDArray NDArray::operator+(const float16& scalar) const;
template NDArray NDArray::operator+(const bfloat16& scalar) const; template ND4J_EXPORT NDArray NDArray::operator+(const bfloat16& scalar) const;
template NDArray NDArray::operator+(const Nd4jLong& scalar) const; template ND4J_EXPORT NDArray NDArray::operator+(const Nd4jLong& scalar) const;
template NDArray NDArray::operator+(const int& scalar) const; template ND4J_EXPORT NDArray NDArray::operator+(const int& scalar) const;
template NDArray NDArray::operator+(const int16_t& scalar) const; template ND4J_EXPORT NDArray NDArray::operator+(const int16_t& scalar) const;
template NDArray NDArray::operator+(const int8_t& scalar) const; template ND4J_EXPORT NDArray NDArray::operator+(const int8_t& scalar) const;
template NDArray NDArray::operator+(const uint8_t& scalar) const; template ND4J_EXPORT NDArray NDArray::operator+(const uint8_t& scalar) const;
template NDArray NDArray::operator+(const bool& scalar) const; template ND4J_EXPORT NDArray NDArray::operator+(const bool& scalar) const;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// subtraction operator array - scalar // subtraction operator array - scalar
@ -1824,16 +1824,16 @@ NDArray NDArray::operator-(const T& scalar) const {
return result; return result;
} }
template NDArray NDArray::operator-(const double& scalar) const; template ND4J_EXPORT NDArray NDArray::operator-(const double& scalar) const;
template NDArray NDArray::operator-(const float& scalar) const; template ND4J_EXPORT NDArray NDArray::operator-(const float& scalar) const;
template NDArray NDArray::operator-(const float16& scalar) const; template ND4J_EXPORT NDArray NDArray::operator-(const float16& scalar) const;
template NDArray NDArray::operator-(const bfloat16& scalar) const; template ND4J_EXPORT NDArray NDArray::operator-(const bfloat16& scalar) const;
template NDArray NDArray::operator-(const Nd4jLong& scalar) const; template ND4J_EXPORT NDArray NDArray::operator-(const Nd4jLong& scalar) const;
template NDArray NDArray::operator-(const int& scalar) const; template ND4J_EXPORT NDArray NDArray::operator-(const int& scalar) const;
template NDArray NDArray::operator-(const int16_t& scalar) const; template ND4J_EXPORT NDArray NDArray::operator-(const int16_t& scalar) const;
template NDArray NDArray::operator-(const int8_t& scalar) const; template ND4J_EXPORT NDArray NDArray::operator-(const int8_t& scalar) const;
template NDArray NDArray::operator-(const uint8_t& scalar) const; template ND4J_EXPORT NDArray NDArray::operator-(const uint8_t& scalar) const;
template NDArray NDArray::operator-(const bool& scalar) const; template ND4J_EXPORT NDArray NDArray::operator-(const bool& scalar) const;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// multiplication operator array*scalar // multiplication operator array*scalar
@ -1851,16 +1851,16 @@ NDArray NDArray::operator*(const T& scalar) const {
return result; return result;
} }
template NDArray NDArray::operator*(const double& scalar) const; template ND4J_EXPORT NDArray NDArray::operator*(const double& scalar) const;
template NDArray NDArray::operator*(const float& scalar) const; template ND4J_EXPORT NDArray NDArray::operator*(const float& scalar) const;
template NDArray NDArray::operator*(const float16& scalar) const; template ND4J_EXPORT NDArray NDArray::operator*(const float16& scalar) const;
template NDArray NDArray::operator*(const bfloat16& scalar) const; template ND4J_EXPORT NDArray NDArray::operator*(const bfloat16& scalar) const;
template NDArray NDArray::operator*(const Nd4jLong& scalar) const; template ND4J_EXPORT NDArray NDArray::operator*(const Nd4jLong& scalar) const;
template NDArray NDArray::operator*(const int& scalar) const; template ND4J_EXPORT NDArray NDArray::operator*(const int& scalar) const;
template NDArray NDArray::operator*(const int16_t& scalar) const; template ND4J_EXPORT NDArray NDArray::operator*(const int16_t& scalar) const;
template NDArray NDArray::operator*(const int8_t& scalar) const; template ND4J_EXPORT NDArray NDArray::operator*(const int8_t& scalar) const;
template NDArray NDArray::operator*(const uint8_t& scalar) const; template ND4J_EXPORT NDArray NDArray::operator*(const uint8_t& scalar) const;
template NDArray NDArray::operator*(const bool& scalar) const; template ND4J_EXPORT NDArray NDArray::operator*(const bool& scalar) const;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// division operator array / scalar // division operator array / scalar
@ -1881,16 +1881,16 @@ NDArray NDArray::operator/(const T& scalar) const {
return result; return result;
} }
template NDArray NDArray::operator/(const double& scalar) const; template ND4J_EXPORT NDArray NDArray::operator/(const double& scalar) const;
template NDArray NDArray::operator/(const float& scalar) const; template ND4J_EXPORT NDArray NDArray::operator/(const float& scalar) const;
template NDArray NDArray::operator/(const float16& scalar) const; template ND4J_EXPORT NDArray NDArray::operator/(const float16& scalar) const;
template NDArray NDArray::operator/(const bfloat16& scalar) const; template ND4J_EXPORT NDArray NDArray::operator/(const bfloat16& scalar) const;
template NDArray NDArray::operator/(const Nd4jLong& scalar) const; template ND4J_EXPORT NDArray NDArray::operator/(const Nd4jLong& scalar) const;
template NDArray NDArray::operator/(const int& scalar) const; template ND4J_EXPORT NDArray NDArray::operator/(const int& scalar) const;
template NDArray NDArray::operator/(const int16_t& scalar) const; template ND4J_EXPORT NDArray NDArray::operator/(const int16_t& scalar) const;
template NDArray NDArray::operator/(const int8_t& scalar) const; template ND4J_EXPORT NDArray NDArray::operator/(const int8_t& scalar) const;
template NDArray NDArray::operator/(const uint8_t& scalar) const; template ND4J_EXPORT NDArray NDArray::operator/(const uint8_t& scalar) const;
template NDArray NDArray::operator/(const bool& scalar) const; template ND4J_EXPORT NDArray NDArray::operator/(const bool& scalar) const;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// addition operator scalar + array // addition operator scalar + array
@ -2260,13 +2260,13 @@ void NDArray::operator+=(const T value) {
NDArray::registerSpecialUse({this}, {}); NDArray::registerSpecialUse({this}, {});
} }
template void NDArray::operator+=(const double value); template ND4J_EXPORT void NDArray::operator+=(const double value);
template void NDArray::operator+=(const float value); template ND4J_EXPORT void NDArray::operator+=(const float value);
template void NDArray::operator+=(const float16 value); template ND4J_EXPORT void NDArray::operator+=(const float16 value);
template void NDArray::operator+=(const bfloat16 value); template ND4J_EXPORT void NDArray::operator+=(const bfloat16 value);
template void NDArray::operator+=(const Nd4jLong value); template ND4J_EXPORT void NDArray::operator+=(const Nd4jLong value);
template void NDArray::operator+=(const int value); template ND4J_EXPORT void NDArray::operator+=(const int value);
template void NDArray::operator+=(const bool value); template ND4J_EXPORT void NDArray::operator+=(const bool value);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
template<typename T> template<typename T>
@ -2282,13 +2282,13 @@ void NDArray::operator-=(const T value) {
NDArray::registerSpecialUse({this}, {}); NDArray::registerSpecialUse({this}, {});
} }
template void NDArray::operator-=(const double value); template ND4J_EXPORT void NDArray::operator-=(const double value);
template void NDArray::operator-=(const float value); template ND4J_EXPORT void NDArray::operator-=(const float value);
template void NDArray::operator-=(const float16 value); template ND4J_EXPORT void NDArray::operator-=(const float16 value);
template void NDArray::operator-=(const bfloat16 value); template ND4J_EXPORT void NDArray::operator-=(const bfloat16 value);
template void NDArray::operator-=(const Nd4jLong value); template ND4J_EXPORT void NDArray::operator-=(const Nd4jLong value);
template void NDArray::operator-=(const int value); template ND4J_EXPORT void NDArray::operator-=(const int value);
template void NDArray::operator-=(const bool value); template ND4J_EXPORT void NDArray::operator-=(const bool value);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
template<typename T> template<typename T>
@ -2302,16 +2302,16 @@ void NDArray::operator*=(const T scalar) {
NDArray::registerSpecialUse({this}, {}); NDArray::registerSpecialUse({this}, {});
} }
template void NDArray::operator*=(const double scalar); template ND4J_EXPORT void NDArray::operator*=(const double scalar);
template void NDArray::operator*=(const float scalar); template ND4J_EXPORT void NDArray::operator*=(const float scalar);
template void NDArray::operator*=(const float16 scalar); template ND4J_EXPORT void NDArray::operator*=(const float16 scalar);
template void NDArray::operator*=(const bfloat16 scalar); template ND4J_EXPORT void NDArray::operator*=(const bfloat16 scalar);
template void NDArray::operator*=(const Nd4jLong scalar); template ND4J_EXPORT void NDArray::operator*=(const Nd4jLong scalar);
template void NDArray::operator*=(const int scalar); template ND4J_EXPORT void NDArray::operator*=(const int scalar);
template void NDArray::operator*=(const int16_t scalar); template ND4J_EXPORT void NDArray::operator*=(const int16_t scalar);
template void NDArray::operator*=(const int8_t scalar); template ND4J_EXPORT void NDArray::operator*=(const int8_t scalar);
template void NDArray::operator*=(const uint8_t scalar); template ND4J_EXPORT void NDArray::operator*=(const uint8_t scalar);
template void NDArray::operator*=(const bool scalar); template ND4J_EXPORT void NDArray::operator*=(const bool scalar);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
template<typename T> template<typename T>
@ -2324,16 +2324,16 @@ void NDArray::operator/=(const T scalar) {
NativeOpExecutioner::execScalar(getContext(), nd4j::scalar::Divide, buffer(), getShapeInfo(), specialBuffer(), getSpecialShapeInfo(), buffer(), getShapeInfo(), specialBuffer(), getSpecialShapeInfo(), other.getBuffer(), other.getShapeInfo(), other.getSpecialBuffer(), other.getSpecialShapeInfo(), nullptr); NativeOpExecutioner::execScalar(getContext(), nd4j::scalar::Divide, buffer(), getShapeInfo(), specialBuffer(), getSpecialShapeInfo(), buffer(), getShapeInfo(), specialBuffer(), getSpecialShapeInfo(), other.getBuffer(), other.getShapeInfo(), other.getSpecialBuffer(), other.getSpecialShapeInfo(), nullptr);
NDArray::registerSpecialUse({this}, {}); NDArray::registerSpecialUse({this}, {});
} }
template void NDArray::operator/=(const double scalar); template ND4J_EXPORT void NDArray::operator/=(const double scalar);
template void NDArray::operator/=(const float scalar); template ND4J_EXPORT void NDArray::operator/=(const float scalar);
template void NDArray::operator/=(const float16 scalar); template ND4J_EXPORT void NDArray::operator/=(const float16 scalar);
template void NDArray::operator/=(const bfloat16 scalar); template ND4J_EXPORT void NDArray::operator/=(const bfloat16 scalar);
template void NDArray::operator/=(const Nd4jLong scalar); template ND4J_EXPORT void NDArray::operator/=(const Nd4jLong scalar);
template void NDArray::operator/=(const int scalar); template ND4J_EXPORT void NDArray::operator/=(const int scalar);
template void NDArray::operator/=(const int16_t scalar); template ND4J_EXPORT void NDArray::operator/=(const int16_t scalar);
template void NDArray::operator/=(const int8_t scalar); template ND4J_EXPORT void NDArray::operator/=(const int8_t scalar);
template void NDArray::operator/=(const uint8_t scalar); template ND4J_EXPORT void NDArray::operator/=(const uint8_t scalar);
template void NDArray::operator/=(const bool scalar); template ND4J_EXPORT void NDArray::operator/=(const bool scalar);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// subtraction operator array - array // subtraction operator array - array
@ -2929,7 +2929,7 @@ std::vector<T> NDArray::asVectorT() {
return result; return result;
} }
BUILD_SINGLE_TEMPLATE(template std::vector, NDArray::asVectorT(), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT std::vector, NDArray::asVectorT(), LIBND4J_TYPES);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// set new order and shape in case of suitable array length // set new order and shape in case of suitable array length
@ -3046,7 +3046,7 @@ template <typename T>
void NDArray::templatedSet(void *buffer, const Nd4jLong xOfsset, nd4j::DataType dtype, const void *value) { void NDArray::templatedSet(void *buffer, const Nd4jLong xOfsset, nd4j::DataType dtype, const void *value) {
BUILD_SINGLE_PARTIAL_SELECTOR(dtype, templatedSet< , T>(buffer, xOfsset, value), LIBND4J_TYPES); BUILD_SINGLE_PARTIAL_SELECTOR(dtype, templatedSet< , T>(buffer, xOfsset, value), LIBND4J_TYPES);
} }
BUILD_SINGLE_TEMPLATE(template void NDArray::templatedSet, (void *buffer, const Nd4jLong xOfsset, nd4j::DataType dtype, const void *value), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT void NDArray::templatedSet, (void *buffer, const Nd4jLong xOfsset, nd4j::DataType dtype, const void *value), LIBND4J_TYPES);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
void NDArray::applyPairwiseTransform(nd4j::pairwise::Ops op, const NDArray* other, NDArray *target, ExtraArguments *extraParams) const{ void NDArray::applyPairwiseTransform(nd4j::pairwise::Ops op, const NDArray* other, NDArray *target, ExtraArguments *extraParams) const{
@ -3109,7 +3109,7 @@ void NDArray::templatedDoubleAssign(void *xBuffer, const Nd4jLong xOffset, const
const auto y = reinterpret_cast<const Y *>(yBuffer); const auto y = reinterpret_cast<const Y *>(yBuffer);
x[xOffset] = static_cast<X>(y[yOffset]); x[xOffset] = static_cast<X>(y[yOffset]);
} }
BUILD_DOUBLE_TEMPLATE(template void NDArray::templatedDoubleAssign, (void *xBuffer, const Nd4jLong xOffset, const void *yBuffer, const Nd4jLong yOffset) const, LIBND4J_TYPES, LIBND4J_TYPES); BUILD_DOUBLE_TEMPLATE(template ND4J_EXPORT void NDArray::templatedDoubleAssign, (void *xBuffer, const Nd4jLong xOffset, const void *yBuffer, const Nd4jLong yOffset) const, LIBND4J_TYPES, LIBND4J_TYPES);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
void NDArray::varianceAlongDimension(nd4j::variance::Ops op, NDArray *target, const bool biasCorrected, const std::vector<int>& dimensions) const { void NDArray::varianceAlongDimension(nd4j::variance::Ops op, NDArray *target, const bool biasCorrected, const std::vector<int>& dimensions) const {
@ -3356,7 +3356,7 @@ T NDArray::e(const Nd4jLong i) const {
BUILD_SINGLE_PARTIAL_SELECTOR(dataType(), return templatedGet<, T>(getBuffer(), rp), LIBND4J_TYPES); BUILD_SINGLE_PARTIAL_SELECTOR(dataType(), return templatedGet<, T>(getBuffer(), rp), LIBND4J_TYPES);
} }
BUILD_SINGLE_UNCHAINED_TEMPLATE(template , NDArray::e(const Nd4jLong) const, LIBND4J_TYPES); BUILD_SINGLE_UNCHAINED_TEMPLATE(template ND4J_EXPORT , NDArray::e(const Nd4jLong) const, LIBND4J_TYPES);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Returns value from 2D matrix by coordinates/indexes // Returns value from 2D matrix by coordinates/indexes
@ -3376,7 +3376,7 @@ T NDArray::e(const Nd4jLong i, const Nd4jLong j) const {
return static_cast<T>(119); return static_cast<T>(119);
} }
BUILD_SINGLE_UNCHAINED_TEMPLATE(template , NDArray::e(const Nd4jLong, const Nd4jLong) const, LIBND4J_TYPES); BUILD_SINGLE_UNCHAINED_TEMPLATE(template ND4J_EXPORT , NDArray::e(const Nd4jLong, const Nd4jLong) const, LIBND4J_TYPES);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// returns value from 3D tensor by coordinates // returns value from 3D tensor by coordinates
@ -3396,7 +3396,7 @@ T NDArray::e(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k) const {
return static_cast<T>(119); return static_cast<T>(119);
} }
BUILD_SINGLE_UNCHAINED_TEMPLATE(template , NDArray::e(const Nd4jLong, const Nd4jLong, const Nd4jLong) const, LIBND4J_TYPES); BUILD_SINGLE_UNCHAINED_TEMPLATE(template ND4J_EXPORT , NDArray::e(const Nd4jLong, const Nd4jLong, const Nd4jLong) const, LIBND4J_TYPES);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// returns value from 3D tensor by coordinates // returns value from 3D tensor by coordinates
@ -3416,7 +3416,7 @@ T NDArray::e(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLon
return static_cast<T>(119); return static_cast<T>(119);
} }
BUILD_SINGLE_UNCHAINED_TEMPLATE(template , NDArray::e(const Nd4jLong, const Nd4jLong, const Nd4jLong, const Nd4jLong) const, LIBND4J_TYPES); BUILD_SINGLE_UNCHAINED_TEMPLATE(template ND4J_EXPORT , NDArray::e(const Nd4jLong, const Nd4jLong, const Nd4jLong, const Nd4jLong) const, LIBND4J_TYPES);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
NDArray NDArray::e(const Nd4jLong i) const { NDArray NDArray::e(const Nd4jLong i) const {
@ -3591,17 +3591,17 @@ void NDArray::applyScalar(nd4j::scalar::Ops op, const T scalar, NDArray *target,
applyScalarArr(op, &scalarArr, target, extraParams); applyScalarArr(op, &scalarArr, target, extraParams);
} }
template <> void NDArray::applyScalar(nd4j::scalar::Ops op, const NDArray* scalar, NDArray *target, ExtraArguments *extraParams) { throw std::runtime_error("NDArray::applyScalar<NDArray*> method: do not use me!");} template <> ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::Ops op, const NDArray* scalar, NDArray *target, ExtraArguments *extraParams) { throw std::runtime_error("NDArray::applyScalar<NDArray*> method: do not use me!");}
template void NDArray::applyScalar(nd4j::scalar::Ops op, const double scalar, NDArray *target, ExtraArguments *extraParams); template ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::Ops op, const double scalar, NDArray *target, ExtraArguments *extraParams);
template void NDArray::applyScalar(nd4j::scalar::Ops op, const float scalar, NDArray *target, ExtraArguments *extraParams); template ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::Ops op, const float scalar, NDArray *target, ExtraArguments *extraParams);
template void NDArray::applyScalar(nd4j::scalar::Ops op, const float16 scalar, NDArray *target, ExtraArguments *extraParams); template ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::Ops op, const float16 scalar, NDArray *target, ExtraArguments *extraParams);
template void NDArray::applyScalar(nd4j::scalar::Ops op, const bfloat16 scalar, NDArray *target, ExtraArguments *extraParams); template ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::Ops op, const bfloat16 scalar, NDArray *target, ExtraArguments *extraParams);
template void NDArray::applyScalar(nd4j::scalar::Ops op, const Nd4jLong scalar, NDArray *target, ExtraArguments *extraParams); template ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::Ops op, const Nd4jLong scalar, NDArray *target, ExtraArguments *extraParams);
template void NDArray::applyScalar(nd4j::scalar::Ops op, const int scalar, NDArray *target, ExtraArguments *extraParams); template ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::Ops op, const int scalar, NDArray *target, ExtraArguments *extraParams);
template void NDArray::applyScalar(nd4j::scalar::Ops op, const int16_t scalar, NDArray *target, ExtraArguments *extraParams); template ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::Ops op, const int16_t scalar, NDArray *target, ExtraArguments *extraParams);
template void NDArray::applyScalar(nd4j::scalar::Ops op, const int8_t scalar, NDArray *target, ExtraArguments *extraParams); template ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::Ops op, const int8_t scalar, NDArray *target, ExtraArguments *extraParams);
template void NDArray::applyScalar(nd4j::scalar::Ops op, const uint8_t scalar, NDArray *target, ExtraArguments *extraParams); template ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::Ops op, const uint8_t scalar, NDArray *target, ExtraArguments *extraParams);
template void NDArray::applyScalar(nd4j::scalar::Ops op, const bool scalar, NDArray *target, ExtraArguments *extraParams); template ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::Ops op, const bool scalar, NDArray *target, ExtraArguments *extraParams);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void NDArray::applyScalarArr(nd4j::scalar::BoolOps op, const NDArray* scalar, NDArray *target, ExtraArguments *extraParams) const { void NDArray::applyScalarArr(nd4j::scalar::BoolOps op, const NDArray* scalar, NDArray *target, ExtraArguments *extraParams) const {
@ -3627,17 +3627,17 @@ void NDArray::applyScalar(nd4j::scalar::BoolOps op, const T scalar, NDArray *tar
applyScalarArr(op, &scalarArr, target, extraParams); applyScalarArr(op, &scalarArr, target, extraParams);
} }
template <> void NDArray::applyScalar(nd4j::scalar::BoolOps op, const NDArray* scalar, NDArray *target, ExtraArguments *extraParams) const { throw std::runtime_error("NDArray::applyScalar<NDArray*> method: do not use me!");} template <> ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::BoolOps op, const NDArray* scalar, NDArray *target, ExtraArguments *extraParams) const { throw std::runtime_error("NDArray::applyScalar<NDArray*> method: do not use me!");}
template void NDArray::applyScalar<double>(nd4j::scalar::BoolOps op, const double scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<double>(nd4j::scalar::BoolOps op, const double scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<float>(nd4j::scalar::BoolOps op, const float scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<float>(nd4j::scalar::BoolOps op, const float scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<float16>(nd4j::scalar::BoolOps op, const float16 scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<float16>(nd4j::scalar::BoolOps op, const float16 scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<bfloat16>(nd4j::scalar::BoolOps op, const bfloat16 scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<bfloat16>(nd4j::scalar::BoolOps op, const bfloat16 scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<Nd4jLong>(nd4j::scalar::BoolOps op, const Nd4jLong scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<Nd4jLong>(nd4j::scalar::BoolOps op, const Nd4jLong scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<int>(nd4j::scalar::BoolOps op, const int scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<int>(nd4j::scalar::BoolOps op, const int scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<int16_t>(nd4j::scalar::BoolOps op, const int16_t scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<int16_t>(nd4j::scalar::BoolOps op, const int16_t scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<int8_t>(nd4j::scalar::BoolOps op, const int8_t scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<int8_t>(nd4j::scalar::BoolOps op, const int8_t scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<uint8_t>(nd4j::scalar::BoolOps op, const uint8_t scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<uint8_t>(nd4j::scalar::BoolOps op, const uint8_t scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<bool>(nd4j::scalar::BoolOps op, const bool scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<bool>(nd4j::scalar::BoolOps op, const bool scalar, NDArray *target, ExtraArguments *extraParams) const;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -3665,17 +3665,17 @@ template void NDArray::applyScalar<bool>(nd4j::scalar::BoolOps op, const bool sc
applyScalarArr(op, &scalarArr, target, extraParams); applyScalarArr(op, &scalarArr, target, extraParams);
} }
template <> void NDArray::applyScalar(nd4j::scalar::IntOps op, const NDArray* scalar, NDArray *target, ExtraArguments *extraParams) const { throw std::runtime_error("NDArray::applyScalar<NDArray*> method: do not use me!");} template <> ND4J_EXPORT void NDArray::applyScalar(nd4j::scalar::IntOps op, const NDArray* scalar, NDArray *target, ExtraArguments *extraParams) const { throw std::runtime_error("NDArray::applyScalar<NDArray*> method: do not use me!");}
template void NDArray::applyScalar<double>(nd4j::scalar::IntOps op, const double scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<double>(nd4j::scalar::IntOps op, const double scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<float>(nd4j::scalar::IntOps op, const float scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<float>(nd4j::scalar::IntOps op, const float scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<float16>(nd4j::scalar::IntOps op, const float16 scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<float16>(nd4j::scalar::IntOps op, const float16 scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<bfloat16>(nd4j::scalar::IntOps op, const bfloat16 scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<bfloat16>(nd4j::scalar::IntOps op, const bfloat16 scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<Nd4jLong>(nd4j::scalar::IntOps op, const Nd4jLong scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<Nd4jLong>(nd4j::scalar::IntOps op, const Nd4jLong scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<int>(nd4j::scalar::IntOps op, const int scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<int>(nd4j::scalar::IntOps op, const int scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<int16_t>(nd4j::scalar::IntOps op, const int16_t scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<int16_t>(nd4j::scalar::IntOps op, const int16_t scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<int8_t>(nd4j::scalar::IntOps op, const int8_t scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<int8_t>(nd4j::scalar::IntOps op, const int8_t scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<uint8_t>(nd4j::scalar::IntOps op, const uint8_t scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<uint8_t>(nd4j::scalar::IntOps op, const uint8_t scalar, NDArray *target, ExtraArguments *extraParams) const;
template void NDArray::applyScalar<bool>(nd4j::scalar::IntOps op, const bool scalar, NDArray *target, ExtraArguments *extraParams) const; template ND4J_EXPORT void NDArray::applyScalar<bool>(nd4j::scalar::IntOps op, const bool scalar, NDArray *target, ExtraArguments *extraParams) const;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -3966,19 +3966,19 @@ void NDArray::p(const Nd4jLong i, const T value) {
NDArray::registerPrimaryUse({this}, {}); NDArray::registerPrimaryUse({this}, {});
} }
template void NDArray::p(const Nd4jLong i, const double value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const double value);
template void NDArray::p(const Nd4jLong i, const float value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const float value);
template void NDArray::p(const Nd4jLong i, const float16 value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const float16 value);
template void NDArray::p(const Nd4jLong i, const bfloat16 value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const bfloat16 value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong value);
template void NDArray::p(const Nd4jLong i, const int value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const int value);
template void NDArray::p(const Nd4jLong i, const int8_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const int8_t value);
template void NDArray::p(const Nd4jLong i, const uint8_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const uint8_t value);
template void NDArray::p(const Nd4jLong i, const uint16_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const uint16_t value);
template void NDArray::p(const Nd4jLong i, const uint32_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const uint32_t value);
template void NDArray::p(const Nd4jLong i, const uint64_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const uint64_t value);
template void NDArray::p(const Nd4jLong i, const int16_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const int16_t value);
template void NDArray::p(const Nd4jLong i, const bool value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const bool value);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// This method sets value in 2D matrix to position i, j // This method sets value in 2D matrix to position i, j
@ -3996,19 +3996,19 @@ void NDArray::p(const Nd4jLong i, const Nd4jLong j, const T value) {
BUILD_SINGLE_PARTIAL_SELECTOR(dataType(), templatedSet<, T>(this->getBuffer(), xOffset, p), LIBND4J_TYPES); BUILD_SINGLE_PARTIAL_SELECTOR(dataType(), templatedSet<, T>(this->getBuffer(), xOffset, p), LIBND4J_TYPES);
NDArray::registerPrimaryUse({this}, {}); NDArray::registerPrimaryUse({this}, {});
} }
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const double value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const double value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const float value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const float value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const float16 value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const float16 value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const bfloat16 value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const bfloat16 value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const int value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const int value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const int8_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const int8_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const uint8_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const uint8_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const uint16_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const uint16_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const uint32_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const uint32_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const uint64_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const uint64_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const int16_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const int16_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const bool value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const bool value);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// This method sets value in 3D matrix to position i,j,k // This method sets value in 3D matrix to position i,j,k
@ -4026,19 +4026,19 @@ void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const T va
BUILD_SINGLE_PARTIAL_SELECTOR(dataType(), templatedSet<, T>(this->getBuffer(), xOffset, p), LIBND4J_TYPES); BUILD_SINGLE_PARTIAL_SELECTOR(dataType(), templatedSet<, T>(this->getBuffer(), xOffset, p), LIBND4J_TYPES);
NDArray::registerPrimaryUse({this}, {}); NDArray::registerPrimaryUse({this}, {});
} }
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const double value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const double value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const float value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const float value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const float16 value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const float16 value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const bfloat16 value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const bfloat16 value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const int value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const int value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const int8_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const int8_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const uint8_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const uint8_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const uint16_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const uint16_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const uint32_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const uint32_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const uint64_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const uint64_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const int16_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const int16_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const bool value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const bool value);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
template <typename T> template <typename T>
@ -4055,19 +4055,19 @@ void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4j
BUILD_SINGLE_PARTIAL_SELECTOR(dataType(), templatedSet<, T>(this->getBuffer(), xOffset, p), LIBND4J_TYPES); BUILD_SINGLE_PARTIAL_SELECTOR(dataType(), templatedSet<, T>(this->getBuffer(), xOffset, p), LIBND4J_TYPES);
NDArray::registerPrimaryUse({this}, {}); NDArray::registerPrimaryUse({this}, {});
} }
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const double value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const double value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const float value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const float value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const float16 value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const float16 value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const bfloat16 value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const bfloat16 value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const Nd4jLong value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const Nd4jLong value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const int value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const int value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const int8_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const int8_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const uint8_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const uint8_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const uint16_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const uint16_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const uint32_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const uint32_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const uint64_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const uint64_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const int16_t value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const int16_t value);
template void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const bool value); template ND4J_EXPORT void NDArray::p(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k, const Nd4jLong l, const bool value);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
void NDArray::p(const Nd4jLong i, const NDArray& scalar) { void NDArray::p(const Nd4jLong i, const NDArray& scalar) {
@ -4256,7 +4256,7 @@ void NDArray::templatedAssign(void *xBuffer, Nd4jLong xOffset, const void *yBuff
if (xBuffer != nullptr && yBuffer != nullptr) if (xBuffer != nullptr && yBuffer != nullptr)
*(reinterpret_cast<T*>(xBuffer) + xOffset) = *(reinterpret_cast<const T*>(yBuffer) + yOffset); *(reinterpret_cast<T*>(xBuffer) + xOffset) = *(reinterpret_cast<const T*>(yBuffer) + yOffset);
} }
BUILD_SINGLE_TEMPLATE(template void NDArray::templatedAssign, (void *xBuffer, const Nd4jLong xOffset, const void *yBuffer, const Nd4jLong yOffset) const, LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT void NDArray::templatedAssign, (void *xBuffer, const Nd4jLong xOffset, const void *yBuffer, const Nd4jLong yOffset) const, LIBND4J_TYPES);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -29,7 +29,7 @@ namespace nd4j {
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
template <> template <>
NDArray NDArrayFactory::create<bool>(const char order, const std::vector<Nd4jLong> &shape, const std::vector<bool> &data, nd4j::LaunchContext * context) { ND4J_EXPORT NDArray NDArrayFactory::create<bool>(const char order, const std::vector<Nd4jLong> &shape, const std::vector<bool> &data, nd4j::LaunchContext * context) {
if ((int) shape.size() > MAX_RANK) if ((int) shape.size() > MAX_RANK)
throw std::invalid_argument("NDArrayFactory::create: rank of NDArray can't exceed 32 !"); throw std::invalid_argument("NDArrayFactory::create: rank of NDArray can't exceed 32 !");
@ -71,8 +71,19 @@ namespace nd4j {
NDArray result(buffer, descriptor, context); NDArray result(buffer, descriptor, context);
return result; return result;
} }
template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::vector<double>& data, nd4j::LaunchContext * context);
template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::vector<float>& data, nd4j::LaunchContext * context);
template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::vector<float16>& data, nd4j::LaunchContext * context);
template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::vector<bfloat16>& data, nd4j::LaunchContext * context);
template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::vector<Nd4jLong>& data, nd4j::LaunchContext * context);
template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::vector<uint64_t>& data, nd4j::LaunchContext * context);
template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::vector<int>& data, nd4j::LaunchContext * context);
template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::vector<unsigned int>& data, nd4j::LaunchContext * context);
template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::vector<int16_t>& data, nd4j::LaunchContext * context);
template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::vector<int8_t>& data, nd4j::LaunchContext * context);
template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::vector<uint8_t>& data, nd4j::LaunchContext * context);
template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::vector<bool>& data, nd4j::LaunchContext * context);
NDArray NDArrayFactory::string(const char *str, nd4j::LaunchContext * context) { NDArray NDArrayFactory::string(const char *str, nd4j::LaunchContext * context) {
std::string s(str); std::string s(str);
@ -118,7 +129,7 @@ template<typename T>
NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, nd4j::LaunchContext * context) { NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, nd4j::LaunchContext * context) {
return create_(order, shape, DataTypeUtils::fromT<T>(), context); return create_(order, shape, DataTypeUtils::fromT<T>(), context);
} }
BUILD_SINGLE_TEMPLATE(template NDArray* NDArrayFactory::create_, (const char order, const std::vector<Nd4jLong> &shape, nd4j::LaunchContext * context), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT NDArray* NDArrayFactory::create_, (const char order, const std::vector<Nd4jLong> &shape, nd4j::LaunchContext * context), LIBND4J_TYPES);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
template <typename T> template <typename T>
@ -128,20 +139,20 @@ void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<T> &vector) {
} }
template <> template <>
void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<bool> &vector) { void ND4J_EXPORT NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<bool> &vector) {
auto p = reinterpret_cast<bool *>(ptr); auto p = reinterpret_cast<bool *>(ptr);
for (Nd4jLong e = 0; e < vector.size(); e++) for (Nd4jLong e = 0; e < vector.size(); e++)
p[e] = vector[e]; p[e] = vector[e];
} }
template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<double> &vector); template ND4J_EXPORT void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<double> &vector);
template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<float> &vector); template ND4J_EXPORT void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<float> &vector);
template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<float16> &vector); template ND4J_EXPORT void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<float16> &vector);
template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<Nd4jLong> &vector); template ND4J_EXPORT void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<Nd4jLong> &vector);
template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<int> &vector); template ND4J_EXPORT void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<int> &vector);
template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<int16_t> &vector); template ND4J_EXPORT void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<int16_t> &vector);
template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<uint8_t> &vector); template ND4J_EXPORT void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<uint8_t> &vector);
template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<int8_t> &vector); template ND4J_EXPORT void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<int8_t> &vector);
#ifndef __JAVACPP_HACK__ #ifndef __JAVACPP_HACK__
@ -150,16 +161,16 @@ template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<int8
NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const T value, const char order, nd4j::LaunchContext * context) { NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const T value, const char order, nd4j::LaunchContext * context) {
return valueOf(std::vector<Nd4jLong>(shape), value, order); return valueOf(std::vector<Nd4jLong>(shape), value, order);
} }
template NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const double value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const double value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const float value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const float value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const float16 value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const float16 value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const bfloat16 value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const bfloat16 value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const Nd4jLong value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const Nd4jLong value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const int value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const int value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const uint8_t value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const uint8_t value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const int8_t value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const int8_t value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const int16_t value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const int16_t value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const bool value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::initializer_list<Nd4jLong>& shape, const bool value, const char order, nd4j::LaunchContext * context);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
template <typename T> template <typename T>
@ -167,18 +178,18 @@ template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<int8
std::vector<T> vec(data); std::vector<T> vec(data);
return create<T>(order, shape, vec, context); return create<T>(order, shape, vec, context);
} }
template NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<double>& data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<double>& data, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<float>& data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<float>& data, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<float16>& data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<float16>& data, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<bfloat16>& data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<bfloat16>& data, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<Nd4jLong>& data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<Nd4jLong>& data, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<uint64_t>& data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<uint64_t>& data, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<int>& data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<int>& data, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<unsigned int>& data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<unsigned int>& data, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<int16_t>& data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<int16_t>& data, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<int8_t>& data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<int8_t>& data, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<uint8_t>& data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<uint8_t>& data, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<bool>& data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<bool>& data, nd4j::LaunchContext * context);
#endif #endif
@ -197,19 +208,19 @@ template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<int8
return res; return res;
} }
template NDArray* NDArrayFactory::create_(const double scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const double scalar, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const float scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const float scalar, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const float16 scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const float16 scalar, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const bfloat16 scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const bfloat16 scalar, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const Nd4jLong scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const Nd4jLong scalar, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const int scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const int scalar, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const bool scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const bool scalar, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const int8_t scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const int8_t scalar, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const uint8_t scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const uint8_t scalar, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const uint16_t scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const uint16_t scalar, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const uint32_t scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const uint32_t scalar, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const uint64_t scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const uint64_t scalar, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const int16_t scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const int16_t scalar, nd4j::LaunchContext * context);
template <typename T> template <typename T>
NDArray NDArrayFactory::create(nd4j::DataType type, const T scalar, nd4j::LaunchContext * context) { NDArray NDArrayFactory::create(nd4j::DataType type, const T scalar, nd4j::LaunchContext * context) {
@ -223,20 +234,20 @@ template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<int8
return res; return res;
} }
// BUILD_DOUBLE_TEMPLATE(template NDArray NDArrayFactory::create, (DataType type, const T scalar, nd4j::LaunchContext * context), LIBND4J_TYPES); // BUILD_DOUBLE_TEMPLATE(template ND4J_EXPORT NDArray NDArrayFactory::create, (DataType type, const T scalar, nd4j::LaunchContext * context), LIBND4J_TYPES);
template NDArray NDArrayFactory::create(DataType type, const double scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const double scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(DataType type, const float scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const float scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(DataType type, const float16 scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const float16 scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(DataType type, const bfloat16 scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const bfloat16 scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(DataType type, const Nd4jLong scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const Nd4jLong scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(DataType type, const int scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const int scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(DataType type, const int8_t scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const int8_t scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(DataType type, const uint8_t scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const uint8_t scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(DataType type, const uint16_t scalar, nd4j::LaunchContext* workspace); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const uint16_t scalar, nd4j::LaunchContext* workspace);
template NDArray NDArrayFactory::create(DataType type, const uint32_t scalar, nd4j::LaunchContext* workspace); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const uint32_t scalar, nd4j::LaunchContext* workspace);
template NDArray NDArrayFactory::create(DataType type, const uint64_t scalar, nd4j::LaunchContext* workspace); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const uint64_t scalar, nd4j::LaunchContext* workspace);
template NDArray NDArrayFactory::create(DataType type, const int16_t scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const int16_t scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(DataType type, const bool scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(DataType type, const bool scalar, nd4j::LaunchContext * context);
template <typename T> template <typename T>
NDArray NDArrayFactory::create(const T scalar, nd4j::LaunchContext * context) { NDArray NDArrayFactory::create(const T scalar, nd4j::LaunchContext * context) {
@ -252,19 +263,19 @@ template void NDArrayFactory::memcpyFromVector(void *ptr, const std::vector<int8
return res; return res;
} }
template NDArray NDArrayFactory::create(const double scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const double scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const float scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const float scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const float16 scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const float16 scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const bfloat16 scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const bfloat16 scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const Nd4jLong scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const Nd4jLong scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const int scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const int scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const int8_t scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const int8_t scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const uint8_t scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const uint8_t scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const int16_t scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const int16_t scalar, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const uint16_t scalar, nd4j::LaunchContext* workspace); template ND4J_EXPORT NDArray NDArrayFactory::create(const uint16_t scalar, nd4j::LaunchContext* workspace);
template NDArray NDArrayFactory::create(const uint32_t scalar, nd4j::LaunchContext* workspace); template ND4J_EXPORT NDArray NDArrayFactory::create(const uint32_t scalar, nd4j::LaunchContext* workspace);
template NDArray NDArrayFactory::create(const uint64_t scalar, nd4j::LaunchContext* workspace); template ND4J_EXPORT NDArray NDArrayFactory::create(const uint64_t scalar, nd4j::LaunchContext* workspace);
template NDArray NDArrayFactory::create(const bool scalar, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const bool scalar, nd4j::LaunchContext * context);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -273,31 +284,31 @@ NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &
return new NDArray(NDArrayFactory::create<T>(order, shape, data, context)); return new NDArray(NDArrayFactory::create<T>(order, shape, data, context));
} }
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<double> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<double> &data, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<float> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<float> &data, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<float16> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<float16> &data, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<bfloat16> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<bfloat16> &data, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<int> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<int> &data, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<unsigned int> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<unsigned int> &data, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<unsigned long> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<unsigned long> &data, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<Nd4jLong> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<Nd4jLong> &data, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<int8_t> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<int8_t> &data, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<uint8_t> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<uint8_t> &data, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<int16_t> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<int16_t> &data, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<uint16_t> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<uint16_t> &data, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<bool> &data, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd4jLong> &shape, const std::vector<bool> &data, nd4j::LaunchContext * context);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
template <> template <>
NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, NDArray* value, const char order, nd4j::LaunchContext * context) { ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, NDArray* value, const char order, nd4j::LaunchContext * context) {
auto result = create_(order, shape, value->dataType(), context); auto result = create_(order, shape, value->dataType(), context);
result->assign(*value); result->assign(*value);
return result; return result;
} }
template <> template <>
NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, NDArray& value, const char order, nd4j::LaunchContext * context) { ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, NDArray& value, const char order, nd4j::LaunchContext * context) {
auto result = create_(order, shape, value.dataType(), context); auto result = create_(order, shape, value.dataType(), context);
result->assign(value); result->assign(value);
return result; return result;
@ -309,16 +320,16 @@ template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd
result->assign(value); result->assign(value);
return result; return result;
} }
template NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const double value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const double value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const float value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const float value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const float16 value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const float16 value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const bfloat16 value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const bfloat16 value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const Nd4jLong value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const Nd4jLong value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const int value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const int value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const int16_t value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const int16_t value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const int8_t value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const int8_t value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const uint8_t value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const uint8_t value, const char order, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const bool value, const char order, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::valueOf(const std::vector<Nd4jLong>& shape, const bool value, const char order, nd4j::LaunchContext * context);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -334,19 +345,19 @@ template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd
return result; return result;
} }
template NDArray* NDArrayFactory::linspace(const double from, const double to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const double from, const double to, const Nd4jLong numElements);
template NDArray* NDArrayFactory::linspace(const float from, const float to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const float from, const float to, const Nd4jLong numElements);
template NDArray* NDArrayFactory::linspace(const float16 from, const float16 to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const float16 from, const float16 to, const Nd4jLong numElements);
template NDArray* NDArrayFactory::linspace(const bfloat16 from, const bfloat16 to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const bfloat16 from, const bfloat16 to, const Nd4jLong numElements);
template NDArray* NDArrayFactory::linspace(const Nd4jLong from, const Nd4jLong to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const Nd4jLong from, const Nd4jLong to, const Nd4jLong numElements);
template NDArray* NDArrayFactory::linspace(const int from, const int to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const int from, const int to, const Nd4jLong numElements);
template NDArray* NDArrayFactory::linspace(const int16_t from, const int16_t to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const int16_t from, const int16_t to, const Nd4jLong numElements);
template NDArray* NDArrayFactory::linspace(const uint8_t from, const uint8_t to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const uint8_t from, const uint8_t to, const Nd4jLong numElements);
template NDArray* NDArrayFactory::linspace(const uint16_t from, const uint16_t to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const uint16_t from, const uint16_t to, const Nd4jLong numElements);
template NDArray* NDArrayFactory::linspace(const uint32_t from, const uint32_t to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const uint32_t from, const uint32_t to, const Nd4jLong numElements);
template NDArray* NDArrayFactory::linspace(const uint64_t from, const uint64_t to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const uint64_t from, const uint64_t to, const Nd4jLong numElements);
template NDArray* NDArrayFactory::linspace(const int8_t from, const int8_t to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const int8_t from, const int8_t to, const Nd4jLong numElements);
template NDArray* NDArrayFactory::linspace(const bool from, const bool to, const Nd4jLong numElements); template ND4J_EXPORT NDArray* NDArrayFactory::linspace(const bool from, const bool to, const Nd4jLong numElements);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
template <typename T> template <typename T>
@ -363,19 +374,19 @@ template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd
return res; return res;
} }
template NDArray* NDArrayFactory::vector(Nd4jLong length, const double startingValue, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const double startingValue, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::vector(Nd4jLong length, const float startingValue, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const float startingValue, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::vector(Nd4jLong length, const float16 startingValue, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const float16 startingValue, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::vector(Nd4jLong length, const bfloat16 startingValue, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const bfloat16 startingValue, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::vector(Nd4jLong length, const Nd4jLong startingValue, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const Nd4jLong startingValue, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::vector(Nd4jLong length, const int startingValue, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const int startingValue, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::vector(Nd4jLong length, const uint8_t startingValue, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const uint8_t startingValue, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::vector(Nd4jLong length, const uint16_t startingValue, nd4j::LaunchContext *workspace); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const uint16_t startingValue, nd4j::LaunchContext *workspace);
template NDArray* NDArrayFactory::vector(Nd4jLong length, const uint32_t startingValue, nd4j::LaunchContext *workspace); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const uint32_t startingValue, nd4j::LaunchContext *workspace);
template NDArray* NDArrayFactory::vector(Nd4jLong length, const uint64_t startingValue, nd4j::LaunchContext *workspace); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const uint64_t startingValue, nd4j::LaunchContext *workspace);
template NDArray* NDArrayFactory::vector(Nd4jLong length, const int8_t startingValue, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const int8_t startingValue, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::vector(Nd4jLong length, const int16_t startingValue, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const int16_t startingValue, nd4j::LaunchContext * context);
template NDArray* NDArrayFactory::vector(Nd4jLong length, const bool startingValue, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray* NDArrayFactory::vector(Nd4jLong length, const bool startingValue, nd4j::LaunchContext * context);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
template <typename T> template <typename T>
@ -383,14 +394,14 @@ template NDArray* NDArrayFactory::create_(const char order, const std::vector<Nd
std::vector<Nd4jLong> vec(shape); std::vector<Nd4jLong> vec(shape);
return create<T>(order, vec, context); return create<T>(order, vec, context);
} }
BUILD_SINGLE_TEMPLATE(template NDArray NDArrayFactory::create, (const char, const std::initializer_list<Nd4jLong>&, nd4j::LaunchContext * context), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT NDArray NDArrayFactory::create, (const char, const std::initializer_list<Nd4jLong>&, nd4j::LaunchContext * context), LIBND4J_TYPES);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
template <typename T> template <typename T>
NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, nd4j::LaunchContext * context) { NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, nd4j::LaunchContext * context) {
return create(order, shape, DataTypeUtils::fromT<T>(), context); return create(order, shape, DataTypeUtils::fromT<T>(), context);
} }
BUILD_SINGLE_TEMPLATE(template NDArray NDArrayFactory::create, (const char order, const std::vector<Nd4jLong> &shape, nd4j::LaunchContext * context), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT NDArray NDArrayFactory::create, (const char order, const std::vector<Nd4jLong> &shape, nd4j::LaunchContext * context), LIBND4J_TYPES);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, nd4j::DataType dtype, nd4j::LaunchContext* context) { NDArray NDArrayFactory::create(const char order, const std::vector<Nd4jLong> &shape, nd4j::DataType dtype, nd4j::LaunchContext* context) {
@ -443,17 +454,17 @@ NDArray NDArrayFactory::create(const std::vector<T> &values, nd4j::LaunchContext
return res; return res;
} }
template NDArray NDArrayFactory::create(const std::vector<double> &values, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const std::vector<double> &values, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const std::vector<float> &values, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const std::vector<float> &values, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const std::vector<float16> &values, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const std::vector<float16> &values, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const std::vector<bfloat16> &values, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const std::vector<bfloat16> &values, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const std::vector<Nd4jLong> &values, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const std::vector<Nd4jLong> &values, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const std::vector<int> &values, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const std::vector<int> &values, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const std::vector<int16_t> &values, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const std::vector<int16_t> &values, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const std::vector<uint16_t> &values, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const std::vector<uint16_t> &values, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const std::vector<int8_t> &values, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const std::vector<int8_t> &values, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const std::vector<uint8_t> &values, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const std::vector<uint8_t> &values, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(const std::vector<bool> &values, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(const std::vector<bool> &values, nd4j::LaunchContext * context);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
template <typename T> template <typename T>
@ -466,7 +477,7 @@ template NDArray NDArrayFactory::create(const std::vector<bool> &values, nd4j::L
return result; return result;
} }
BUILD_SINGLE_TEMPLATE(template NDArray* NDArrayFactory::empty_, (nd4j::LaunchContext * context), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT NDArray* NDArrayFactory::empty_, (nd4j::LaunchContext * context), LIBND4J_TYPES);
NDArray* NDArrayFactory::empty_(nd4j::DataType dataType, nd4j::LaunchContext * context) { NDArray* NDArrayFactory::empty_(nd4j::DataType dataType, nd4j::LaunchContext * context) {
if (context == nullptr) if (context == nullptr)
@ -486,7 +497,7 @@ template NDArray NDArrayFactory::create(const std::vector<bool> &values, nd4j::L
NDArray NDArrayFactory::empty(nd4j::LaunchContext * context) { NDArray NDArrayFactory::empty(nd4j::LaunchContext * context) {
return empty(DataTypeUtils::fromT<T>(), context); return empty(DataTypeUtils::fromT<T>(), context);
} }
BUILD_SINGLE_TEMPLATE(template NDArray NDArrayFactory::empty, (nd4j::LaunchContext * context), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT NDArray NDArrayFactory::empty, (nd4j::LaunchContext * context), LIBND4J_TYPES);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
NDArray NDArrayFactory::empty(nd4j::DataType dataType, nd4j::LaunchContext * context) { NDArray NDArrayFactory::empty(nd4j::DataType dataType, nd4j::LaunchContext * context) {
@ -529,16 +540,16 @@ NDArray NDArrayFactory::create(T* buffer, const char order, const std::initializ
return result; return result;
} }
template NDArray NDArrayFactory::create(double* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(double* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(float* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(float* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(float16* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(float16* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(bfloat16* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(bfloat16* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(Nd4jLong * buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(Nd4jLong * buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(int* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(int* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(bool* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(bool* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(uint8_t * buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(uint8_t * buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(int8_t* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(int8_t* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context);
template NDArray NDArrayFactory::create(int16_t* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context); template ND4J_EXPORT NDArray NDArrayFactory::create(int16_t* buffer, const char order, const std::initializer_list<Nd4jLong>& shape, nd4j::LaunchContext * context);
NDArray NDArrayFactory::string(char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<const char *> &strings, nd4j::LaunchContext * context) { NDArray NDArrayFactory::string(char order, const std::vector<Nd4jLong> &shape, const std::initializer_list<const char *> &strings, nd4j::LaunchContext * context) {

View File

@ -150,7 +150,7 @@ void NDArray::fillAsTriangular(const float val, int lower, int upper, const char
manager.synchronize(); manager.synchronize();
} }
BUILD_SINGLE_TEMPLATE(template void NDArray::fillAsTriangular, (const float val, int lower, int upper, const char direction, NDArray* target), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT void NDArray::fillAsTriangular, (const float val, int lower, int upper, const char direction, NDArray* target), LIBND4J_TYPES);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
template<typename T> template<typename T>

View File

@ -291,16 +291,9 @@ case "$OS" in
;; ;;
macosx*) macosx*)
# Do something under Mac OS X platform
#if [ "$CHIP" == "cuda" ]; then
export CC=clang export CC=clang
export CXX=clang++ export CXX=clang++
PARALLEL="true" PARALLEL="true"
#else
# export CC="$(ls -1 /usr/local/bin/gcc-? | head -n 1)"
# export CXX="$(ls -1 /usr/local/bin/g++-? | head -n 1)"
# PARALLEL="true"
#fi
export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_MACOSX_RPATH=ON -DAPPLE_BUILD=true" export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_MACOSX_RPATH=ON -DAPPLE_BUILD=true"
;; ;;

View File

@ -89,7 +89,7 @@ namespace nd4j {
delete[] target; delete[] target;
#endif #endif
} }
BUILD_SINGLE_TEMPLATE(template void ExtraArguments::convertAndCopy, (Nd4jPointer pointer, Nd4jLong offset), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT void ExtraArguments::convertAndCopy, (Nd4jPointer pointer, Nd4jLong offset), LIBND4J_TYPES);
void* ExtraArguments::allocate(size_t length, size_t elementSize) { void* ExtraArguments::allocate(size_t length, size_t elementSize) {
#ifdef __CUDABLAS__ #ifdef __CUDABLAS__
@ -119,7 +119,7 @@ namespace nd4j {
void* ExtraArguments::argumentsAsT(Nd4jLong offset) { void* ExtraArguments::argumentsAsT(Nd4jLong offset) {
return argumentsAsT(DataTypeUtils::fromT<T>(), offset); return argumentsAsT(DataTypeUtils::fromT<T>(), offset);
} }
BUILD_SINGLE_TEMPLATE(template void *ExtraArguments::argumentsAsT, (Nd4jLong offset), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT void *ExtraArguments::argumentsAsT, (Nd4jLong offset), LIBND4J_TYPES);
void* ExtraArguments::argumentsAsT(nd4j::DataType dataType, Nd4jLong offset) { void* ExtraArguments::argumentsAsT(nd4j::DataType dataType, Nd4jLong offset) {

View File

@ -24,9 +24,17 @@
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <pointercast.h> #include <pointercast.h>
#include <dll.h>
#if defined(_MSC_VER)
// we're ignoring warning about non-exportable parent class, since std::runtime_error is a part of Standard C++ Library
#pragma warning( disable : 4275 )
#endif
namespace nd4j { namespace nd4j {
class allocation_exception : public std::runtime_error { class ND4J_EXPORT allocation_exception : public std::runtime_error {
public: public:
allocation_exception(std::string message); allocation_exception(std::string message);
~allocation_exception() = default; ~allocation_exception() = default;

View File

@ -23,9 +23,17 @@
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <dll.h>
#if defined(_MSC_VER)
// we're ignoring warning about non-exportable parent class, since std::runtime_error is a part of Standard C++ Library
#pragma warning( disable : 4275 )
#endif
namespace nd4j { namespace nd4j {
class cuda_exception : public std::runtime_error { class ND4J_EXPORT cuda_exception : public std::runtime_error {
public: public:
cuda_exception(std::string message); cuda_exception(std::string message);
~cuda_exception() = default; ~cuda_exception() = default;

View File

@ -24,9 +24,17 @@
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <array/DataType.h> #include <array/DataType.h>
#include <dll.h>
#if defined(_MSC_VER)
// we're ignoring warning about non-exportable parent class, since std::runtime_error is a part of Standard C++ Library
#pragma warning( disable : 4275 )
#endif
namespace nd4j { namespace nd4j {
class datatype_exception : public std::runtime_error { class ND4J_EXPORT datatype_exception : public std::runtime_error {
public: public:
datatype_exception(std::string message); datatype_exception(std::string message);
~datatype_exception() = default; ~datatype_exception() = default;

View File

@ -24,9 +24,17 @@
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <pointercast.h> #include <pointercast.h>
#include <dll.h>
#if defined(_MSC_VER)
// we're ignoring warning about non-exportable parent class, since std::runtime_error is a part of Standard C++ Library
#pragma warning( disable : 4275 )
#endif
namespace nd4j { namespace nd4j {
class graph_exception : public std::runtime_error { class ND4J_EXPORT graph_exception : public std::runtime_error {
protected: protected:
Nd4jLong _graphId; Nd4jLong _graphId;
std::string _message; std::string _message;

View File

@ -25,9 +25,17 @@
#include <pointercast.h> #include <pointercast.h>
#include <stdexcept> #include <stdexcept>
#include <exceptions/graph_exception.h> #include <exceptions/graph_exception.h>
#include <dll.h>
#if defined(_MSC_VER)
// we're ignoring warning about non-exportable parent class, since std::runtime_error is a part of Standard C++ Library
#pragma warning( disable : 4275 )
#endif
namespace nd4j { namespace nd4j {
class graph_execution_exception: public graph_exception { class ND4J_EXPORT graph_execution_exception: public graph_exception {
public: public:
explicit graph_execution_exception(Nd4jLong graphId); explicit graph_execution_exception(Nd4jLong graphId);
}; };

View File

@ -25,9 +25,17 @@
#include <pointercast.h> #include <pointercast.h>
#include <stdexcept> #include <stdexcept>
#include <exceptions/graph_exception.h> #include <exceptions/graph_exception.h>
#include <dll.h>
#if defined(_MSC_VER)
// we're ignoring warning about non-exportable parent class, since std::runtime_error is a part of Standard C++ Library
#pragma warning( disable : 4275 )
#endif
namespace nd4j { namespace nd4j {
class graph_exists_exception: public graph_exception { class ND4J_EXPORT graph_exists_exception: public graph_exception {
public: public:
explicit graph_exists_exception(Nd4jLong graphId); explicit graph_exists_exception(Nd4jLong graphId);
}; };

View File

@ -25,9 +25,17 @@
#include <pointercast.h> #include <pointercast.h>
#include <stdexcept> #include <stdexcept>
#include <exceptions/graph_exception.h> #include <exceptions/graph_exception.h>
#include <dll.h>
#if defined(_MSC_VER)
// we're ignoring warning about non-exportable parent class, since std::runtime_error is a part of Standard C++ Library
#pragma warning( disable : 4275 )
#endif
namespace nd4j { namespace nd4j {
class no_results_exception: public graph_exception { class ND4J_EXPORT no_results_exception: public graph_exception {
public: public:
explicit no_results_exception(Nd4jLong graphId); explicit no_results_exception(Nd4jLong graphId);
}; };

View File

@ -25,9 +25,17 @@
#include <pointercast.h> #include <pointercast.h>
#include <stdexcept> #include <stdexcept>
#include <exceptions/graph_exception.h> #include <exceptions/graph_exception.h>
#include <dll.h>
#if defined(_MSC_VER)
// we're ignoring warning about non-exportable parent class, since std::runtime_error is a part of Standard C++ Library
#pragma warning( disable : 4275 )
#endif
namespace nd4j { namespace nd4j {
class unknown_graph_exception: public graph_exception { class ND4J_EXPORT unknown_graph_exception: public graph_exception {
public: public:
explicit unknown_graph_exception(Nd4jLong graphId); explicit unknown_graph_exception(Nd4jLong graphId);
}; };

View File

@ -33,7 +33,7 @@
#include <queue> #include <queue>
namespace samediff { namespace samediff {
class ThreadPool { class ND4J_EXPORT ThreadPool {
private: private:
static ThreadPool* _INSTANCE; static ThreadPool* _INSTANCE;

View File

@ -27,7 +27,7 @@
#include <op_enums.h> #include <op_enums.h>
namespace samediff { namespace samediff {
class ThreadsHelper { class ND4J_EXPORT ThreadsHelper {
public: public:
static int numberOfThreads(int maxThreads, uint64_t numberOfElements); static int numberOfThreads(int maxThreads, uint64_t numberOfElements);
static int numberOfThreads2d(int maxThreads, uint64_t iters_x, uint64_t iters_y); static int numberOfThreads2d(int maxThreads, uint64_t iters_x, uint64_t iters_y);
@ -36,7 +36,7 @@ namespace samediff {
static int pickLoop3d(int numThreads, uint64_t iters_x, uint64_t iters_y, uint64_t iters_z); static int pickLoop3d(int numThreads, uint64_t iters_x, uint64_t iters_y, uint64_t iters_z);
}; };
class Span { class ND4J_EXPORT Span {
private: private:
int64_t _startX, _stopX, _incX; int64_t _startX, _stopX, _incX;
public: public:
@ -50,7 +50,7 @@ namespace samediff {
static Span build(uint64_t thread_id, uint64_t num_threads, int64_t start_x, int64_t stop_x, int64_t inc_x); static Span build(uint64_t thread_id, uint64_t num_threads, int64_t start_x, int64_t stop_x, int64_t inc_x);
}; };
class Span2 { class ND4J_EXPORT Span2 {
private: private:
int64_t _startX, _stopX, _incX; int64_t _startX, _stopX, _incX;
int64_t _startY, _stopY, _incY; int64_t _startY, _stopY, _incY;
@ -70,7 +70,7 @@ namespace samediff {
static Span2 build(int loop, uint64_t thread_id, uint64_t num_threads, int64_t start_x, int64_t stop_x, int64_t inc_x, int64_t start_y, int64_t stop_y, int64_t inc_y); static Span2 build(int loop, uint64_t thread_id, uint64_t num_threads, int64_t start_x, int64_t stop_x, int64_t inc_x, int64_t start_y, int64_t stop_y, int64_t inc_y);
}; };
class Span3 { class ND4J_EXPORT Span3 {
private: private:
int64_t _startX, _stopX, _incX; int64_t _startX, _stopX, _incX;
int64_t _startY, _stopY, _incY; int64_t _startY, _stopY, _incY;
@ -94,7 +94,7 @@ namespace samediff {
static Span3 build(int loop, uint64_t thread_id, uint64_t num_threads, int64_t start_x, int64_t stop_x, int64_t inc_x, int64_t start_y, int64_t stop_y, int64_t inc_y, int64_t start_z, int64_t stop_z, int64_t inc_z); static Span3 build(int loop, uint64_t thread_id, uint64_t num_threads, int64_t start_x, int64_t stop_x, int64_t inc_x, int64_t start_y, int64_t stop_y, int64_t inc_y, int64_t start_z, int64_t stop_z, int64_t inc_z);
}; };
class Threads { class ND4J_EXPORT Threads {
public: public:
/** /**
* This function executes 1 dimensional loop for a given number of threads * This function executes 1 dimensional loop for a given number of threads

View File

@ -29,7 +29,7 @@
#include <mutex> #include <mutex>
namespace samediff { namespace samediff {
class Ticket { class ND4J_EXPORT Ticket {
private: private:
bool _acquired = false; bool _acquired = false;
std::vector<BlockingQueue<CallableWithArguments*>*> _queues; std::vector<BlockingQueue<CallableWithArguments*>*> _queues;

View File

@ -64,7 +64,7 @@ namespace nd4j {
Variable* clone(); Variable* clone();
template <typename N> template <typename N>
Variable* asT(); ND4J_EXPORT Variable* asT();
bool hasNDArray(); bool hasNDArray();
nd4j::NDArray* getNDArray(); nd4j::NDArray* getNDArray();

View File

@ -311,7 +311,7 @@ namespace nd4j {
node->_dataType = DataTypeUtils::fromT<T>(); node->_dataType = DataTypeUtils::fromT<T>();
return node; return node;
} }
BUILD_SINGLE_TEMPLATE(template Node* Node::asT, (), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT Node* Node::asT, (), LIBND4J_TYPES);
nd4j::graph::Node::Node(nd4j::ops::DeclarableOp *customOp, int id, std::initializer_list<int> input, std::initializer_list<int> output, std::initializer_list<int> dimensions, float scalar, std::initializer_list<double> tArgs, std::initializer_list<int> iArgs) { nd4j::graph::Node::Node(nd4j::ops::DeclarableOp *customOp, int id, std::initializer_list<int> input, std::initializer_list<int> output, std::initializer_list<int> dimensions, float scalar, std::initializer_list<double> tArgs, std::initializer_list<int> iArgs) {
this->_opType = OpType_CUSTOM; this->_opType = OpType_CUSTOM;

View File

@ -50,7 +50,7 @@ namespace nd4j {
return result; return result;
} }
BUILD_SINGLE_TEMPLATE(template Variable* Variable::asT, (), LIBND4J_TYPES); BUILD_SINGLE_TEMPLATE(template ND4J_EXPORT Variable* Variable::asT, (), LIBND4J_TYPES);
nd4j::graph::Variable* nd4j::graph::Variable::clone() { nd4j::graph::Variable* nd4j::graph::Variable::clone() {
auto result = new Variable(this->isPlaceholder()); auto result = new Variable(this->isPlaceholder());

View File

@ -24,7 +24,7 @@
#include "NDArray.h" #include "NDArray.h"
namespace nd4j { namespace nd4j {
class AttentionHelper { class ND4J_EXPORT AttentionHelper {
public: public:
static nd4j::NDArray multiHeadProject(const nd4j::NDArray* input, const nd4j::NDArray* projectionMatrix, nd4j::LaunchContext * context = nd4j::LaunchContext ::defaultContext()); static nd4j::NDArray multiHeadProject(const nd4j::NDArray* input, const nd4j::NDArray* projectionMatrix, nd4j::LaunchContext * context = nd4j::LaunchContext ::defaultContext());

View File

@ -44,7 +44,7 @@
namespace nd4j { namespace nd4j {
class BenchmarkHelper { class ND4J_EXPORT BenchmarkHelper {
private: private:
unsigned int _wIterations; unsigned int _wIterations;
unsigned int _rIterations; unsigned int _rIterations;

View File

@ -28,7 +28,7 @@
#include <climits> #include <climits>
namespace nd4j { namespace nd4j {
class BitwiseUtils { class ND4J_EXPORT BitwiseUtils {
public: public:

View File

@ -28,7 +28,7 @@
#include <types/triple.h> #include <types/triple.h>
namespace nd4j { namespace nd4j {
class CudaLaunchHelper { class ND4J_EXPORT CudaLaunchHelper {
public: public:
static Triple getFlatLaunchParams(Nd4jLong length, int SM, int CORES, int SHARED_MEMORY); static Triple getFlatLaunchParams(Nd4jLong length, int SM, int CORES, int SHARED_MEMORY);
static int getReductionBlocks(Nd4jLong xLength, int blockSize = 512); static int getReductionBlocks(Nd4jLong xLength, int blockSize = 512);

View File

@ -40,7 +40,7 @@
#include <DebugInfo.h> #include <DebugInfo.h>
namespace nd4j { namespace nd4j {
class NDArray; class NDArray;
class DebugHelper { class ND4J_EXPORT DebugHelper {
public: public:
// cuda-specific debug functions // cuda-specific debug functions

View File

@ -27,7 +27,7 @@
namespace nd4j { namespace nd4j {
class GradCheck { class ND4J_EXPORT GradCheck {
public: public:
enum LossFunc {MEAN = 0, SUM = 1}; enum LossFunc {MEAN = 0, SUM = 1};

View File

@ -25,7 +25,7 @@
#include "NDArray.h" #include "NDArray.h"
namespace nd4j { namespace nd4j {
class MmulHelper { class ND4J_EXPORT MmulHelper {
private: private:

View File

@ -28,7 +28,7 @@
namespace nd4j { namespace nd4j {
class OmpLaunchHelper { class ND4J_EXPORT OmpLaunchHelper {
public: public:

View File

@ -30,7 +30,7 @@
namespace nd4j { namespace nd4j {
class PointersManager { class ND4J_EXPORT PointersManager {
private: private:

View File

@ -24,7 +24,7 @@
#include <execution/LaunchContext.h> #include <execution/LaunchContext.h>
namespace nd4j { namespace nd4j {
class RandomLauncher { class ND4J_EXPORT RandomLauncher {
public: public:
static void applyDropOut(nd4j::LaunchContext *context, nd4j::graph::RandomGenerator& rng, NDArray *array, double retainProb, NDArray* z = nullptr); static void applyDropOut(nd4j::LaunchContext *context, nd4j::graph::RandomGenerator& rng, NDArray *array, double retainProb, NDArray* z = nullptr);
static void applyInvertedDropOut(nd4j::LaunchContext *context, nd4j::graph::RandomGenerator& rng, NDArray *array, double retainProb, NDArray* z = nullptr); static void applyInvertedDropOut(nd4j::LaunchContext *context, nd4j::graph::RandomGenerator& rng, NDArray *array, double retainProb, NDArray* z = nullptr);

View File

@ -26,7 +26,7 @@
namespace nd4j { namespace nd4j {
class ShapeUtils { class ND4J_EXPORT ShapeUtils {
public: public:

View File

@ -23,6 +23,7 @@
#include <atomic> #include <atomic>
#include <mutex> #include <mutex>
#include <dll.h>
/** /**
* This class provides PRIMITIVE read-write lock, and should NOT be used outside of GraphServer due to its inefficiency. * This class provides PRIMITIVE read-write lock, and should NOT be used outside of GraphServer due to its inefficiency.
@ -31,7 +32,7 @@
* Basic idea: write lock won't be obtained before all read requests served * Basic idea: write lock won't be obtained before all read requests served
*/ */
namespace nd4j { namespace nd4j {
class SimpleReadWriteLock { class ND4J_EXPORT SimpleReadWriteLock {
private: private:
std::atomic<unsigned long long int> _read_locks; std::atomic<unsigned long long int> _read_locks;
std::atomic<unsigned long long int> _write_locks; std::atomic<unsigned long long int> _write_locks;

View File

@ -27,7 +27,7 @@
#include <sstream> #include <sstream>
namespace nd4j { namespace nd4j {
class StringUtils { class ND4J_EXPORT StringUtils {
public: public:
template <typename T> template <typename T>
static FORCEINLINE std::string valueToString(T value) { static FORCEINLINE std::string valueToString(T value) {

View File

@ -27,7 +27,7 @@
#include <mutex> #include <mutex>
namespace nd4j { namespace nd4j {
class CublasHelper { class ND4J_EXPORT CublasHelper {
private: private:
static CublasHelper *_INSTANCE; static CublasHelper *_INSTANCE;
static std::mutex _mutex; static std::mutex _mutex;

View File

@ -24,10 +24,11 @@
#include "Workspace.h" #include "Workspace.h"
#include <map> #include <map>
#include <mutex> #include <mutex>
#include <dll.h>
namespace nd4j { namespace nd4j {
namespace memory { namespace memory {
class MemoryRegistrator { class ND4J_EXPORT MemoryRegistrator {
protected: protected:
static MemoryRegistrator* _INSTANCE; static MemoryRegistrator* _INSTANCE;
Workspace* _workspace; Workspace* _workspace;

View File

@ -22,10 +22,11 @@
#define LIBND4J_MEMORYREPORT_H #define LIBND4J_MEMORYREPORT_H
#include <pointercast.h> #include <pointercast.h>
#include <dll.h>
namespace nd4j { namespace nd4j {
namespace memory { namespace memory {
class MemoryReport { class ND4J_EXPORT MemoryReport {
private: private:
Nd4jLong _vm = 0; Nd4jLong _vm = 0;
Nd4jLong _rss = 0; Nd4jLong _rss = 0;

View File

@ -22,10 +22,11 @@
#define LIBND4J_MEMORYUTILS_H #define LIBND4J_MEMORYUTILS_H
#include "MemoryReport.h" #include "MemoryReport.h"
#include <dll.h>
namespace nd4j { namespace nd4j {
namespace memory { namespace memory {
class MemoryUtils { class ND4J_EXPORT MemoryUtils {
public: public:
static bool retrieveMemoryStatistics(MemoryReport& report); static bool retrieveMemoryStatistics(MemoryReport& report);
}; };

View File

@ -22,9 +22,10 @@
#define DEV_TESTS_BROADCASTBOOLOPSTUPLE_H #define DEV_TESTS_BROADCASTBOOLOPSTUPLE_H
#include <op_enums.h> #include <op_enums.h>
#include <dll.h>
namespace nd4j { namespace nd4j {
class BroadcastBoolOpsTuple { class ND4J_EXPORT BroadcastBoolOpsTuple {
private: private:
public: public:

View File

@ -22,9 +22,10 @@
#define DEV_TESTS_BROADCASTINTOPSTUPLE_H #define DEV_TESTS_BROADCASTINTOPSTUPLE_H
#include <op_enums.h> #include <op_enums.h>
#include <dll.h>
namespace nd4j { namespace nd4j {
class BroadcastIntOpsTuple { class ND4J_EXPORT BroadcastIntOpsTuple {
private: private:
public: public:

View File

@ -22,9 +22,10 @@
#define DEV_TESTS_BROADCASTOPSTUPLE_H #define DEV_TESTS_BROADCASTOPSTUPLE_H
#include <op_enums.h> #include <op_enums.h>
#include <dll.h>
namespace nd4j { namespace nd4j {
class BroadcastOpsTuple { class ND4J_EXPORT BroadcastOpsTuple {
private: private:
public: public:

View File

@ -108,6 +108,9 @@ namespace nd4j {
if (!x->isScalar() && !y->isScalar() && x->isSameShape(y)) { if (!x->isScalar() && !y->isScalar() && x->isSameShape(y)) {
x->applyPairwiseTransform(op.p, y, z, nullptr); x->applyPairwiseTransform(op.p, y, z, nullptr);
} else if (ShapeUtils::areShapesBroadcastable(*x, *y)) {
x->applyTrueBroadcast(op, y, z, true, extraArgs);
return z;
} else if (!x->isScalar() && y->isScalar()) { } else if (!x->isScalar() && y->isScalar()) {
x->applyScalarArr(op.s, const_cast<const NDArray*>(y), z); x->applyScalarArr(op.s, const_cast<const NDArray*>(y), z);
} else if (x->isScalar() && !y->isScalar()) { } else if (x->isScalar() && !y->isScalar()) {

View File

@ -32,6 +32,10 @@ CONFIGURABLE_OP_IMPL(adjust_contrast, 1, 1, true, -2, 0) {
auto input = INPUT_VARIABLE(0); auto input = INPUT_VARIABLE(0);
auto output = OUTPUT_VARIABLE(0); auto output = OUTPUT_VARIABLE(0);
// just skip op if input is empty
if (input->isEmpty())
return Status::OK();
REQUIRE_TRUE(block.numT() > 0 || block.width() > 1, 0, "ADJUST_CONTRAST: Scale factor required"); REQUIRE_TRUE(block.numT() > 0 || block.width() > 1, 0, "ADJUST_CONTRAST: Scale factor required");
const double factor = block.width() > 1 ? INPUT_VARIABLE(1)->e<double>(0) : T_ARG(0); const double factor = block.width() > 1 ? INPUT_VARIABLE(1)->e<double>(0) : T_ARG(0);
@ -70,6 +74,10 @@ DECLARE_TYPES(adjust_contrast) {
const double factor = block.width() > 1 ? INPUT_VARIABLE(1)->e<double>(0) : T_ARG(0); const double factor = block.width() > 1 ? INPUT_VARIABLE(1)->e<double>(0) : T_ARG(0);
// just skip op if input is empty
if (input->isEmpty())
return Status::OK();
REQUIRE_TRUE(input->rankOf() > 2, 0, "ADJUST_CONTRAST_V2: op expects rank of input array to be >= 3, but got %i instead", input->rankOf()); REQUIRE_TRUE(input->rankOf() > 2, 0, "ADJUST_CONTRAST_V2: op expects rank of input array to be >= 3, but got %i instead", input->rankOf());
REQUIRE_TRUE(input->sizeAt(-1) == 3, 0, "ADJUST_CONTRAST_V2: operation expects image with 3 channels (R, G, B), but got %i instead", input->sizeAt(-1)); REQUIRE_TRUE(input->sizeAt(-1) == 3, 0, "ADJUST_CONTRAST_V2: operation expects image with 3 channels (R, G, B), but got %i instead", input->sizeAt(-1));

View File

@ -35,6 +35,10 @@ CONFIGURABLE_OP_IMPL(adjust_hue, 1, 1, true, 1, -2) {
auto input = INPUT_VARIABLE(0); auto input = INPUT_VARIABLE(0);
auto output = OUTPUT_VARIABLE(0); auto output = OUTPUT_VARIABLE(0);
// just skip op if input is empty
if (input->isEmpty())
return Status::OK();
const int rank = input->rankOf(); const int rank = input->rankOf();
const int dimC = block.getIArguments()->size() > 0 ? (INT_ARG(0) >= 0 ? INT_ARG(0) : INT_ARG(0) + rank) : rank - 1; const int dimC = block.getIArguments()->size() > 0 ? (INT_ARG(0) >= 0 ? INT_ARG(0) : INT_ARG(0) + rank) : rank - 1;
const double delta = T_ARG(0); const double delta = T_ARG(0);

View File

@ -33,6 +33,10 @@ CONFIGURABLE_OP_IMPL(adjust_saturation, 1, 1, true, 1, -2) {
auto input = INPUT_VARIABLE(0); auto input = INPUT_VARIABLE(0);
auto output = OUTPUT_VARIABLE(0); auto output = OUTPUT_VARIABLE(0);
// just skip op if input is empty
if (input->isEmpty())
return Status::OK();
const int rank = input->rankOf(); const int rank = input->rankOf();
const int dimC = block.getIArguments()->size() > 0 ? (INT_ARG(0) >= 0 ? INT_ARG(0) : INT_ARG(0) + rank) : rank - 1; const int dimC = block.getIArguments()->size() > 0 ? (INT_ARG(0) >= 0 ? INT_ARG(0) : INT_ARG(0) + rank) : rank - 1;
const double factor = T_ARG(0); const double factor = T_ARG(0);

View File

@ -25,6 +25,7 @@
namespace nd4j { namespace nd4j {
namespace ops { namespace ops {
CUSTOM_OP_IMPL(create, 1, 1, false, 0, 1) { CUSTOM_OP_IMPL(create, 1, 1, false, 0, 1) {
auto init = block.numB() > 0 ? B_ARG(0) : true; auto init = block.numB() > 0 ? B_ARG(0) : true;

View File

@ -27,23 +27,23 @@ namespace nd4j {
namespace ops { namespace ops {
namespace helpers { namespace helpers {
void softMaxForVector(nd4j::LaunchContext * context, const NDArray &input, NDArray &output); ND4J_EXPORT void softMaxForVector(nd4j::LaunchContext * context, const NDArray &input, NDArray &output);
void logSoftMaxForVector(nd4j::LaunchContext * context, const NDArray &input, NDArray &output); ND4J_EXPORT void logSoftMaxForVector(nd4j::LaunchContext * context, const NDArray &input, NDArray &output);
void softmax(nd4j::LaunchContext * context, const NDArray &input, NDArray &output, const int dimension); ND4J_EXPORT void softmax(nd4j::LaunchContext * context, const NDArray &input, NDArray &output, const int dimension);
void logSoftmax(nd4j::LaunchContext * context, const NDArray &input, NDArray &output, const int dimension); ND4J_EXPORT void logSoftmax(nd4j::LaunchContext * context, const NDArray &input, NDArray &output, const int dimension);
void softmaxDerivative(nd4j::LaunchContext * context, const NDArray& input, NDArray& output, const int dimension); ND4J_EXPORT void softmaxDerivative(nd4j::LaunchContext * context, const NDArray& input, NDArray& output, const int dimension);
void prelu(nd4j::LaunchContext * context, const NDArray &input, const NDArray &alpha, NDArray &output); ND4J_EXPORT void prelu(nd4j::LaunchContext * context, const NDArray &input, const NDArray &alpha, NDArray &output);
void preluBP(nd4j::LaunchContext * context, const NDArray &input, const NDArray &alpha, const NDArray &dLdO, NDArray &dLdI, NDArray &dLdA); ND4J_EXPORT void preluBP(nd4j::LaunchContext * context, const NDArray &input, const NDArray &alpha, const NDArray &dLdO, NDArray &dLdI, NDArray &dLdA);
void thresholdRelu(nd4j::LaunchContext * context, const NDArray &input, double threshold, NDArray &output); ND4J_EXPORT void thresholdRelu(nd4j::LaunchContext * context, const NDArray &input, double threshold, NDArray &output);
void thresholdReluDerivative(nd4j::LaunchContext * context, NDArray *input, double threshold, NDArray* dLdO, NDArray *output); ND4J_EXPORT void thresholdReluDerivative(nd4j::LaunchContext * context, NDArray *input, double threshold, NDArray* dLdO, NDArray *output);
} }
} }
} }

View File

@ -27,7 +27,7 @@ namespace nd4j {
namespace ops { namespace ops {
namespace helpers { namespace helpers {
void col2im(nd4j::LaunchContext & context, const NDArray& input, NDArray& output, const int sH, const int sW, const int pH, const int pW, const int iH, const int iW, const int dH, const int dW); ND4J_EXPORT void col2im(nd4j::LaunchContext & context, const NDArray& input, NDArray& output, const int sH, const int sW, const int pH, const int pW, const int iH, const int iW, const int dH, const int dW);
} }

View File

@ -23,6 +23,7 @@
#include <NDArray.h> #include <NDArray.h>
#include <graph/Context.h> #include <graph/Context.h>
#include <dll.h>
#include <execution/LaunchContext.h> #include <execution/LaunchContext.h>
@ -35,7 +36,7 @@ namespace nd4j {
PNORM_POOL = 2, PNORM_POOL = 2,
}; };
class ConvolutionUtils { class ND4J_EXPORT ConvolutionUtils {
public: public:
static inline void calcOutSizePool2D(int& oH, int& oW, const int kH, const int kW, const int sH, const int sW, const int pH, const int pW, const int dH, const int dW, const int iH, const int iW, const int paddingMode) { static inline void calcOutSizePool2D(int& oH, int& oW, const int kH, const int kW, const int sH, const int sW, const int pH, const int pW, const int dH, const int dW, const int iH, const int iW, const int paddingMode) {

View File

@ -27,7 +27,7 @@ namespace nd4j {
namespace ops { namespace ops {
namespace helpers { namespace helpers {
void im2col(nd4j::LaunchContext & context, const NDArray& im, NDArray& col, const int kH, const int kW, const int sH, const int sW, const int pH, const int pW, const int dH, const int dW, const NDArray& arrZeroPadVal); ND4J_EXPORT void im2col(nd4j::LaunchContext & context, const NDArray& im, NDArray& col, const int kH, const int kW, const int sH, const int sW, const int pH, const int pW, const int dH, const int dW, const NDArray& arrZeroPadVal);
} }
} }
} }

View File

@ -29,13 +29,13 @@ namespace ops {
namespace helpers { namespace helpers {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void lstmLayerCell(const NDArray* x, const NDArray* Wx, const NDArray* Wr, void ND4J_EXPORT lstmLayerCell(const NDArray* x, const NDArray* Wx, const NDArray* Wr,
const NDArray* b, const NDArray* hI, const NDArray* cI, const NDArray* Wp, const NDArray* b, const NDArray* hI, const NDArray* cI, const NDArray* Wp,
const std::vector<float>& params, const std::vector<float>& params,
NDArray* h, NDArray* c); NDArray* h, NDArray* c);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void lstmLayerTimeLoop(const NDArray* x, const NDArray* Wx, const NDArray* Wr, void ND4J_EXPORT lstmLayerTimeLoop(const NDArray* x, const NDArray* Wx, const NDArray* Wr,
const NDArray* b, const NDArray* seqLen, const NDArray* hI, const NDArray* cI, const NDArray* Wp, const NDArray* b, const NDArray* seqLen, const NDArray* hI, const NDArray* cI, const NDArray* Wp,
const std::vector<float>& params, const std::vector<float>& params,
const bool forward, const bool forward,

View File

@ -26,7 +26,7 @@ namespace nd4j {
namespace ops { namespace ops {
namespace helpers { namespace helpers {
bool multiUnique(std::vector<NDArray*> const& inputList, nd4j::memory::Workspace* workspace = nullptr); ND4J_EXPORT bool multiUnique(std::vector<NDArray*> const& inputList, nd4j::memory::Workspace* workspace = nullptr);
} }
} }

View File

@ -774,8 +774,27 @@ TEST_F(BroadcastableOpsTests, broadcast_bool_2) {
ASSERT_TRUE(z.equalsTo(e)); ASSERT_TRUE(z.equalsTo(e));
} }
TEST_F(BroadcastableOpsTests, broadcast_2) { TEST_F(BroadcastableOpsTests, broadcast_bool_3) {
auto x = NDArrayFactory::create<int>(0);
auto y = NDArrayFactory::create<int>('c', {3}, {2, 1, 2});
NDArray z('c', {3}, nd4j::DataType::BOOL);
NDArray e('c', {3}, nd4j::DataType::BOOL);
e.assign(true);
nd4j::ops::less op;
auto status = op.execute({&x, &y}, {&z}, {}, {}, {});
ASSERT_EQ(ND4J_STATUS_OK, status);
// z.printIndexedBuffer("Z");
ASSERT_TRUE(z.isSameShape(e));
ASSERT_TRUE(z.equalsTo(e));
}
TEST_F(BroadcastableOpsTests, broadcast_2) {
NDArray x('c', {3, 1, 2}, nd4j::DataType::FLOAT32); NDArray x('c', {3, 1, 2}, nd4j::DataType::FLOAT32);
NDArray y('c', {2, 2}, nd4j::DataType::FLOAT32); NDArray y('c', {2, 2}, nd4j::DataType::FLOAT32);
NDArray z('c', {3, 2, 2}, nd4j::DataType::FLOAT32); NDArray z('c', {3, 2, 2}, nd4j::DataType::FLOAT32);
@ -797,3 +816,19 @@ TEST_F(BroadcastableOpsTests, broadcast_2) {
ASSERT_TRUE(z.equalsTo(e)); ASSERT_TRUE(z.equalsTo(e));
} }
TEST_F(BroadcastableOpsTests, broadcast_3) {
auto x = NDArrayFactory::create<int>(0);
auto y = NDArrayFactory::create<int>('c', {3}, {2, 1, 2});
NDArray z('c', {3}, nd4j::DataType::INT32);
auto e = NDArrayFactory::create<int>('c', {3}, {2, 1, 2});
nd4j::ops::add op;
auto status = op.execute({&x, &y}, {&z}, {}, {}, {});
ASSERT_EQ(ND4J_STATUS_OK, status);
// z.printIndexedBuffer("Z");
ASSERT_TRUE(z.isSameShape(e));
ASSERT_TRUE(z.equalsTo(e));
}

View File

@ -29,7 +29,7 @@ if (CUDA_BLAS)
if(WIN32) if(WIN32)
message("CUDA on Windows: enabling /EHsc") message("CUDA on Windows: enabling /EHsc")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /FS /w") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /FS")
SET_TARGET_PROPERTIES(${LIBND4J_NAME} PROPERTIES COMPILER_FLAGS "/EHsc") SET_TARGET_PROPERTIES(${LIBND4J_NAME} PROPERTIES COMPILER_FLAGS "/EHsc")
endif() endif()

View File

@ -97,6 +97,8 @@ TEST_F(CudaBasicsTests1, TestPairwise_1) {
cudaMemcpyAsync(devBufferPtrX, x.buffer(), x.lengthOf() * x.sizeOfT(), cudaMemcpyHostToDevice, *stream); cudaMemcpyAsync(devBufferPtrX, x.buffer(), x.lengthOf() * x.sizeOfT(), cudaMemcpyHostToDevice, *stream);
cudaMemcpyAsync(devShapePtrX, x.shapeInfo(), shape::shapeInfoByteLength(x.shapeInfo()), cudaMemcpyHostToDevice, *stream); cudaMemcpyAsync(devShapePtrX, x.shapeInfo(), shape::shapeInfoByteLength(x.shapeInfo()), cudaMemcpyHostToDevice, *stream);
res = cudaStreamSynchronize(*stream);
ASSERT_EQ(0, res);
LaunchContext lc(stream, nullptr, nullptr); LaunchContext lc(stream, nullptr, nullptr);
NativeOpExecutioner::execPairwiseTransform(&lc, pairwise::Add, nullptr, x.shapeInfo(), devBufferPtrX, reinterpret_cast<Nd4jLong*>(devShapePtrX), nullptr, x.shapeInfo(), devBufferPtrX, reinterpret_cast<Nd4jLong*>(devShapePtrX), nullptr, z.shapeInfo(), devBufferPtrZ, reinterpret_cast<Nd4jLong*>(devShapePtrX), nullptr); NativeOpExecutioner::execPairwiseTransform(&lc, pairwise::Add, nullptr, x.shapeInfo(), devBufferPtrX, reinterpret_cast<Nd4jLong*>(devShapePtrX), nullptr, x.shapeInfo(), devBufferPtrX, reinterpret_cast<Nd4jLong*>(devShapePtrX), nullptr, z.shapeInfo(), devBufferPtrZ, reinterpret_cast<Nd4jLong*>(devShapePtrX), nullptr);
@ -117,6 +119,7 @@ TEST_F(CudaBasicsTests1, TestPairwise_1) {
z.tickWriteHost(); z.tickWriteHost();
for (int e = 0; e < z.lengthOf(); e++) { for (int e = 0; e < z.lengthOf(); e++) {
nd4j_printf("step %i\n", e);
ASSERT_NEAR(exp.e<double>(e), z.e<double>(e), 1e-5); ASSERT_NEAR(exp.e<double>(e), z.e<double>(e), 1e-5);
} }
} }
@ -168,6 +171,8 @@ TEST_F(CudaBasicsTests1, execIndexReduceScalar_1) {
void* reductionPointer = nullptr; void* reductionPointer = nullptr;
cudaResult = cudaMalloc(reinterpret_cast<void **>(&reductionPointer), 1024*1024); cudaResult = cudaMalloc(reinterpret_cast<void **>(&reductionPointer), 1024*1024);
ASSERT_EQ(0, cudaResult);
cudaResult = cudaMemset(reductionPointer, 0, 1024 * 1024);
ASSERT_EQ(0, cudaResult); ASSERT_EQ(0, cudaResult);
LaunchContext lc(&stream, LaunchContext::defaultContext()->getReductionPointer(), LaunchContext::defaultContext()->getScalarPointer(), LaunchContext::defaultContext()->getAllocationPointer()); LaunchContext lc(&stream, LaunchContext::defaultContext()->getReductionPointer(), LaunchContext::defaultContext()->getScalarPointer(), LaunchContext::defaultContext()->getAllocationPointer());

View File

@ -1576,32 +1576,32 @@ TEST_F(DeclarableOpsTests6, LogDet_3) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TEST_F(DeclarableOpsTests6, MatrixInverse_1) { TEST_F(DeclarableOpsTests6, MatrixInverse_1) {
auto x = NDArrayFactory::create<double>('c', {2, 5, 5}, { auto x = NDArrayFactory::create<float>('c', {2, 5, 5}, {
2., 4., 60., 8., 10., 2.f, 4.f, 60.f, 8.f, 10.f,
0., 1., 2., 3., 4., 0.f, 1.f, 2.f, 3.f, 4.f,
0., 0., 2., 4., 6., 0.f, 0.f, 2.f, 4.f, 6.f,
0., 0., 0., 1., 2., 0.f, 0.f, 0.f, 1.f, 2.f,
0., 0., 0., 0., 4., 0.f, 0.f, 0.f, 0.f, 4.f,
1., 0., 0., 0., 0., 1.f, 0.f, 0.f, 0.f, 0.f,
2., 1., 0., 0., 0., 2.f, 1.f, 0.f, 0.f, 0.f,
30., 2., 1., 0., 0., 30.f, 2.f, 1.f, 0.f, 0.f,
4., 3., 2., 1., 0., 4.f, 3.f, 2.f, 1.f, 0.f,
5., 4., 3., 2., 1., 5.f, 4.f, 3.f, 2.f, 1.f
}); });
auto exp = NDArrayFactory::create<double>('c', {2, 5, 5}, { auto exp = NDArrayFactory::create<float>('c', {2, 5, 5}, {
0.5, -2.0, -13.0, 54.0, -6.75, 0.5f, -2.0f, -13.0f, 54.0f, -6.75f,
0.0, 1.0, -1.0, 1.0, 0.0, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f,
0, 0, 0.5, -2.0, 0.25, 0.f, 0.f, 0.5f, -2.0f, 0.25f,
0, 0, 0, 1.0, -0.5, 0.f, 0.f, 0.f, 1.0f, -0.5f,
0, 0, 0, 0, 0.25, 0.f, 0.f, 0.f, 0.f, 0.25f,
1.0, 0.0, 0.0, 0.0, 0., 1.0f, 0.0f, 0.0f, 0.0f, 0.f,
-2.0, 1.0, 0., 0., 0., -2.0f, 1.0f, 0.f, 0.f, 0.f,
-26.0, -2.0, 1, 0, 0., -26.0f, -2.0f, 1.f, 0.f, 0.f,
54.0, 1.0, -2.0, 1, 0., 54.0f, 1.0f, -2.0f, 1.f, 0.f,
-27.0, 0.0, 1.0, -2.0, 1. -27.0f, 0.0f, 1.0f, -2.0f, 1.f,
}); });
nd4j::ops::matrix_inverse op; nd4j::ops::matrix_inverse op;
@ -1620,8 +1620,8 @@ TEST_F(DeclarableOpsTests6, MatrixInverse_1) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TEST_F(DeclarableOpsTests6, MatrixInverse_010) { TEST_F(DeclarableOpsTests6, MatrixInverse_010) {
auto x = NDArrayFactory::create<double>('c', {1, 5, 5}, {1., 0., 0., 0., 0.,2., 1., 0., 0., 0.,30., 2., 1., 0., 0.,4., 3., 2., 1., 0.,5., 4., 3., 2., 1.,}); auto x = NDArrayFactory::create<float>('c', {1, 5, 5}, {1.f, 0.f, 0.f, 0.f, 0.f, 2.f, 1.f, 0.f, 0.f, 0.f, 30.f, 2.f, 1.f, 0.f, 0.f, 4.f, 3.f, 2.f, 1.f, 0.f, 5.f, 4.f, 3.f, 2.f, 1.f, });
auto exp = NDArrayFactory::create<double>('c', {1, 5, 5}, {1.0, 0.0, 0.0, 0.0, 0.,-2.0, 1.0, 0., 0., 0.,-26.0, -2.0, 1, 0, 0.,54.0, 1.0, -2.0, 1, 0.,-27.0, 0.0, 1.0, -2.0, 1.}); auto exp = NDArrayFactory::create<float>('c', {1, 5, 5}, {1.0f, 0.0f, 0.0f, 0.0f, 0.f, -2.0f, 1.0f, 0.f, 0.f, 0.f, -26.0f, -2.0f, 1.f, 0.f, 0.f, 54.0f, 1.0f, -2.0f, 1.f, 0.f, -27.0f, 0.0f, 1.0f, -2.0f, 1.f});
nd4j::ops::matrix_inverse op; nd4j::ops::matrix_inverse op;
auto result = op.execute({&x}, {}, {}, {}, false, nd4j::DataType::FLOAT32); auto result = op.execute({&x}, {}, {}, {}, false, nd4j::DataType::FLOAT32);
@ -1639,9 +1639,9 @@ TEST_F(DeclarableOpsTests6, MatrixInverse_010) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TEST_F(DeclarableOpsTests6, MatrixInverse_01) { TEST_F(DeclarableOpsTests6, MatrixInverse_01) {
auto x = NDArrayFactory::create<double>('c', {1, 5, 5}, {2., 4., 60., 8., 10., 0., 1., 2., 3., 4., 0., 0., 2., 4., 6., 0., 0., 0., 1., 2., 0., 0., 0., 0., 4. }); auto x = NDArrayFactory::create<float>('c', {1, 5, 5}, {2.f, 4.f, 60.f, 8.f, 10.f, 0.f, 1.f, 2.f, 3.f, 4.f, 0.f, 0.f, 2.f, 4.f, 6.f, 0.f, 0.f, 0.f, 1.f, 2.f, 0.f, 0.f, 0.f, 0.f, 4.f });
auto exp = NDArrayFactory::create<double>('c', {1, 5, 5}, {0.5, -2.0, -13.0, 54.0, -6.75, 0.0, 1.0, -1.0, 1.0, 0.0, 0, 0, 0.5, -2.0, 0.25, 0, 0, 0, 1.0, -0.5, 0, 0, 0, 0, 0.25 }); auto exp = NDArrayFactory::create<float>('c', {1, 5, 5}, {0.5f, -2.0f, -13.0f, 54.0f, -6.75f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.f, 0.f, 0.5f, -2.0f, 0.25f, 0.f, 0.f, 0.f, 1.0f, -0.5f, 0.f, 0.f, 0.f, 0.f, 0.25f });
nd4j::ops::matrix_inverse op; nd4j::ops::matrix_inverse op;
auto result = op.execute({&x}, {}, {}, {}, false, nd4j::DataType::FLOAT32); auto result = op.execute({&x}, {}, {}, {}, false, nd4j::DataType::FLOAT32);
@ -1658,8 +1658,8 @@ TEST_F(DeclarableOpsTests6, MatrixInverse_01) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TEST_F(DeclarableOpsTests6, MatrixInverse_02) { TEST_F(DeclarableOpsTests6, MatrixInverse_02) {
auto x = NDArrayFactory::create<double>('c', {1, 5, 5}, {1., 0., 0., 0., 0., 2., 1., 0., 0., 0., 30., 2., 1., 0., 0., 4., 3., 2., 1., 0., 5., 4., 3., 2., 1. }); auto x = NDArrayFactory::create<float>('c', {1, 5, 5}, {1.f, 0.f, 0.f, 0.f, 0.f, 2.f, 1.f, 0.f, 0.f, 0.f, 30.f, 2.f, 1.f, 0.f, 0.f, 4.f, 3.f, 2.f, 1.f, 0.f, 5.f, 4.f, 3.f, 2.f, 1.f });
auto exp = NDArrayFactory::create<double>('c', {1, 5, 5}, {1.0, 0.0, 0.0, 0.0, 0., -2.0, 1.0, 0., 0., 0., -26.0, -2.0, 1, 0, 0., 54.0, 1.0, -2.0, 1, 0., -27.0, 0.0, 1.0, -2.0, 1. }); auto exp = NDArrayFactory::create<float>('c', {1, 5, 5}, {1.0f, 0.0f, 0.0f, 0.0f, 0.f, -2.0f, 1.0f, 0.f, 0.f, 0.f, -26.0f, -2.0f, 1.f, 0.f, 0.f, 54.0f, 1.0f, -2.0f, 1.f, 0.f, -27.0f, 0.0f, 1.0f, -2.0f, 1.f });
nd4j::ops::matrix_inverse op; nd4j::ops::matrix_inverse op;
auto result = op.execute({&x}, {}, {}, {}, false, nd4j::DataType::FLOAT32); auto result = op.execute({&x}, {}, {}, {}, false, nd4j::DataType::FLOAT32);

View File

@ -24,6 +24,7 @@ import org.junit.runners.Parameterized;
import org.nd4j.linalg.BaseNd4jTest; import org.nd4j.linalg.BaseNd4jTest;
import org.nd4j.linalg.api.buffer.DataType; import org.nd4j.linalg.api.buffer.DataType;
import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.api.ops.impl.transforms.custom.LessThan;
import org.nd4j.linalg.api.ops.impl.transforms.pairwise.arithmetic.AddOp; import org.nd4j.linalg.api.ops.impl.transforms.pairwise.arithmetic.AddOp;
import org.nd4j.linalg.api.ops.impl.transforms.pairwise.arithmetic.RealDivOp; import org.nd4j.linalg.api.ops.impl.transforms.pairwise.arithmetic.RealDivOp;
import org.nd4j.linalg.factory.Nd4j; import org.nd4j.linalg.factory.Nd4j;
@ -288,6 +289,30 @@ public class BasicBroadcastTests extends BaseNd4jTest {
} }
} }
@Test
public void testLt(){
INDArray x = Nd4j.scalar(0);
INDArray y = Nd4j.createFromArray(2,1,2);
INDArray result = Nd4j.create(DataType.BOOL, 3);
INDArray lt = Nd4j.exec(new LessThan(x,y,result))[0];
INDArray exp = Nd4j.createFromArray(true, true, true);
assertEquals(exp, lt);
}
@Test
public void testAdd(){
INDArray x = Nd4j.scalar(0);
INDArray y = Nd4j.createFromArray(2,1,2);
INDArray result = Nd4j.create(DataType.INT, 3);
INDArray sum = Nd4j.exec(new AddOp(x,y,result))[0];
INDArray exp = Nd4j.createFromArray(2, 1, 2);
assertEquals(exp, sum);
}
@Override @Override
public char ordering() { public char ordering() {
return 'c'; return 'c';