#include "dnn.hpp"
#include "am_intel_dnn.hpp"
#include "dnn_types.h"
+#include "gna_types.h"
#if GNA_LIB_VER == 2
#include <gna2-model-api.h>
float input_scale_factor,
void *&ptr_inputs,
void *&ptr_outputs,
- intel_pwl_segment_t *ptr_segments,
+ gna_pwl_segment_t *ptr_segments,
bool postInitMem) {
comp.num_rows_in = num_rows;
comp.num_columns_in = num_columns;
ptr_inputs = &comp.ptr_inputs;
ptr_outputs = &comp.ptr_outputs;
if (ptr_segments != nullptr) {
- *reinterpret_cast<intel_pwl_segment_t **>(ptr_segments) =
- reinterpret_cast<intel_pwl_segment_t *>(& comp.op.pwl.ptr_segments);
+ *reinterpret_cast<gna_pwl_segment_t **>(ptr_segments) =
+ reinterpret_cast<gna_pwl_segment_t *>(& comp.op.pwl.ptr_segments);
}
}
}
if (num_bytes_per_weight == 1) {
int8_t *ptr_weight = reinterpret_cast<int8_t *>(component[i].op.affine.ptr_weights);
- intel_compound_bias_t *ptr_bias = reinterpret_cast<intel_compound_bias_t *>(component[i].op.affine.ptr_biases);
+ gna_compound_bias_t *ptr_bias = reinterpret_cast<gna_compound_bias_t *>(component[i].op.affine.ptr_biases);
#ifdef DUMP_WB
for (uint32_t row = 0; row < num_weight_rows; row++) {
for (uint32_t col = 0; col < num_weight_columns; col++) {
}
if (compute_precision_ == kDnnInt) {
if (num_bytes_per_weight == 1) {
- intel_compound_bias_t
- *ptr_biases = reinterpret_cast<intel_compound_bias_t *>(component[i].op.affine.ptr_biases);
+ gna_compound_bias_t
+ *ptr_biases = reinterpret_cast<gna_compound_bias_t *>(component[i].op.affine.ptr_biases);
#ifdef DUMP_WB
for (uint32_t row = 0; row < num_rows_out; row++) {
if (logging_precision == kDnnInt) {
if (num_bytes_per_weight == 1) {
int8_t *ptr_weight = reinterpret_cast<int8_t *>(component[i].op.conv1D.ptr_filters);
- intel_compound_bias_t *ptr_bias = reinterpret_cast<intel_compound_bias_t *>(component[i].op.conv1D.ptr_biases);
+ gna_compound_bias_t *ptr_bias = reinterpret_cast<gna_compound_bias_t *>(component[i].op.conv1D.ptr_biases);
#ifdef DUMP_WB
for (uint32_t row = 0; row < num_filters; row++) {
for (uint32_t col = 0; col < num_filter_coefficients; col++) {
if (compute_precision_ == kDnnInt) {
if (logging_precision == kDnnInt) {
if (num_bytes_per_weight == 1) {
- intel_compound_bias_t
- *ptr_biases = reinterpret_cast<intel_compound_bias_t *>(component[i].op.conv1D.ptr_biases);
+ gna_compound_bias_t
+ *ptr_biases = reinterpret_cast<gna_compound_bias_t *>(component[i].op.conv1D.ptr_biases);
#ifdef DUMP_WB
for (uint32_t row = 0; row < num_filters; row++) {
out_bfile << "0x" << std::setfill('0') << std::setw(8) << std::hex
<< GNAPluginNS::memory::MemoryOffset(component[i].op.recurrent.ptr_feedbacks, ptr_dnn_memory_) << "\n";
if (num_bytes_per_weight == 1) {
int8_t *ptr_weight = reinterpret_cast<int8_t *>(component[i].op.recurrent.ptr_weights);
- intel_compound_bias_t
- *ptr_bias = reinterpret_cast<intel_compound_bias_t *>(component[i].op.recurrent.ptr_biases);
+ gna_compound_bias_t
+ *ptr_bias = reinterpret_cast<gna_compound_bias_t *>(component[i].op.recurrent.ptr_biases);
#ifdef DUMP_WB
for (uint32_t row = 0; row < num_weight_rows; row++) {
out_file << "<weight_row> ";
if (compute_precision_ == kDnnInt) {
if (logging_precision == kDnnInt) {
if (num_bytes_per_weight == 1) {
- intel_compound_bias_t
- *ptr_biases = reinterpret_cast<intel_compound_bias_t *>(component[i].op.recurrent.ptr_biases);
+ gna_compound_bias_t
+ *ptr_biases = reinterpret_cast<gna_compound_bias_t *>(component[i].op.recurrent.ptr_biases);
out_file << "<compound_bias>" << " ";
#ifdef DUMP_WB
for (uint32_t col = 0; col < num_columns_out; col++) {
}
break;
case kDnnPiecewiselinearOp: {
- intel_pwl_segment_t *ptr_segment = component[i].op.pwl.ptr_segments;
+ gna_pwl_segment_t *ptr_segment = component[i].op.pwl.ptr_segments;
DnnActivationType func_id = component[i].op.pwl.func_id.type;
uint32_t num_segments = component[i].op.pwl.num_segments;
float output_scale_factor = component[i].output_scale_factor;
#include <vector>
#include "dnn_types.h"
+#include "gna_types.h"
#include "gna_plugin_log.hpp"
float input_scale_factor,
A *&ptr_inputs,
B *&ptr_outputs,
- intel_pwl_segment_t *ptr_segments) {
+ gna_pwl_segment_t *ptr_segments) {
InitPiecewiseLinearComponentPrivate(cmp,
function_id,
orientation,
float input_scale_factor,
void *&ptr_inputs,
void *&ptr_outputs,
- intel_pwl_segment_t *ptr_segments,
+ gna_pwl_segment_t *ptr_segments,
bool postInitMem);
static void InitInterleaveComponentPrivate(intel_dnn_component_t &cmp,
#include <cstdint>
#include <type_traits>
-#include <gna-api-types-xnn.h>
+#include "gna_types.h"
#include "gna_plugin_log.hpp"
typedef struct {
DnnActivation func_id; // identifies function being approximated
uint32_t num_segments;
- intel_pwl_segment_t *ptr_segments;
+ gna_pwl_segment_t *ptr_segments;
} intel_piecewiselinear_t;
typedef struct {
--- /dev/null
+// Copyright (C) 2018-2020 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#if GNA_LIB_VER == 1
+#include "gna_lib_ver_selector.hpp"
+#else
+#include <cstdint>
+
+/** PWL Segment - as read directly by the accelerator */
+typedef struct _pwl_segment_t {
+ int32_t xBase; // X Component of segment starting point, with scaling encoded if needed.
+ int16_t yBase; // Y Component of segment starting point.
+ int16_t slope; // Slope of linear function.
+} gna_pwl_segment_t;
+static_assert(8 == sizeof(gna_pwl_segment_t), "Invalid size of gna_pwl_segment_t");
+
+/** Piecewise-linear activation function (PWL) details */
+typedef struct _pwl_func_t {
+ uint32_t nSegments; // Number of segments, set to 0 to disable activation function.
+ gna_pwl_segment_t* pSegments; // Activation function segments data or NULL if disabled.
+} gna_pwl_func_t;
+
+/**
+ * Compound bias
+ * Used for nBytesPerWeight=GNA_INT8 and nBytesPerBias=GNA_INT16 only.
+ * As read directly by the accelerator.
+ */
+typedef struct _compound_bias_t {
+ int32_t bias; // 4B Signed integer bias (constant) value.
+ uint8_t multiplier; // Scaling factor that weight elements are multiplied by.
+ uint8_t reserved[3]; // Not used.
+} gna_compound_bias_t;
+static_assert(8 == sizeof(gna_compound_bias_t), "Invalid size of gna_compound_bias_t");
+
+/**
+ * Layer operation type.
+ * Defines type of layer "core" operation.
+ * All nodes/cells within a layer are of the same type,
+ * e.g. affine transform cell, convolutional cell, recurrent cell.
+ * Affine, convolutional and recurrent layers are in fact "fused operation" layers
+ * and "core" operation is fused with activation and/or pooling functions.
+ * NOTE: Operation types are exclusive.
+ */
+typedef enum _layer_operation {
+ // Fully connected affine transform (deep feed forward) with activation function. Cast pLayerStruct to intel_affine_layer_t.
+ INTEL_AFFINE,
+ // Fully connected affine transform (matrix x vector) (deep feed forward) with activation function.Cast pLayerStruct to intel_affine_layer_t.
+ INTEL_AFFINE_DIAGONAL,
+ /*
+ * Fully connected affine transform (with grouped bias vectors) (deep feed forward) with activation function.
+ * Cast pLayerStruct to intel_affine_multibias_layer_t.
+ */
+ INTEL_AFFINE_MULTIBIAS,
+ INTEL_CONVOLUTIONAL, // Convolutional transform with activation function and pooling. Cast pLayerStruct to intel_convolutional_layer_t.
+ INTEL_CONVOLUTIONAL_2D, // Convolutional transform with activation function and pooling. Cast pLayerStruct to nn_layer_cnn2d.
+ INTEL_COPY, // Auxiliary data copy operation. Cast pLayerStruct to intel_copy_layer_t.
+ INTEL_DEINTERLEAVE, // Auxiliary 2D tensor transpose operation (interleave to flat). No casting, always set pLayerStruct to null.
+ INTEL_GMM, // Gaussian Mixture Model operation. Cast pLayerStruct to intel_gmm_layer_t.
+ INTEL_INTERLEAVE, // Auxiliary 2D tensor transpose operation (flat to interleave). No casting, always set pLayerStruct to null.
+ INTEL_RECURRENT, // Fully connected affine transform with recurrence and activation function. Cast pLayerStruct to intel_recurrent_layer_t.
+ GNA_LAYER_CNN_2D_POOLING,
+ LAYER_OPERATION_TYPE_COUT,
+} gna_layer_operation;
+
+typedef enum _layer_mode {
+ INTEL_INPUT, // Layer serves as model input layer (usually first layer)
+ INTEL_OUTPUT, // Layer serves as model output layer (usually last layer)
+ INTEL_INPUT_OUTPUT, // Layer serves as model input nad output layer (usually in single layer topology)
+ INTEL_HIDDEN, // Layer serves as model hidden layer (layers between input and output layers)
+ LAYER_MODE_COUNT // Number of Layer modes.
+} gna_layer_mode;
+
+/** Layer common configuration descriptor */
+typedef struct _nnet_layer_t {
+ gna_layer_operation operation; // Layer operation type.
+ gna_layer_mode mode; // Layer connection mode.
+ uint32_t nInputColumns; // Number of input columns.
+ uint32_t nInputRows; // Number of input rows.
+ uint32_t nOutputColumns; // Number of output columns.
+ uint32_t nOutputRows; // Number of output rows.
+ uint32_t nBytesPerInput; // Precision/mode of input node, use a value from gna_data_mode. Valid values {GNA_INT8, GNA_INT16, GNA_DATA_DISABLED}
+ // Precision/ activation mode of output node, use a value from gna_data_mode. Valid values {GNA_INT8, GNA_INT16, GNA_INT32, GNA_DATA_ACTIVATION_DISABLED}
+ uint32_t nBytesPerOutput;
+ uint32_t nBytesPerIntermediateOutput;// Number of bytes per intermediate output node, always set to GNA_INT32.
+ void* pLayerStruct; // Layer detailed configuration, cast to intel_[LAYER_KIND]_layer_t.
+ void* pInputs; // Signed integer NN or GMM input buffer.
+ void* pOutputsIntermediate; // 4B Signed integer Auxiliary output buffer.
+ void* pOutputs; // Signed integer output buffer.
+} gna_nnet_layer_t;
+
+/** GNA Network descriptor */
+typedef struct _nnet_type_t {
+ uint32_t nLayers; // The number of layers in the network.
+ uint32_t nGroup; // Input vector grouping level.
+ gna_nnet_layer_t *pLayers; // Layer configurations.
+} gna_nnet_type_t;
+
+/** Affine function details */
+typedef struct _affine_func_t {
+ uint32_t nBytesPerWeight; // Precision/mode of weight element, use a value from gna_data_mode.
+ uint32_t nBytesPerBias; // Precision/mode of bias (constant) element, use a value from gna_data_mode.
+ void* pWeights; // Signed integer weights data buffer.
+ void* pBiases; // Biases (constants) data buffer. Signed integer biases or gna_compound_bias_t
+} gna_affine_func_t;
+
+/** Fully connected affine layer detailed descriptor */
+typedef struct _affine_layer_t {
+ gna_affine_func_t affine; // Affine function details.
+ gna_pwl_func_t pwl; // Activation function details.
+} gna_affine_layer_t;
+
+/** Pooling function types */
+typedef enum _pool_type_t {
+ INTEL_NO_POOLING = 0, // Pooling function disabled.
+ INTEL_MAX_POOLING = 1, // Max Pooling function.
+ INTEL_SUM_POOLING = 2, // Sum Pooling function.
+ NUM_POOLING_TYPES // Number of Pooling function types.
+} gna_pool_type_t;
+
+/** Convolutional Layer detailed descriptor */
+typedef struct _convolutional_layer_t {
+ uint32_t nFilters; // Number of filters.
+ uint32_t nFilterCoefficients; // Number of filter elements, including 0-padding if necessary.
+ uint32_t nFilterRows; // Number of rows in each filter.
+ uint32_t nBytesFilterCoefficient;// Precision/mode of filter coefficient element, use a value from gna_data_mode.
+ uint32_t nBytesBias; // Precision/mode of bias (constant) element, use a value from gna_data_mode.
+ uint32_t nFeatureMaps; // Number of feature maps.
+ uint32_t nFeatureMapRows; // Number of rows in each feature map.
+ uint32_t nFeatureMapColumns; // Number of columns in each feature map.
+ void* pFilters; // Signed integer Filters data buffer, filters stored one after the other.
+ void* pBiases; // Signed integer Biases (constants) data buffer, biases are specified per kernel/filter.
+ gna_pool_type_t poolType; // Pooling function type.
+ uint32_t nPoolSize; // Pool size, set 1 to disable pooling.
+ uint32_t nPoolStride; // Pool stride.
+ gna_pwl_func_t pwl; // Activation function details.
+} gna_convolutional_layer_t;
+
+/**
+ The list of processing acceleration modes.
+ Current acceleration modes availability depends on the CPU type.
+ Available modes are detected by GNA.
+
+ NOTE:
+ - GNA_HARDWARE: in some GNA hardware generations, model components unsupported
+ by hardware will be processed using software acceleration.
+ When software inference is used, by default "fast" algorithm is used
+ and results may be not bit-exact with these produced by hardware device.
+ */
+typedef enum _acceleration {
+ GNA_HARDWARE = static_cast<int>(0xFFFFFFFE), // GNA Hardware acceleration enforcement
+ GNA_AUTO = 0x3, // GNA selects the best available acceleration
+ GNA_SOFTWARE = 0x5, // GNA selects the best available software acceleration
+ GNA_GENERIC = 0x7, // Enforce the usage of generic software mode
+ GNA_SSE4_2 = 0x9, // Enforce the usage of SSE 4.2 CPU instruction set
+ GNA_AVX1 = 0xB, // Enforce the usage of AVX1 CPU instruction set
+ GNA_AVX2 = 0xD // Enforce the usage of AVX2 CPU instruction set
+} gna_acceleration;
+
+static_assert(4 == sizeof(gna_acceleration), "Invalid size of gna_acceleration");
+
+#endif
#include <runtime/pwl.h>
#include <gna_slope_scale.h>
#include "dnn_types.h"
+#include "backend/gna_types.h"
#include "round_float_define.hpp"
void make_gna_pwl(const DnnActivation fun,
const double u_bound,
const double in_scale,
const double out_scale,
- std::vector<intel_pwl_segment_t> &gna_pwl) {
+ std::vector<gna_pwl_segment_t> &gna_pwl) {
pwl_gna_slope_scale_t s;
uint32_t pwl_size = static_cast<int32_t>(pwl.size());
gnalog() << "make_gna_pwl\n";
#include <vector>
#include <runtime/pwl.h>
+#include "backend/gna_types.h"
void make_gna_pwl(const DnnActivation fun,
const double u_bound,
const double in_scale,
const double out_scale,
- std::vector<intel_pwl_segment_t> &gna_pwl);
+ std::vector<gna_pwl_segment_t> &gna_pwl);
#include <utility>
#include <cmath>
-#include <gna-api-types-xnn.h>
+#include "backend/gna_types.h"
#include "gna_plugin_log.hpp"
#include "quantized_layer_params.hpp"
#include "quantization.h"
_Np = InferenceEngine::Precision::MIXED;
}
};
-struct QuantI8 : public QuantDescTmpl<P_TYPE(I16), P_TYPE(I32), P_TYPE(I8), intel_compound_bias_t, P_TYPE(MIXED)> {
+struct QuantI8 : public QuantDescTmpl<P_TYPE(I16), P_TYPE(I32), P_TYPE(I8), gna_compound_bias_t, P_TYPE(MIXED)> {
QuantI8() {
_Np = InferenceEngine::Precision::MIXED;
}
}
template <>
-inline bool shouldAlwaysAllocate<intel_compound_bias_t>() {
+inline bool shouldAlwaysAllocate<gna_compound_bias_t>() {
return true;
}
#include <cstring>
#include <iostream>
#include <details/ie_exception.hpp>
+#include "backend/gna_types.h"
#include "quantization.h"
void QuantizeAffine16(float *ptr_float_weights,
}
void QuantizeAffine8(float *ptr_float_weights, float *ptr_float_biases,
- int8_t *ptr_int_weights, intel_compound_bias_t *ptr_int_biases,
+ int8_t *ptr_int_weights, gna_compound_bias_t *ptr_int_biases,
float input_scale_factor, float *ptr_weight_scale_factor,
float *ptr_output_scale_factor, uint32_t num_rows, uint32_t num_columns,
uint32_t num_rows_padded, uint32_t num_columns_padded) {
#pragma once
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
#include <vector>
#include <cstdint>
-#include <gna-api-types-xnn.h>
+#include "backend/gna_types.h"
#define MAX_OUT_MULTIPLIER 230
#define MAX_VAL_1B_WEIGHT 127
uint32_t num_columns_padded);
float ScaleFactorForQuantization(void *ptr_float_memory, float target_max, size_t num_elements);
void QuantizeVector16(float *ptr_float_memory, int16_t *ptr_int_memory, uint32_t num_elements, float scale_factor);
-void QuantizeAffine8(float *ptr_float_weights, float *ptr_float_biases, int8_t *ptr_int_weights, intel_compound_bias_t *ptr_int_biases,
+void QuantizeAffine8(float *ptr_float_weights, float *ptr_float_biases, int8_t *ptr_int_weights, gna_compound_bias_t *ptr_int_biases,
float input_scale_factor, float *ptr_weight_scale_factor, float *ptr_output_scale_factor,
uint32_t num_rows, uint32_t num_columns, uint32_t num_rows_padded, uint32_t num_columns_padded);
#else
#include <mm_malloc.h>
#endif
-#include <gna-api-types-xnn.h>
+#include "backend/gna_types.h"
#include "gna_plugin_log.hpp"
#if GNA_LIB_VER == 2
};
#else
template <>
-class CPPWrapper<intel_nnet_type_t> {
+class CPPWrapper<gna_nnet_type_t> {
public:
intel_nnet_type_t obj;
#include <limits>
#include <legacy/ie_layers.h>
-#include <gna-api-types-xnn.h>
#include <ie_algorithm.hpp>
#include <debug.h>
#include "layers/gna_layer_info.hpp"
#include "ie_memcpy.h"
#include "caseless.hpp"
-#include "gna-api.h"
#include "backend/am_intel_dnn.hpp"
#include "runtime/pwl.h"
#include "gna_graph_tools.hpp"
}
} else {
//use PWL to calculate power
- std::vector<intel_pwl_segment_t> ptr_pwl_segments;
+ std::vector<gna_pwl_segment_t> ptr_pwl_segments;
auto orientation = kDnnInterleavedOrientation;
auto& pwlComponent = dnnComponents.addComponent(layer->name, "power");
- intel_pwl_segment_t* ptr_pwl_segments_target = nullptr;
+ gna_pwl_segment_t* ptr_pwl_segments_target = nullptr;
float output_pwl_scale_factor = quantized != nullptr ? quantized->_dst_quant.scale : 1.0f;
float input_pwl_scale_factor = quantized != nullptr ? quantized->_src_quant.scale : 1.0f;
}
}
- ptr_pwl_segments_target = reinterpret_cast<intel_pwl_segment_t*>(&ptr_pwl_segments_target);
+ ptr_pwl_segments_target = reinterpret_cast<gna_pwl_segment_t*>(&ptr_pwl_segments_target);
void* ptr_pwl_input = nullptr;
void* ptr_pwl_outputs = nullptr;
if (ptr_pwl_segments_target != nullptr) {
gnamem->readonly().push_local_ptr(ptr_pwl_segments_target,
&ptr_pwl_segments.front(),
- ptr_pwl_segments.size() * sizeof(intel_pwl_segment_t),
+ ptr_pwl_segments.size() * sizeof(gna_pwl_segment_t),
64);
}
}
void GNAGraphCompiler::PWLPrimitive(InferenceEngine::CNNLayerPtr layer) {
auto* generic = dynamic_cast<GenericLayer*>(layer.get());
std::string type;
- std::vector<intel_pwl_segment_t> ptr_pwl_segments;
+ std::vector<gna_pwl_segment_t> ptr_pwl_segments;
uint32_t num_rows;
uint32_t num_columns;
void* ptr_inputs = nullptr;
#endif
auto& currentComponent = dnnComponents.addComponent(layer->name, actName);
-
- intel_pwl_segment_t* ptr_pwl_segments_target = nullptr;
+ gna_pwl_segment_t* ptr_pwl_segments_target = nullptr;
if (!gnaFlags->sw_fp32) {
// TODO: generalize activation function code
input_pwl_scale_factor,
output_pwl_scale_factor);
}
- ptr_pwl_segments_target = reinterpret_cast<intel_pwl_segment_t*>(&ptr_pwl_segments_target);
+ ptr_pwl_segments_target = reinterpret_cast<gna_pwl_segment_t*>(&ptr_pwl_segments_target);
}
dnn->InitPiecewiseLinearComponent(currentComponent,
if (ptr_pwl_segments_target != nullptr) {
gnamem->readonly().push_local_ptr(ptr_pwl_segments_target,
&ptr_pwl_segments.front(),
- ptr_pwl_segments.size() * sizeof(intel_pwl_segment_t),
+ ptr_pwl_segments.size() * sizeof(gna_pwl_segment_t),
64);
}
}
// gna_helper.cpp : various GNA-related utility functions
//
-#define PROFILE
-
#include <cstdint>
#include <cstdio>
#include <fstream>
#include <vector>
#include <sstream>
#include <string>
-#include <gna-api-types-xnn.h>
+#include "backend/gna_types.h"
#include "gna_plugin_log.hpp"
#include "gna_lib_ver_selector.hpp"
}
}
-void PrintGnaNetwork(intel_nnet_type_t *ptr_nnet) {
- PrintMatrixInt16("input", reinterpret_cast<int16_t*>(ptr_nnet->pLayers[0].pInputs),
- ptr_nnet->pLayers[0].nInputRows, ptr_nnet->pLayers[0].nInputColumns, ptr_nnet->pLayers[0].nInputColumns, 1.0);
- for (uint32_t i = 0; i < ptr_nnet->nLayers; i++) {
- char name[256];
- snprintf(name, sizeof(name), "output %d", i);
- if (ptr_nnet->pLayers[i].nBytesPerOutput == 2) {
- PrintMatrixInt16(name, reinterpret_cast<int16_t*>(ptr_nnet->pLayers[i].pOutputs),
- ptr_nnet->pLayers[i].nOutputRows, ptr_nnet->pLayers[i].nOutputColumns, ptr_nnet->pLayers[i].nOutputColumns, 1.0);
- } else {
- PrintMatrixInt32(name, reinterpret_cast<int32_t*>(ptr_nnet->pLayers[i].pOutputs),
- ptr_nnet->pLayers[i].nOutputRows, ptr_nnet->pLayers[i].nOutputColumns, ptr_nnet->pLayers[i].nOutputColumns, 1.0);
- }
- }
-}
typedef struct {
std::string sName;
return (nOffsetBytes);
}
-std::string LayerName(intel_nnet_layer_t *pLayer) {
+std::string LayerName(gna_nnet_layer_t *pLayer) {
const auto nKind = pLayer->nLayerKind;
std::string sKind;
if (nKind == INTEL_AFFINE) {
return (sKind);
}
-uint32_t NumInputs(intel_nnet_layer_t *pLayer) {
+uint32_t NumInputs(gna_nnet_layer_t *pLayer) {
const auto nKind = pLayer->nLayerKind;
uint32_t nInputs;
if ((nKind == INTEL_AFFINE) || (nKind == INTEL_AFFINE_DIAGONAL)) {
return (nInputs);
}
-uint32_t NumOutputs(intel_nnet_layer_t *pLayer) {
+uint32_t NumOutputs(gna_nnet_layer_t *pLayer) {
const auto nKind = pLayer->nLayerKind;
uint32_t nOutputs;
if ((nKind == INTEL_AFFINE) || (nKind == INTEL_AFFINE_DIAGONAL)) {
return (nOutputs);
}
-uint32_t NumGroupSize(intel_nnet_layer_t *pLayer) {
+uint32_t NumGroupSize(gna_nnet_layer_t *pLayer) {
const auto nKind = pLayer->nLayerKind;
uint32_t nGroupSize;
if ((nKind == INTEL_AFFINE) || (nKind == INTEL_AFFINE_DIAGONAL)) {
#if GNA_LIB_VER == 2
#include <cstdint>
-#include <gna-api-types-xnn.h>
#define nLayerKind operation
#define intel_layer_kind_t gna_layer_operation
#define intel_gna_proc_t uint32_t
+
+
+/**
+ * Rounds a number up, to the nearest multiple of significance
+ * Used for calculating the memory sizes of GNA data buffers
+ *
+ * @param number Memory size or a number to round up.
+ * @param significance Informs the function how to round up. The function "ceils"
+ * the number to the lowest possible value divisible by "significance".
+ * @return Rounded integer value.
+ */
+#define ALIGN(number, significance) ((((number) + (significance) - 1) / (significance)) * (significance))
+
+/**
+ * Rounds a number up, to the nearest multiple of 64
+ * Used for calculating memory sizes of GNA data arrays
+ */
+#define ALIGN64(number) ALIGN(number, 64)
+
+#else
+
+#include <gna-api.h>
+#include <gna-api-types-xnn.h>
+
+#define gna_pwl_segment_t intel_pwl_segment_t
+#define gna_compound_bias_t intel_compound_bias_t
+#define gna_nnet_layer_t intel_nnet_layer_t
+#define gna_nnet_type_t intel_nnet_type_t
+#define gna_affine_func_t intel_affine_func_t
+#define gna_affine_layer_t intel_affine_layer_t
+#define gna_convolutional_layer_t intel_convolutional_layer_t
#endif
#include <vector>
#include <utility>
-#include <gna-api.h>
#include "descriptions/gna_input_desc.hpp"
#include "descriptions/gna_output_desc.hpp"
#include "gna_plugin_log.hpp"
#include "ie_layers.h"
#include "caseless.hpp"
#include "ie_algorithm.hpp"
-#include "gna-api.h"
+#include "backend/gna_types.h"
#include "gna_permute.hpp"
+#include "gna_lib_ver_selector.hpp"
namespace GNAPluginNS {
#include <list>
#include <algorithm>
#include <functional>
-
-#include <gna-api.h>
+#include "gna_lib_ver_selector.hpp"
namespace GNAPluginNS {
namespace memory {
#include <iomanip>
#include <legacy/graph_transformer.h>
-#include <gna-api.h>
#include <blob_factory.hpp>
#include <ie_memcpy.h>
#include <ie_algorithm.hpp>
#include <limits>
#include <cstdint>
#include <algorithm>
+#include "backend/gna_types.h"
#ifdef _NO_MKL_
#include <cmath>
void PwlDesignOpt16(const DnnActivation activation_type,
- std::vector<intel_pwl_segment_t> &ptr_segment,
+ std::vector<gna_pwl_segment_t> &ptr_segment,
const float scale_in,
const float scale_out) {
std::vector<pwl_t> pwl;
}
void PwlDesign16(const DnnActivation activation_type,
- intel_pwl_segment_t *ptr_segment,
+ gna_pwl_segment_t *ptr_segment,
const uint32_t num_segments,
const float scale_in,
const float scale_out) {
uint32_t num_saturate = 0;
uint32_t num_segments = component->op.pwl.num_segments;
if (num_segments > 0) {
- intel_pwl_segment_t *ptr_segment = component->op.pwl.ptr_segments;
+ gna_pwl_segment_t *ptr_segment = component->op.pwl.ptr_segments;
for (int i = num_row_start; i <= num_row_end; i++) {
int32_t *ptr_input = reinterpret_cast<int32_t *>(component->ptr_inputs) + i * component->num_columns_in;
int16_t *ptr_output = reinterpret_cast<int16_t *>(component->ptr_outputs) + i * component->num_columns_in;
#include <cstdint>
#include "backend/dnn_types.h"
+#include "backend/gna_types.h"
#define SIGMOID_NUM_SEGMENTS 65
#define SIGMOID_DOMAIN 10.0f // portion of input to be approximated (-10,10)
const uint32_t num_col_start,
const uint32_t num_col_end);
void PwlDesign16(const DnnActivation activation_type,
- intel_pwl_segment_t *ptr_segment,
+ gna_pwl_segment_t *ptr_segment,
const uint32_t num_segments,
const float scale_in,
const float scale_out);
void PwlDesignOpt16(const DnnActivation activation_type,
- std::vector<intel_pwl_segment_t> &ptr_segment,
+ std::vector<gna_pwl_segment_t> &ptr_segment,
const float scale_in,
const float scale_out);
#if GNA_LIB_VER == 1
GTEST_SKIP();
#endif
- auto & nnet_type = storage<intel_nnet_type_t>();
+ auto & nnet_type = storage<gna_nnet_type_t>();
// saving pointer to nnet - todo probably deep copy required
save_args().onInferModel(AffineWith2AffineOutputsModel())
TEST_F(GNAAOTTests, DISABLED_CanConvertFromAOTtoSueModel) {
- auto & nnet_type = storage<intel_nnet_type_t>();
+ auto & nnet_type = storage<gna_nnet_type_t>();
// saving pointer to nnet - todo probably deep copy required
save_args().onInferModel(AffineWith2AffineOutputsModel())
nnet_input_precision(Precision::I16).
nnet_ouput_precision(Precision::I32).
nnet_weights_precision(Precision::I8).
- nnet_biases_precision(Precision::fromType<intel_compound_bias_t>());
+ nnet_biases_precision(Precision::fromType<gna_compound_bias_t>());
}
TEST_F(GNAHWPrecisionTest, canPassInt16Precision) {
#include "gna_matcher.hpp"
#include <gna/gna_config.hpp>
-#include <gna-api-types-xnn.h>
+#include "backend/gna_types.h"
#include <gna_executable_network.hpp>
#include "gna_plugin.hpp"
#include "gna_mock_api.hpp"
#include <backend/dnn_types.h>
#include <gna_plugin_policy.hpp>
-#include <gna-api.h>
+#include <backend/gna_types.h>
#include <gna/gna_config.hpp>
#include <gna_plugin.hpp>
#include <gna_lib_ver_selector.hpp>
return *this;
}
- GNAPropagateMatcher & exact_nnet_structure(intel_nnet_type_t * pNet) {
+ GNAPropagateMatcher & exact_nnet_structure(gna_nnet_type_t * pNet) {
getMatcher().type = GnaPluginTestEnvironment::exactNNetStructure;
original_nnet = pNet;
return * this;
}
- GNAPropagateMatcher & to(intel_nnet_type_t *savedNet) {
+ GNAPropagateMatcher & to(gna_nnet_type_t *savedNet) {
this->savedNet = savedNet;
return *this;
}
protected:
void match();
- intel_nnet_type_t * original_nnet = nullptr;
- intel_nnet_type_t * savedNet = nullptr;
+ gna_nnet_type_t * original_nnet = nullptr;
+ gna_nnet_type_t * savedNet = nullptr;
};
#include <vector>
#include <gtest/gtest.h>
#include <legacy/layer_transform.hpp>
-#include <gna-api-types-xnn.h>
+#include "backend/gna_types.h"
#include "frontend/model_quantizer.hpp"
#include "frontend/layer_quantizer.hpp"
#include "gna_matcher.hpp"
#pragma once
-#include"gna-api.h"
+#include "backend/gna_types.h"
#include "nnet_base_matcher.hpp"
#include "frontend/quantization.h"
-class ConvoluionLayerMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t*> {
+class ConvoluionLayerMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t*> {
bool matchInserted;
int matchQuantity;
public:
ConvoluionLayerMatcher(bool matchInserted, int matchQuantity) : matchInserted(matchInserted), matchQuantity(matchQuantity) {}
- bool MatchAndExplain(const intel_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
if (foo == nullptr)
return false;
for(int i = 0; i < foo->nLayers; i++) {
if (foo->pLayers[i].nLayerKind != INTEL_CONVOLUTIONAL) continue;
- auto conv = (intel_convolutional_layer_t*)foo->pLayers[i].pLayerStruct;
+ auto conv = (gna_convolutional_layer_t*)foo->pLayers[i].pLayerStruct;
return matchInserted;
}
//
#pragma once
+
#include "nnet_base_matcher.hpp"
-class CopyLayerMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t*> {
+#include "backend/gna_types.h"
+
+class CopyLayerMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t*> {
bool matchInserted;
const int matchQuantity;
mutable int actualNumberOfCopyLayers;
public:
CopyLayerMatcher(bool matchInserted, int matchQuantity) : matchInserted(matchInserted), matchQuantity(matchQuantity) {}
- bool MatchAndExplain(const intel_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
if (foo == nullptr)
return false;
actualNumberOfCopyLayers = 0;
}
};
-inline ::testing::Matcher<const intel_nnet_type_t*> HasCopyLayer(bool matchInserted = false, int matchQuantity = -1) {
+inline ::testing::Matcher<const gna_nnet_type_t*> HasCopyLayer(bool matchInserted = false, int matchQuantity = -1) {
std::unique_ptr<NNetComponentMatcher> c (new NNetComponentMatcher());
c->add(new CopyLayerMatcher(matchInserted, matchQuantity));
return ::testing::MakeMatcher(c.release());
//
#pragma once
-#include"gna-api.h"
+
+#include "backend/gna_types.h"
#include "nnet_base_matcher.hpp"
#include "frontend/quantization.h"
-class DiagLayerMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t*> {
+class DiagLayerMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t*> {
bool matchInserted;
int matchQuantity;
mutable int actualQuantity;
public:
DiagLayerMatcher(bool matchInserted, int matchQuantity) : matchInserted(matchInserted), matchQuantity(matchQuantity) {}
- bool MatchAndExplain(const intel_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
if (foo == nullptr)
return false;
actualQuantity = 0;
if (foo->pLayers[i].nLayerKind != INTEL_AFFINE_DIAGONAL) continue;
// diagonal layer has to have 1 for weights and 0 for biases
- auto diag = (intel_affine_func_t*)foo->pLayers[i].pLayerStruct;
+ auto diag = (gna_affine_func_t*)foo->pLayers[i].pLayerStruct;
bool bWeightsOK = true;
int beforePadding = 0;
}
};
-inline ::testing::Matcher<const intel_nnet_type_t*> HasDiagonalLayer(bool matchInserted = false, int matchQuantity = -1) {
+inline ::testing::Matcher<const gna_nnet_type_t*> HasDiagonalLayer(bool matchInserted = false, int matchQuantity = -1) {
std::unique_ptr<NNetComponentMatcher> c (new NNetComponentMatcher());
c->add(new DiagLayerMatcher(matchInserted, matchQuantity));
return ::testing::MakeMatcher(c.release());
#pragma once
+#include "backend/gna_types.h"
-class OutputFiller : public ::testing::MatcherInterface<const intel_nnet_type_t*> {
+class OutputFiller : public ::testing::MatcherInterface<const gna_nnet_type_t*> {
mutable std::stringstream reason;
int32_t fill32BValue;
int16_t fill16BValue;
OutputFiller(int32_t fill32BValue, int16_t fill16BValue) : fill32BValue(fill32BValue), fill16BValue(fill16BValue) {}
- bool MatchAndExplain(const intel_nnet_type_t* foo, ::testing::MatchResultListener* listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t* foo, ::testing::MatchResultListener* listener) const override {
if (foo == nullptr)
return false;
reason.str("");
#pragma once
#include <gmock/gmock-matchers.h>
+#include "backend/gna_types.h"
#include "nnet_base_matcher.hpp"
-class InputDataMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t *> {
+class InputDataMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t *> {
std::vector<int16_t> refInput;
public:
explicit InputDataMatcher(const std::vector<int16_t> &_refInput) : refInput(_refInput) {}
- bool MatchAndExplain(const intel_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
if (foo->pLayers == nullptr) {
*listener << "Address of the first layer descriptor is NULL";
return false;
//
#pragma once
+
+#include "backend/gna_types.h"
#include "gna_lib_ver_selector.hpp"
-class NNetComponentMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t*> {
- std::vector<std::shared_ptr<::testing::MatcherInterface<const intel_nnet_type_t*>>> matchers;
+class NNetComponentMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t*> {
+ std::vector<std::shared_ptr<::testing::MatcherInterface<const gna_nnet_type_t*>>> matchers;
mutable int failIdx = -1;
mutable std::stringstream reason;
int bitness;
public:
NNetComponentMatcher(int bitness = 16) : bitness(bitness) {}
- NNetComponentMatcher& add(::testing::MatcherInterface<const intel_nnet_type_t*> * p) {
- matchers.push_back(std::shared_ptr<::testing::MatcherInterface<const intel_nnet_type_t*>>(p));
+ NNetComponentMatcher& add(::testing::MatcherInterface<const gna_nnet_type_t*> * p) {
+ matchers.push_back(std::shared_ptr<::testing::MatcherInterface<const gna_nnet_type_t*>>(p));
return *this;
}
bool empty() const {
return matchers.empty();
}
- bool MatchAndExplain(const intel_nnet_type_t* foo, ::testing::MatchResultListener* listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t* foo, ::testing::MatchResultListener* listener) const override {
if (foo == nullptr)
return false;
reason.str("");
}
if (foo->pLayers[j].nLayerKind == INTEL_AFFINE ||
foo->pLayers[j].nLayerKind == INTEL_AFFINE_DIAGONAL) {
- auto pAffine = reinterpret_cast<intel_affine_func_t*>(foo->pLayers[j].pLayerStruct);
+ auto pAffine = reinterpret_cast<gna_affine_func_t*>(foo->pLayers[j].pLayerStruct);
if (pAffine->pWeights == foo->pLayers[i].pOutputs) {
reason << "numberOfBytes per output int pLayers[" << i << "] should be " << (bitness/8) << ", but was "
#pragma once
-#include"gna-api.h"
+#include "backend/gna_types.h"
#include "nnet_base_matcher.hpp"
#include "frontend/quantization.h"
-class PoolingLayerMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t*> {
+class PoolingLayerMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t*> {
bool matchInserted;
int matchQuantity;
bool bMaxPool;
public:
PoolingLayerMatcher(bool matchInserted, int matchQuantity, bool bMaxPool)
: matchInserted(matchInserted), matchQuantity(matchQuantity), bMaxPool(bMaxPool) {}
- bool MatchAndExplain(const intel_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
if (foo == nullptr)
return false;
for(int i = 0; i < foo->nLayers; i++) {
if (foo->pLayers[i].nLayerKind != INTEL_CONVOLUTIONAL) continue;
- auto conv = (intel_convolutional_layer_t*)foo->pLayers[i].pLayerStruct;
+ auto conv = (gna_convolutional_layer_t*)foo->pLayers[i].pLayerStruct;
if (conv->poolType != INTEL_MAX_POOLING) continue;
return matchInserted;
#pragma once
#include "nnet_base_matcher.hpp"
+#include "backend/gna_types.h"
#include "gna_lib_ver_selector.hpp"
-class NNetPrecisionMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t*> {
+class NNetPrecisionMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t*> {
GnaPluginTestEnvironment::NnetPrecision nnetPrecision;
intel_layer_kind_t layerKind = (intel_layer_kind_t)-1;
public:
explicit NNetPrecisionMatcher(GnaPluginTestEnvironment::NnetPrecision nnetPrecision,
intel_layer_kind_t layerKind = (intel_layer_kind_t)-1) : nnetPrecision(nnetPrecision), layerKind(layerKind) {}
- bool MatchAndExplain(const intel_nnet_type_t* foo, ::testing::MatchResultListener* listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t* foo, ::testing::MatchResultListener* listener) const override {
auto ioPrecision = (foo->pLayers->nBytesPerInput == nnetPrecision.input_precision.size()) &&
(foo->pLayers->nBytesPerOutput== nnetPrecision.output_precision.size());
}
switch (layerKind) {
case INTEL_AFFINE : {
- auto affine = (intel_affine_layer_t *) (foo->pLayers->pLayerStruct);
+ auto affine = (gna_affine_layer_t *) (foo->pLayers->pLayerStruct);
return affine->affine.nBytesPerBias == nnetPrecision.biases_precision.size() &&
affine->affine.nBytesPerWeight == nnetPrecision.weights_precision.size();
}
};
-inline ::testing::Matcher<const intel_nnet_type_t*> BitnessOfNNetEq(GnaPluginTestEnvironment::NnetPrecision nnetPrecision,
+inline ::testing::Matcher<const gna_nnet_type_t*> BitnessOfNNetEq(GnaPluginTestEnvironment::NnetPrecision nnetPrecision,
intel_layer_kind_t component) {
std::unique_ptr<NNetComponentMatcher> c (new NNetComponentMatcher());
c->add(new NNetPrecisionMatcher(nnetPrecision, component));
extern void PwlApply16(intel_dnn_component_t *component, uint32_t num_subset_size);
-class PWLMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t*> {
+class PWLMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t*> {
bool matchInserted;
int matchQuantity;
mutable int timesInserted = 0;
: matchInserted(inserted), matchQuantity(matchQuantity), activationsToLookFor(particularActivations) {
}
- bool MatchAndExplain(const intel_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
if (foo == nullptr)
return false;
timesInserted = 0;
if (foo->pLayers[i].nLayerKind != INTEL_AFFINE &&
foo->pLayers[i].nLayerKind != INTEL_AFFINE_DIAGONAL &&
foo->pLayers[i].nLayerKind != INTEL_CONVOLUTIONAL) continue;
- auto affine = reinterpret_cast<intel_affine_layer_t*>(foo->pLayers[i].pLayerStruct);
+ auto affine = reinterpret_cast<gna_affine_layer_t*>(foo->pLayers[i].pLayerStruct);
if (affine == nullptr) continue;
bool hasPwl = affine->pwl.nSegments != 0 && affine->pwl.pSegments != nullptr;
return timesInserted == 0;
};
- DnnActivationType detectPwlType(intel_nnet_layer_t *layer) const {
+ DnnActivationType detectPwlType(gna_nnet_layer_t *layer) const {
intel_dnn_component_t comp;
comp.ptr_outputs = layer->pOutputs;
if (layer->nLayerKind == INTEL_AFFINE ||
layer->nLayerKind == INTEL_AFFINE_DIAGONAL) {
- auto pAffineLayer = reinterpret_cast<intel_affine_layer_t *>(layer->pLayerStruct);
+ auto pAffineLayer = reinterpret_cast<gna_affine_layer_t *>(layer->pLayerStruct);
comp.op.pwl.num_segments = pAffineLayer->pwl.nSegments;
comp.op.pwl.ptr_segments = pAffineLayer->pwl.pSegments;
} else if (layer->nLayerKind == INTEL_CONVOLUTIONAL) {
- auto pConvolutionalLayer = reinterpret_cast<intel_convolutional_layer_t *>(layer->pLayerStruct);
+ auto pConvolutionalLayer = reinterpret_cast<gna_convolutional_layer_t *>(layer->pLayerStruct);
comp.op.pwl.num_segments = pConvolutionalLayer->pwl.nSegments;
comp.op.pwl.ptr_segments = pConvolutionalLayer->pwl.pSegments;
} else {
#include <iostream>
#include <runtime/pwl.h>
+#include <backend/gna_types.h>
#include "nnet_base_matcher.hpp"
-class PWLQuantizationMetricsMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t*> {
+class PWLQuantizationMetricsMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t*> {
const float rmse_threshold;
const uint32_t activation_type;
const uint16_t segment_threshold;
rmse_threshold(precision_threshold),
segment_threshold(segments) {}
- bool MatchAndExplain(const intel_nnet_type_t *nnet, ::testing::MatchResultListener *listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t *nnet, ::testing::MatchResultListener *listener) const override {
float rmse = 0.f;
const float test_arg_scale_factor = 16384;
nnet->pLayers[i].nLayerKind != INTEL_AFFINE_DIAGONAL &&
nnet->pLayers[i].nLayerKind != INTEL_CONVOLUTIONAL) continue;
- auto affine = reinterpret_cast<intel_affine_layer_t*>(nnet->pLayers[i].pLayerStruct);
+ auto affine = reinterpret_cast<gna_affine_layer_t*>(nnet->pLayers[i].pLayerStruct);
if (affine == nullptr ||
affine->pwl.nSegments == 0 ||
}
std::vector<double> y_diviation(2*domain);
- std::vector<intel_pwl_segment_t*> segments_vector(affine->pwl.nSegments);
+ std::vector<gna_pwl_segment_t*> segments_vector(affine->pwl.nSegments);
std::iota(segments_vector.begin(), segments_vector.begin()+affine->pwl.nSegments,
affine->pwl.pSegments);
}
};
-inline ::testing::Matcher<const intel_nnet_type_t*> PrecisionOfQuantizedPwlMetrics(uint32_t type,
+inline ::testing::Matcher<const gna_nnet_type_t*> PrecisionOfQuantizedPwlMetrics(uint32_t type,
float threshold,
uint16_t segments) {
std::unique_ptr<NNetComponentMatcher> c (new NNetComponentMatcher());
//
#pragma once
-#include"gna-api.h"
+#include "backend/gna_types.h"
#include "nnet_base_matcher.hpp"
#include "frontend/quantization.h"
}
};
-class WeightsMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t*> {
+class WeightsMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t*> {
enum HowMatch{
eNone,
eEq,
eMatchKind = eEq;
}
}
- bool MatchAndExplain(const intel_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
if (foo == nullptr)
return false;
iterator.reset();
if (foo->pLayers[i].nLayerKind != INTEL_AFFINE &&
foo->pLayers[i].nLayerKind != INTEL_AFFINE_DIAGONAL) continue;
- auto affine = (intel_affine_func_t*)foo->pLayers[i].pLayerStruct;
+ auto affine = (gna_affine_func_t*)foo->pLayers[i].pLayerStruct;
auto affineWeightsSize = foo->pLayers[i].nOutputRows *
(foo->pLayers[i].nLayerKind == INTEL_AFFINE_DIAGONAL ? 1 : foo->pLayers[i].nInputRows);
}
};
-class WeightsSizeMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t*> {
+class WeightsSizeMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t*> {
enum HowMatch{
eNone,
eEqAffine,
eMatchKind(eEqAffine),
expected_weights_size(data_len){
}
- bool MatchAndExplain(const intel_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
if (foo == nullptr)
return false;
};
-class WeightsSaver: public ::testing::MatcherInterface<const intel_nnet_type_t*> {
+class WeightsSaver: public ::testing::MatcherInterface<const gna_nnet_type_t*> {
mutable TranspozeIterator iterator;
std::vector<uint16_t>* weights;
public:
explicit WeightsSaver(TranspozedData data) :
weights(std::get<0>(data)), iterator(data) {
}
- bool MatchAndExplain(const intel_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
+ bool MatchAndExplain(const gna_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
if (foo == nullptr)
return false;
for(int i = 0; i < foo->nLayers; i++) {
if (foo->pLayers[i].nLayerKind != INTEL_AFFINE) continue;
- auto affine = (intel_affine_func_t*)foo->pLayers[i].pLayerStruct;
+ auto affine = (gna_affine_func_t*)foo->pLayers[i].pLayerStruct;
auto affineWeightsSize = foo->pLayers[i].nOutputRows * foo->pLayers[i].nInputRows;
auto pWeights = reinterpret_cast<uint16_t *>(affine->pWeights);