Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 1 | |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame^] | 2 | // Copyright (c) 2020-2022, ARM Limited. |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | #include "tensor.h" |
| 17 | #include "arith_util.h" |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame^] | 18 | #include "half.hpp" |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 19 | |
| 20 | using namespace TosaReference; |
| 21 | using namespace Eigen; |
| 22 | using namespace tosa; |
| 23 | |
Kevin Cheng | acb550f | 2021-06-29 15:32:19 -0700 | [diff] [blame] | 24 | TosaReference::Tensor::Tensor(std::string tensorName_, DType tensorDtype_, std::vector<int> shape_) |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 25 | { |
Kevin Cheng | acb550f | 2021-06-29 15:32:19 -0700 | [diff] [blame] | 26 | tensorName = std::string(tensorName_); |
| 27 | tensorDtype = tensorDtype_; |
| 28 | shape = std::vector<int>(shape_); |
| 29 | producer = nullptr; |
| 30 | isValid = false; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 31 | consumers.clear(); |
| 32 | isSubgraphInput = false; |
| 33 | isSubgraphOutput = false; |
| 34 | } |
| 35 | |
| 36 | TosaReference::Tensor::~Tensor() |
| 37 | {} |
| 38 | |
| 39 | int TosaReference::Tensor::setIsSubgraphInput() |
| 40 | { |
| 41 | isSubgraphInput = true; |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | int TosaReference::Tensor::setIsSubgraphOutput() |
| 46 | { |
| 47 | isSubgraphOutput = true; |
| 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | int TosaReference::Tensor::setProducer(GraphNode* node) |
| 52 | { |
| 53 | ASSERT_MSG(node, "Tensor::setProducer: no node passed in"); |
| 54 | ASSERT_MSG(!producer, "Tensor::setProducer: producer node already set, tensor %s", tensorName.c_str()); |
| 55 | producer = node; |
| 56 | |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | int TosaReference::Tensor::addConsumer(GraphNode* node) |
| 61 | { |
| 62 | ASSERT_MSG(node, "Tensor::addConsumer: no node passed in"); |
| 63 | consumers.push_back(node); |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | int TosaReference::Tensor::dumpTensorParams(FILE* out) const |
| 69 | { |
Kevin Cheng | 550ccc5 | 2021-03-03 11:21:43 -0800 | [diff] [blame] | 70 | fprintf(out, "Name: %s DType=%s isValid=%d Rank=%d Shape=%s\n", tensorName.c_str(), EnumNamesDType()[getDtype()], |
| 71 | getIsValid(), getRank(), getShapeAsString().c_str()); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | int TosaReference::Tensor::dumpTensorParams(std::ostream& out) const |
| 77 | { |
Kevin Cheng | 550ccc5 | 2021-03-03 11:21:43 -0800 | [diff] [blame] | 78 | out << "Name: " << getName() << " DType=" << EnumNamesDType()[getDtype()] << " isValid=" << getIsValid() |
| 79 | << " Rank=" << getRank() << " Shape=" << getShapeAsString() << "\n"; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 80 | |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | int TosaReference::Tensor::readFromNpyFile(const char* filename) |
| 85 | { |
| 86 | uint32_t elements = getElementCount(); |
| 87 | float* fdatabuf = nullptr; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame^] | 88 | half_float::half* f16databuf = nullptr; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 89 | int32_t* i32databuf = nullptr; |
| 90 | int64_t* i64databuf = nullptr; |
| 91 | bool* bdatabuf = nullptr; |
| 92 | NumpyUtilities::NPError nperror; |
| 93 | |
| 94 | switch (getDtype()) |
| 95 | { |
| 96 | case DType_FLOAT: |
| 97 | fdatabuf = (float*)calloc(sizeof(float), elements); |
| 98 | ASSERT_MEM(fdatabuf); |
| 99 | |
| 100 | nperror = NumpyUtilities::readFromNpyFile(filename, elements, fdatabuf); |
| 101 | break; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame^] | 102 | case DType_FP16: |
| 103 | f16databuf = (half_float::half*)calloc(sizeof(half_float::half), elements); |
| 104 | ASSERT_MEM(f16databuf); |
| 105 | fdatabuf = (float*)calloc(sizeof(float), elements); |
| 106 | ASSERT_MEM(fdatabuf); |
| 107 | |
| 108 | nperror = NumpyUtilities::readFromNpyFile(filename, elements, f16databuf); |
| 109 | break; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 110 | case DType_INT32: |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 111 | case DType_UINT8: |
| 112 | case DType_INT4: |
| 113 | case DType_INT8: |
| 114 | case DType_INT16: |
Jeremy Johnson | f7f78ae | 2022-05-25 15:26:38 +0100 | [diff] [blame] | 115 | case DType_UINT16: |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 116 | i32databuf = (int32_t*)calloc(sizeof(int32_t), elements); |
| 117 | ASSERT_MEM(i32databuf); |
| 118 | |
| 119 | nperror = NumpyUtilities::readFromNpyFile(filename, elements, i32databuf); |
| 120 | break; |
| 121 | case DType_INT48: |
| 122 | i64databuf = (int64_t*)calloc(sizeof(int64_t), elements); |
| 123 | ASSERT_MEM(i64databuf); |
| 124 | |
| 125 | nperror = NumpyUtilities::readFromNpyFile(filename, elements, i64databuf); |
| 126 | break; |
| 127 | case DType_BOOL: |
| 128 | bdatabuf = (bool*)calloc(sizeof(bool), elements); |
| 129 | ASSERT_MEM(bdatabuf); |
| 130 | |
| 131 | nperror = NumpyUtilities::readFromNpyFile(filename, elements, bdatabuf); |
| 132 | break; |
| 133 | default: |
| 134 | FATAL_ERROR("unsupported tensor type=%s", EnumNamesDType()[getDtype()]); |
| 135 | } |
| 136 | |
| 137 | switch (nperror) |
| 138 | { |
| 139 | case NumpyUtilities::NO_ERROR: |
| 140 | break; |
| 141 | case NumpyUtilities::FILE_NOT_FOUND: |
| 142 | FATAL_ERROR("readFromNpyFile: Cannot open file %s", filename); |
| 143 | case NumpyUtilities::FILE_IO_ERROR: |
| 144 | FATAL_ERROR("readFromNpyFile: IO error reading file: %s", filename); |
| 145 | case NumpyUtilities::FILE_TYPE_MISMATCH: |
| 146 | FATAL_ERROR("readFromNpyFile: Tensor type %s and Numpy file type mismatch for tensor %s filename %s", |
| 147 | EnumNamesDType()[getDtype()], getName().c_str(), filename); |
| 148 | case NumpyUtilities::HEADER_PARSE_ERROR: |
| 149 | FATAL_ERROR("Numpy header parsing error for file: %s", filename); |
| 150 | case NumpyUtilities::BUFFER_SIZE_MISMATCH: |
| 151 | FATAL_ERROR("Buffer size does not match numpy file size for tensor %s filename %s", getName().c_str(), |
| 152 | filename); |
| 153 | default: |
| 154 | FATAL_ERROR("Unknown error parsing Numpy file: %s", filename); |
| 155 | } |
| 156 | |
| 157 | switch (getDtype()) |
| 158 | { |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame^] | 159 | case DType_FP16: |
| 160 | // Convert from fp16 to fp32 |
| 161 | for (uint32_t i=0; i < elements; i++) { |
| 162 | fdatabuf[i] = half_float::half_cast<float, half_float::half>(f16databuf[i]); |
| 163 | } |
| 164 | // Fall through to DType_FLOAT case |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 165 | case DType_FLOAT: |
| 166 | if (setTensorValueFloat(elements, fdatabuf)) |
| 167 | { |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame^] | 168 | if (f16databuf) |
| 169 | free(f16databuf); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 170 | free(fdatabuf); |
| 171 | return 1; |
| 172 | } |
| 173 | break; |
| 174 | case DType_INT32: |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 175 | case DType_UINT8: |
| 176 | case DType_INT4: |
| 177 | case DType_INT8: |
| 178 | case DType_INT16: |
Jeremy Johnson | f7f78ae | 2022-05-25 15:26:38 +0100 | [diff] [blame] | 179 | case DType_UINT16: |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 180 | if (setTensorValueInt32(elements, i32databuf)) |
| 181 | { |
| 182 | free(i32databuf); |
| 183 | return 1; |
| 184 | } |
| 185 | break; |
| 186 | case DType_INT48: |
| 187 | if (setTensorValueInt64(elements, i64databuf)) |
| 188 | { |
| 189 | free(i64databuf); |
| 190 | return 1; |
| 191 | } |
| 192 | break; |
| 193 | case DType_BOOL: |
| 194 | if (setTensorValueBool(elements, bdatabuf)) |
| 195 | { |
| 196 | free(i32databuf); |
| 197 | return 1; |
| 198 | } |
| 199 | break; |
| 200 | default: |
| 201 | FATAL_ERROR("unsupported tensor type=%s", EnumNamesDType()[getDtype()]); |
| 202 | } |
| 203 | |
| 204 | setIsValid(); |
| 205 | |
| 206 | if (fdatabuf) |
| 207 | free(fdatabuf); |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame^] | 208 | if (f16databuf) |
| 209 | free(f16databuf); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 210 | if (i32databuf) |
| 211 | free(i32databuf); |
| 212 | if (i64databuf) |
| 213 | free(i64databuf); |
| 214 | if (bdatabuf) |
| 215 | free(bdatabuf); |
| 216 | |
| 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | int TosaReference::Tensor::writeToNpyFile(const char* filename) const |
| 221 | { |
| 222 | float* fdatabuf = nullptr; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame^] | 223 | half_float::half* f16databuf = nullptr; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 224 | int32_t* i32databuf = nullptr; |
| 225 | int64_t* i64databuf = nullptr; |
| 226 | bool* bdatabuf = nullptr; |
| 227 | NumpyUtilities::NPError nperror; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame^] | 228 | uint32_t elements = getElementCount(); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 229 | |
| 230 | switch (getDtype()) |
| 231 | { |
| 232 | case DType_FLOAT: |
| 233 | fdatabuf = (float*)calloc(sizeof(float), elements); |
| 234 | ASSERT_MEM(fdatabuf); |
| 235 | |
| 236 | if (getTensorValueFloat(elements, fdatabuf)) |
| 237 | { |
| 238 | free(fdatabuf); |
| 239 | return 1; |
| 240 | } |
| 241 | |
| 242 | nperror = NumpyUtilities::writeToNpyFile(filename, shape, fdatabuf); |
| 243 | |
| 244 | free(fdatabuf); |
| 245 | break; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame^] | 246 | case DType_FP16: |
| 247 | fdatabuf = (float*)calloc(sizeof(float), elements); |
| 248 | ASSERT_MEM(fdatabuf); |
| 249 | f16databuf = (half_float::half*)calloc(sizeof(half_float::half), elements); |
| 250 | ASSERT_MEM(f16databuf); |
| 251 | |
| 252 | if (getTensorValueFloat(elements, fdatabuf)) |
| 253 | { |
| 254 | free(fdatabuf); |
| 255 | free(f16databuf); |
| 256 | return 1; |
| 257 | } |
| 258 | // Convert fp32 to fp16 |
| 259 | for (uint32_t i=0; i < elements; i++) { |
| 260 | f16databuf[i] = half_float::half_cast<half_float::half, float>(fdatabuf[i]); |
| 261 | } |
| 262 | nperror = NumpyUtilities::writeToNpyFile(filename, shape, f16databuf); |
| 263 | |
| 264 | free(fdatabuf); |
| 265 | free(f16databuf); |
| 266 | break; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 267 | case DType_INT32: |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 268 | case DType_UINT8: |
| 269 | case DType_INT4: |
| 270 | case DType_INT8: |
| 271 | case DType_INT16: |
Jeremy Johnson | f7f78ae | 2022-05-25 15:26:38 +0100 | [diff] [blame] | 272 | case DType_UINT16: |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 273 | i32databuf = (int32_t*)calloc(sizeof(int32_t), elements); |
| 274 | ASSERT_MEM(i32databuf); |
| 275 | |
| 276 | if (getTensorValueInt32(elements, i32databuf)) |
| 277 | { |
| 278 | free(i32databuf); |
| 279 | return 1; |
| 280 | } |
| 281 | |
| 282 | nperror = NumpyUtilities::writeToNpyFile(filename, shape, i32databuf); |
| 283 | |
| 284 | free(i32databuf); |
| 285 | break; |
| 286 | case DType_INT48: |
| 287 | i64databuf = (int64_t*)calloc(sizeof(int64_t), elements); |
| 288 | ASSERT_MEM(i64databuf); |
| 289 | |
| 290 | if (getTensorValueInt64(elements, i64databuf)) |
| 291 | { |
| 292 | free(i64databuf); |
| 293 | return 1; |
| 294 | } |
| 295 | |
| 296 | nperror = NumpyUtilities::writeToNpyFile(filename, shape, i64databuf); |
| 297 | |
| 298 | free(i64databuf); |
| 299 | break; |
| 300 | case DType_BOOL: |
| 301 | bdatabuf = (bool*)calloc(sizeof(bool), elements); |
| 302 | ASSERT_MEM(bdatabuf); |
| 303 | |
| 304 | if (getTensorValueBool(elements, bdatabuf)) |
| 305 | { |
| 306 | free(bdatabuf); |
| 307 | return 1; |
| 308 | } |
| 309 | |
| 310 | nperror = NumpyUtilities::writeToNpyFile(filename, shape, bdatabuf); |
| 311 | |
| 312 | free(bdatabuf); |
| 313 | break; |
| 314 | default: |
| 315 | FATAL_ERROR("unsupported tensor type=%s", EnumNamesDType()[getDtype()]); |
| 316 | } |
| 317 | |
| 318 | switch (nperror) |
| 319 | { |
| 320 | case NumpyUtilities::NO_ERROR: |
| 321 | break; |
| 322 | case NumpyUtilities::FILE_NOT_FOUND: |
| 323 | FATAL_ERROR("writeToNpyFile: Cannot open output file %s", filename); |
| 324 | case NumpyUtilities::FILE_IO_ERROR: |
| 325 | FATAL_ERROR("writeToNpyFile: IO error writing file: %s", filename); |
| 326 | case NumpyUtilities::FILE_TYPE_MISMATCH: |
| 327 | FATAL_ERROR("writeToNpyFile: Tensor type and Numpy file type mismatch for tensor %s filename %s", |
| 328 | getName().c_str(), filename); |
| 329 | case NumpyUtilities::HEADER_PARSE_ERROR: |
| 330 | FATAL_ERROR("Numpy header parsing error for file: %s", filename); |
| 331 | case NumpyUtilities::BUFFER_SIZE_MISMATCH: |
| 332 | FATAL_ERROR("Buffer size does not match numpy file size for tensor %s filename %s", getName().c_str(), |
| 333 | filename); |
| 334 | default: |
| 335 | FATAL_ERROR("Unknown error writing Numpy file: %s", filename); |
| 336 | } |
| 337 | |
| 338 | return 0; |
| 339 | } |
| 340 | |
| 341 | template <class T> |
| 342 | int TosaReference::TensorTemplate<T>::copyValueFrom(TosaReference::Tensor* src) |
| 343 | { |
| 344 | FATAL_ERROR("TensorTemplate<T>::copyValueFrom should not be called. " |
| 345 | "Implement template specialization version."); |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | #define DEF_CTENSOR_COPY_VALUE_FROM(RANK, TYPE) \ |
| 350 | template <> \ |
| 351 | int TosaReference::Tensor##RANK<TYPE>::copyValueFrom(TosaReference::Tensor* src) \ |
| 352 | { \ |
| 353 | TosaReference::Tensor##RANK<TYPE>* t = dynamic_cast<Tensor##RANK<TYPE>*>(src); \ |
| 354 | if (!t) \ |
| 355 | { \ |
| 356 | WARNING("tensor %s templated class does not match %s", src->getName().c_str(), this->getName().c_str()); \ |
| 357 | return 1; \ |
| 358 | } \ |
| 359 | \ |
| 360 | uint32_t src_rank = src->getRank(); \ |
| 361 | uint32_t dst_rank = this->getRank(); \ |
| 362 | DType src_dtype = src->getDtype(); \ |
| 363 | DType dst_dtype = this->getDtype(); \ |
| 364 | bool tensor_match = true; \ |
| 365 | \ |
| 366 | if ((src_rank != dst_rank) || (src_dtype != dst_dtype)) \ |
| 367 | { \ |
| 368 | tensor_match = false; \ |
| 369 | } \ |
| 370 | else \ |
| 371 | { \ |
| 372 | for (uint32_t i = 0; i < src_rank; i++) \ |
| 373 | { \ |
| 374 | int src_dim = src->getShape()[i]; \ |
| 375 | int dst_dim = this->getShape()[i]; \ |
| 376 | if (src_dim != dst_dim) \ |
| 377 | { \ |
| 378 | tensor_match = false; \ |
| 379 | } \ |
| 380 | } \ |
| 381 | } \ |
| 382 | \ |
| 383 | if (!tensor_match) \ |
| 384 | { \ |
| 385 | WARNING("source tensor %s (rank=%u, dtype=%s, shape=%s) doesn't match destination tensor %s (rank=%u, " \ |
| 386 | "dtype=%s, shape=%s)", \ |
| 387 | src->getName().c_str(), src_rank, EnumNamesDType()[src_dtype], src->getShapeAsString().c_str(), \ |
| 388 | this->getName().c_str(), dst_rank, EnumNamesDType()[dst_dtype], this->getShapeAsString().c_str()); \ |
| 389 | return 1; \ |
| 390 | } \ |
| 391 | \ |
| 392 | this->getTensor() = t->getTensor(); \ |
| 393 | return 0; \ |
| 394 | } |
| 395 | |
| 396 | DEF_CTENSOR_COPY_VALUE_FROM(0, float) |
| 397 | DEF_CTENSOR_COPY_VALUE_FROM(1, float) |
| 398 | DEF_CTENSOR_COPY_VALUE_FROM(2, float) |
| 399 | DEF_CTENSOR_COPY_VALUE_FROM(3, float) |
| 400 | DEF_CTENSOR_COPY_VALUE_FROM(4, float) |
| 401 | DEF_CTENSOR_COPY_VALUE_FROM(5, float) |
| 402 | DEF_CTENSOR_COPY_VALUE_FROM(6, float) |
| 403 | DEF_CTENSOR_COPY_VALUE_FROM(0, int32_t) |
| 404 | DEF_CTENSOR_COPY_VALUE_FROM(1, int32_t) |
| 405 | DEF_CTENSOR_COPY_VALUE_FROM(2, int32_t) |
| 406 | DEF_CTENSOR_COPY_VALUE_FROM(3, int32_t) |
| 407 | DEF_CTENSOR_COPY_VALUE_FROM(4, int32_t) |
| 408 | DEF_CTENSOR_COPY_VALUE_FROM(5, int32_t) |
| 409 | DEF_CTENSOR_COPY_VALUE_FROM(6, int32_t) |
| 410 | DEF_CTENSOR_COPY_VALUE_FROM(0, int64_t) |
| 411 | DEF_CTENSOR_COPY_VALUE_FROM(1, int64_t) |
| 412 | DEF_CTENSOR_COPY_VALUE_FROM(2, int64_t) |
| 413 | DEF_CTENSOR_COPY_VALUE_FROM(3, int64_t) |
| 414 | DEF_CTENSOR_COPY_VALUE_FROM(4, int64_t) |
| 415 | DEF_CTENSOR_COPY_VALUE_FROM(5, int64_t) |
| 416 | DEF_CTENSOR_COPY_VALUE_FROM(6, int64_t) |
| 417 | DEF_CTENSOR_COPY_VALUE_FROM(0, bool) |
| 418 | DEF_CTENSOR_COPY_VALUE_FROM(1, bool) |
| 419 | DEF_CTENSOR_COPY_VALUE_FROM(2, bool) |
| 420 | DEF_CTENSOR_COPY_VALUE_FROM(3, bool) |
| 421 | DEF_CTENSOR_COPY_VALUE_FROM(4, bool) |
| 422 | DEF_CTENSOR_COPY_VALUE_FROM(5, bool) |
| 423 | DEF_CTENSOR_COPY_VALUE_FROM(6, bool) |
| 424 | |
| 425 | #undef DEF_CTENSOR_COPY_VALUE_FROM |
| 426 | |
Matthew Sloyan | ba5fad3 | 2022-09-26 13:31:43 +0100 | [diff] [blame] | 427 | int TosaReference::Tensor::readfromVector(const std::vector<float>& vals) |
| 428 | { |
| 429 | uint32_t elements = getElementCount(); |
| 430 | switch (getDtype()) |
| 431 | { |
| 432 | case DType_FLOAT: |
| 433 | if (vals.size() != elements) |
| 434 | { |
| 435 | WARNING("The input size (%ld) doesn't match the number of elements (%d) assigned to the tensor.", |
| 436 | vals.size(), elements); |
| 437 | return -1; |
| 438 | } |
| 439 | |
| 440 | setTensorValueFloat(elements, vals.data()); |
| 441 | break; |
| 442 | default: |
| 443 | WARNING("The input type (float) doesn't match the data type assigned to the tensor (%s).", |
| 444 | EnumNameDType(getDtype())); |
| 445 | return -2; |
| 446 | } |
| 447 | setIsValid(); |
| 448 | return 0; |
| 449 | } |
| 450 | |
| 451 | int TosaReference::Tensor::readfromVector(const std::vector<int32_t>& vals) |
| 452 | { |
| 453 | uint32_t elements = getElementCount(); |
| 454 | switch (getDtype()) |
| 455 | { |
| 456 | case DType_INT32: |
| 457 | case DType_UINT8: |
| 458 | case DType_INT4: |
| 459 | case DType_INT8: |
| 460 | case DType_INT16: |
| 461 | case DType_UINT16: |
| 462 | if (vals.size() != elements) |
| 463 | { |
| 464 | WARNING("The input size (%ld) doesn't match the number of elements (%d) assigned to the tensor.", |
| 465 | vals.size(), elements); |
| 466 | return -1; |
| 467 | } |
| 468 | |
| 469 | setTensorValueInt32(elements, vals.data()); |
| 470 | break; |
| 471 | default: |
| 472 | WARNING("The input type doesn't match the data type assigned to the tensor (%s).", |
| 473 | EnumNameDType(getDtype())); |
| 474 | return -2; |
| 475 | } |
| 476 | setIsValid(); |
| 477 | return 0; |
| 478 | } |
| 479 | |
| 480 | int TosaReference::Tensor::readfromVector(const std::vector<int64_t>& vals) |
| 481 | { |
| 482 | uint32_t elements = getElementCount(); |
| 483 | switch (getDtype()) |
| 484 | { |
| 485 | case DType_INT48: |
| 486 | if (vals.size() != elements) |
| 487 | { |
| 488 | WARNING("The input size (%ld) doesn't match the number of elements (%d) assigned to the tensor.", |
| 489 | vals.size(), elements); |
| 490 | return -1; |
| 491 | } |
| 492 | |
| 493 | setTensorValueInt64(elements, vals.data()); |
| 494 | break; |
| 495 | default: |
| 496 | WARNING("The input type doesn't match the data type assigned to the tensor (%s).", |
| 497 | EnumNameDType(getDtype())); |
| 498 | return -2; |
| 499 | } |
| 500 | setIsValid(); |
| 501 | return 0; |
| 502 | } |
| 503 | |
| 504 | int TosaReference::Tensor::readfromVector(const std::vector<unsigned char>& vals) |
| 505 | { |
| 506 | uint32_t elements = getElementCount(); |
| 507 | |
| 508 | switch (getDtype()) |
| 509 | { |
| 510 | case DType_BOOL: |
| 511 | if (vals.size() != elements) |
| 512 | { |
| 513 | WARNING("The input size (%ld) doesn't match the number of elements (%d) assigned to the tensor.", |
| 514 | vals.size(), elements); |
| 515 | return -1; |
| 516 | } |
| 517 | |
| 518 | setTensorValueBool(elements, reinterpret_cast<const bool*>(vals.data())); |
| 519 | break; |
| 520 | default: |
| 521 | WARNING("The input type (bool) doesn't match the data type assigned to the tensor (%s).", |
| 522 | EnumNameDType(getDtype())); |
| 523 | return -2; |
| 524 | } |
| 525 | setIsValid(); |
| 526 | return 0; |
| 527 | } |
| 528 | |
| 529 | int TosaReference::Tensor::writeToVector(std::vector<float>& vals) |
| 530 | { |
| 531 | uint32_t elements = getElementCount(); |
| 532 | |
| 533 | switch (getDtype()) |
| 534 | { |
| 535 | case DType_FLOAT: |
| 536 | if (vals.size() != elements) |
| 537 | { |
| 538 | WARNING("The output size (%ld) doesn't match the number of elements (%d) assigned to the tensor.", |
| 539 | vals.size(), elements); |
| 540 | return -1; |
| 541 | } |
| 542 | |
| 543 | getTensorValueFloat(elements, vals.data()); |
| 544 | break; |
| 545 | default: |
| 546 | WARNING("The output type (float) doesn't match the data type assigned to the tensor (%s).", |
| 547 | EnumNameDType(getDtype())); |
| 548 | return -2; |
| 549 | } |
| 550 | return 0; |
| 551 | } |
| 552 | |
| 553 | int TosaReference::Tensor::writeToVector(std::vector<int32_t>& vals) |
| 554 | { |
| 555 | uint32_t elements = getElementCount(); |
| 556 | |
| 557 | switch (getDtype()) |
| 558 | { |
| 559 | case DType_INT32: |
| 560 | case DType_UINT8: |
| 561 | case DType_INT4: |
| 562 | case DType_INT8: |
| 563 | case DType_INT16: |
| 564 | case DType_UINT16: |
| 565 | if (vals.size() != elements) |
| 566 | { |
| 567 | WARNING("The output size (%ld) doesn't match the number of elements (%d) assigned to the tensor.", |
| 568 | vals.size(), elements); |
| 569 | return -1; |
| 570 | } |
| 571 | |
| 572 | getTensorValueInt32(elements, vals.data()); |
| 573 | break; |
| 574 | default: |
| 575 | WARNING("The output type doesn't match the data type assigned to the tensor (%s).", |
| 576 | EnumNameDType(getDtype())); |
| 577 | return -2; |
| 578 | } |
| 579 | return 0; |
| 580 | } |
| 581 | |
| 582 | int TosaReference::Tensor::writeToVector(std::vector<int64_t>& vals) |
| 583 | { |
| 584 | uint32_t elements = getElementCount(); |
| 585 | |
| 586 | switch (getDtype()) |
| 587 | { |
| 588 | case tosa::DType_INT48: |
| 589 | if (vals.size() != elements) |
| 590 | { |
| 591 | WARNING("The output size (%ld) doesn't match the number of elements (%d) assigned to the tensor.", |
| 592 | vals.size(), elements); |
| 593 | return -1; |
| 594 | } |
| 595 | |
| 596 | getTensorValueInt64(elements, vals.data()); |
| 597 | break; |
| 598 | default: |
| 599 | WARNING("The output type doesn't match the data type assigned to the tensor (%s).", |
| 600 | EnumNameDType(getDtype())); |
| 601 | return -2; |
| 602 | } |
| 603 | return 0; |
| 604 | } |
| 605 | |
| 606 | int TosaReference::Tensor::writeToVector(std::vector<unsigned char>& vals) |
| 607 | { |
| 608 | uint32_t elements = getElementCount(); |
| 609 | |
| 610 | switch (getDtype()) |
| 611 | { |
| 612 | case tosa::DType_BOOL: |
| 613 | if (vals.size() != elements) |
| 614 | { |
| 615 | WARNING("The output size (%ld) doesn't match the number of elements (%d) assigned to the tensor.", |
| 616 | vals.size(), elements); |
| 617 | return -1; |
| 618 | } |
| 619 | |
| 620 | getTensorValueBool(elements, reinterpret_cast<bool*>(vals.data())); |
| 621 | break; |
| 622 | default: |
| 623 | WARNING("The output type (bool) doesn't match the data type assigned to the tensor (%s).", |
| 624 | EnumNameDType(getDtype())); |
| 625 | return -2; |
| 626 | } |
| 627 | return 0; |
| 628 | } |
| 629 | |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 630 | template <class T> |
| 631 | int TosaReference::TensorTemplate<T>::setTensorValueFloat(const size_t buflen, const float* vals) |
| 632 | { |
| 633 | FATAL_ERROR("TensorTemplate<T>::setTensorValueFloat should not be called. " |
| 634 | "Implement template specialization version."); |
| 635 | return 0; |
| 636 | } |
| 637 | |
| 638 | template <> |
| 639 | int TosaReference::Tensor0<float>::setTensorValueFloat(const size_t bufLen, const float* vals) |
| 640 | { |
| 641 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 642 | |
| 643 | (*tensor)(0) = vals[0]; |
| 644 | |
| 645 | return 0; |
| 646 | } |
| 647 | |
| 648 | template <> |
| 649 | int TosaReference::Tensor1<float>::setTensorValueFloat(const size_t bufLen, const float* vals) |
| 650 | { |
| 651 | uint32_t idx = 0; |
| 652 | |
| 653 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 654 | |
| 655 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 656 | { |
| 657 | (*tensor)(i0) = vals[idx++]; |
| 658 | } |
| 659 | |
| 660 | return 0; |
| 661 | } |
| 662 | |
| 663 | template <> |
| 664 | int TosaReference::Tensor2<float>::setTensorValueFloat(const size_t bufLen, const float* vals) |
| 665 | { |
| 666 | uint32_t idx = 0; |
| 667 | |
| 668 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 669 | |
| 670 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 671 | { |
| 672 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 673 | { |
| 674 | (*tensor)(i0, i1) = vals[idx++]; |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | return 0; |
| 679 | } |
| 680 | |
| 681 | template <> |
| 682 | int TosaReference::Tensor3<float>::setTensorValueFloat(const size_t bufLen, const float* vals) |
| 683 | { |
| 684 | uint32_t idx = 0; |
| 685 | |
| 686 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 687 | |
| 688 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 689 | { |
| 690 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 691 | { |
| 692 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 693 | { |
| 694 | (*tensor)(i0, i1, i2) = vals[idx++]; |
| 695 | } |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | return 0; |
| 700 | } |
| 701 | |
| 702 | template <> |
| 703 | int TosaReference::Tensor4<float>::setTensorValueFloat(const size_t bufLen, const float* vals) |
| 704 | { |
| 705 | uint32_t idx = 0; |
| 706 | |
| 707 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 708 | |
| 709 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 710 | { |
| 711 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 712 | { |
| 713 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 714 | { |
| 715 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 716 | { |
| 717 | (*tensor)(i0, i1, i2, i3) = vals[idx++]; |
| 718 | } |
| 719 | } |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | return 0; |
| 724 | } |
| 725 | |
| 726 | template <> |
| 727 | int TosaReference::Tensor5<float>::setTensorValueFloat(const size_t bufLen, const float* vals) |
| 728 | { |
| 729 | uint32_t idx = 0; |
| 730 | |
| 731 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 732 | |
| 733 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 734 | { |
| 735 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 736 | { |
| 737 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 738 | { |
| 739 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 740 | { |
| 741 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 742 | { |
| 743 | (*tensor)(i0, i1, i2, i3, i4) = vals[idx++]; |
| 744 | } |
| 745 | } |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | return 0; |
| 751 | } |
| 752 | |
| 753 | template <> |
| 754 | int TosaReference::Tensor6<float>::setTensorValueFloat(const size_t bufLen, const float* vals) |
| 755 | { |
| 756 | uint32_t idx = 0; |
| 757 | |
| 758 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 759 | |
| 760 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 761 | { |
| 762 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 763 | { |
| 764 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 765 | { |
| 766 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 767 | { |
| 768 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 769 | { |
| 770 | for (int i5 = 0; i5 < shape[5]; i5++) |
| 771 | { |
| 772 | (*tensor)(i0, i1, i2, i3, i4, i5) = vals[idx++]; |
| 773 | } |
| 774 | } |
| 775 | } |
| 776 | } |
| 777 | } |
| 778 | } |
| 779 | return 0; |
| 780 | } |
| 781 | |
| 782 | template <class T> |
| 783 | int TosaReference::TensorTemplate<T>::setTensorValueInt32(const size_t bufLen, const int32_t* vals) |
| 784 | { |
| 785 | FATAL_ERROR("TensorTemplate<T>::setTensorValueInt32 should not be called. " |
| 786 | "Implement template specialization version."); |
| 787 | return 0; |
| 788 | } |
| 789 | |
| 790 | template <> |
| 791 | int TosaReference::Tensor0<int32_t>::setTensorValueInt32(const size_t bufLen, const int32_t* vals) |
| 792 | { |
| 793 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 794 | |
| 795 | (*tensor)(0) = vals[0]; |
| 796 | |
| 797 | return 0; |
| 798 | } |
| 799 | |
| 800 | template <> |
| 801 | int TosaReference::Tensor1<int32_t>::setTensorValueInt32(const size_t bufLen, const int32_t* vals) |
| 802 | { |
| 803 | uint32_t idx = 0; |
| 804 | |
| 805 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 806 | |
| 807 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 808 | { |
| 809 | (*tensor)(i0) = vals[idx++]; |
| 810 | } |
| 811 | |
| 812 | return 0; |
| 813 | } |
| 814 | |
| 815 | template <> |
| 816 | int TosaReference::Tensor2<int32_t>::setTensorValueInt32(const size_t bufLen, const int32_t* vals) |
| 817 | { |
| 818 | uint32_t idx = 0; |
| 819 | |
| 820 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 821 | |
| 822 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 823 | { |
| 824 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 825 | { |
| 826 | (*tensor)(i0, i1) = vals[idx++]; |
| 827 | } |
| 828 | } |
| 829 | |
| 830 | return 0; |
| 831 | } |
| 832 | |
| 833 | template <> |
| 834 | int TosaReference::Tensor3<int32_t>::setTensorValueInt32(const size_t bufLen, const int32_t* vals) |
| 835 | { |
| 836 | uint32_t idx = 0; |
| 837 | |
| 838 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 839 | |
| 840 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 841 | { |
| 842 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 843 | { |
| 844 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 845 | { |
| 846 | (*tensor)(i0, i1, i2) = vals[idx++]; |
| 847 | } |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | return 0; |
| 852 | } |
| 853 | |
| 854 | template <> |
| 855 | int TosaReference::Tensor4<int32_t>::setTensorValueInt32(const size_t bufLen, const int32_t* vals) |
| 856 | { |
| 857 | uint32_t idx = 0; |
| 858 | |
| 859 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 860 | |
| 861 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 862 | { |
| 863 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 864 | { |
| 865 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 866 | { |
| 867 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 868 | { |
| 869 | (*tensor)(i0, i1, i2, i3) = vals[idx++]; |
| 870 | } |
| 871 | } |
| 872 | } |
| 873 | } |
| 874 | |
| 875 | return 0; |
| 876 | } |
| 877 | |
| 878 | template <> |
| 879 | int TosaReference::Tensor5<int32_t>::setTensorValueInt32(const size_t bufLen, const int32_t* vals) |
| 880 | { |
| 881 | uint32_t idx = 0; |
| 882 | |
| 883 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 884 | |
| 885 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 886 | { |
| 887 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 888 | { |
| 889 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 890 | { |
| 891 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 892 | { |
| 893 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 894 | { |
| 895 | (*tensor)(i0, i1, i2, i3, i4) = vals[idx++]; |
| 896 | } |
| 897 | } |
| 898 | } |
| 899 | } |
| 900 | } |
| 901 | |
| 902 | return 0; |
| 903 | } |
| 904 | |
| 905 | template <> |
| 906 | int TosaReference::Tensor6<int32_t>::setTensorValueInt32(const size_t bufLen, const int32_t* vals) |
| 907 | { |
| 908 | uint32_t idx = 0; |
| 909 | |
| 910 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 911 | |
| 912 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 913 | { |
| 914 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 915 | { |
| 916 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 917 | { |
| 918 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 919 | { |
| 920 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 921 | { |
| 922 | for (int i5 = 0; i5 < shape[5]; i5++) |
| 923 | { |
| 924 | (*tensor)(i0, i1, i2, i3, i4, i5) = vals[idx++]; |
| 925 | } |
| 926 | } |
| 927 | } |
| 928 | } |
| 929 | } |
| 930 | } |
| 931 | return 0; |
| 932 | } |
| 933 | |
| 934 | template <class T> |
| 935 | int TosaReference::TensorTemplate<T>::setTensorValueInt64(const size_t bufLen, const int64_t* vals) |
| 936 | { |
| 937 | FATAL_ERROR("TensorTemplate<T>::setTensorValueInt64 should not be called. " |
| 938 | "Implement template specialization version."); |
| 939 | return 0; |
| 940 | } |
| 941 | |
| 942 | template <> |
| 943 | int TosaReference::Tensor0<int64_t>::setTensorValueInt64(const size_t bufLen, const int64_t* vals) |
| 944 | { |
| 945 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 946 | |
| 947 | (*tensor)(0) = vals[0]; |
| 948 | |
| 949 | return 0; |
| 950 | } |
| 951 | |
| 952 | template <> |
| 953 | int TosaReference::Tensor1<int64_t>::setTensorValueInt64(const size_t bufLen, const int64_t* vals) |
| 954 | { |
| 955 | uint32_t idx = 0; |
| 956 | |
| 957 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 958 | |
| 959 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 960 | { |
| 961 | (*tensor)(i0) = vals[idx++]; |
| 962 | } |
| 963 | |
| 964 | return 0; |
| 965 | } |
| 966 | |
| 967 | template <> |
| 968 | int TosaReference::Tensor2<int64_t>::setTensorValueInt64(const size_t bufLen, const int64_t* vals) |
| 969 | { |
| 970 | uint32_t idx = 0; |
| 971 | |
| 972 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 973 | |
| 974 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 975 | { |
| 976 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 977 | { |
| 978 | (*tensor)(i0, i1) = vals[idx++]; |
| 979 | } |
| 980 | } |
| 981 | |
| 982 | return 0; |
| 983 | } |
| 984 | |
| 985 | template <> |
| 986 | int TosaReference::Tensor3<int64_t>::setTensorValueInt64(const size_t bufLen, const int64_t* vals) |
| 987 | { |
| 988 | uint32_t idx = 0; |
| 989 | |
| 990 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 991 | |
| 992 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 993 | { |
| 994 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 995 | { |
| 996 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 997 | { |
| 998 | (*tensor)(i0, i1, i2) = vals[idx++]; |
| 999 | } |
| 1000 | } |
| 1001 | } |
| 1002 | |
| 1003 | return 0; |
| 1004 | } |
| 1005 | |
| 1006 | template <> |
| 1007 | int TosaReference::Tensor4<int64_t>::setTensorValueInt64(const size_t bufLen, const int64_t* vals) |
| 1008 | { |
| 1009 | uint32_t idx = 0; |
| 1010 | |
| 1011 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 1012 | |
| 1013 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1014 | { |
| 1015 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1016 | { |
| 1017 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1018 | { |
| 1019 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1020 | { |
| 1021 | (*tensor)(i0, i1, i2, i3) = vals[idx++]; |
| 1022 | } |
| 1023 | } |
| 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | return 0; |
| 1028 | } |
| 1029 | |
| 1030 | template <> |
| 1031 | int TosaReference::Tensor5<int64_t>::setTensorValueInt64(const size_t bufLen, const int64_t* vals) |
| 1032 | { |
| 1033 | uint32_t idx = 0; |
| 1034 | |
| 1035 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 1036 | |
| 1037 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1038 | { |
| 1039 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1040 | { |
| 1041 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1042 | { |
| 1043 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1044 | { |
| 1045 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 1046 | { |
| 1047 | (*tensor)(i0, i1, i2, i3, i4) = vals[idx++]; |
| 1048 | } |
| 1049 | } |
| 1050 | } |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | return 0; |
| 1055 | } |
| 1056 | |
| 1057 | template <> |
| 1058 | int TosaReference::Tensor6<int64_t>::setTensorValueInt64(const size_t bufLen, const int64_t* vals) |
| 1059 | { |
| 1060 | uint32_t idx = 0; |
| 1061 | |
| 1062 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 1063 | |
| 1064 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1065 | { |
| 1066 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1067 | { |
| 1068 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1069 | { |
| 1070 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1071 | { |
| 1072 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 1073 | { |
| 1074 | for (int i5 = 0; i5 < shape[5]; i5++) |
| 1075 | { |
| 1076 | (*tensor)(i0, i1, i2, i3, i4, i5) = vals[idx++]; |
| 1077 | } |
| 1078 | } |
| 1079 | } |
| 1080 | } |
| 1081 | } |
| 1082 | } |
| 1083 | return 0; |
| 1084 | } |
| 1085 | |
| 1086 | template <class T> |
| 1087 | int TosaReference::TensorTemplate<T>::setTensorValueBool(const size_t buflen, const bool* vals) |
| 1088 | { |
| 1089 | FATAL_ERROR("TensorTemplate<T>::setTensorValueBool should not be called. " |
| 1090 | "Implement template specialization version."); |
| 1091 | return 0; |
| 1092 | } |
| 1093 | |
| 1094 | template <> |
| 1095 | int TosaReference::Tensor0<bool>::setTensorValueBool(const size_t bufLen, const bool* vals) |
| 1096 | { |
| 1097 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 1098 | |
| 1099 | (*tensor)(0) = vals[0]; |
| 1100 | |
| 1101 | return 0; |
| 1102 | } |
| 1103 | |
| 1104 | template <> |
| 1105 | int TosaReference::Tensor1<bool>::setTensorValueBool(const size_t bufLen, const bool* vals) |
| 1106 | { |
| 1107 | uint32_t idx = 0; |
| 1108 | |
| 1109 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 1110 | |
| 1111 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1112 | { |
| 1113 | (*tensor)(i0) = vals[idx++]; |
| 1114 | } |
| 1115 | |
| 1116 | return 0; |
| 1117 | } |
| 1118 | |
| 1119 | template <> |
| 1120 | int TosaReference::Tensor2<bool>::setTensorValueBool(const size_t bufLen, const bool* vals) |
| 1121 | { |
| 1122 | uint32_t idx = 0; |
| 1123 | |
| 1124 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 1125 | |
| 1126 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1127 | { |
| 1128 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1129 | { |
| 1130 | (*tensor)(i0, i1) = vals[idx++]; |
| 1131 | } |
| 1132 | } |
| 1133 | |
| 1134 | return 0; |
| 1135 | } |
| 1136 | |
| 1137 | template <> |
| 1138 | int TosaReference::Tensor3<bool>::setTensorValueBool(const size_t bufLen, const bool* vals) |
| 1139 | { |
| 1140 | uint32_t idx = 0; |
| 1141 | |
| 1142 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 1143 | |
| 1144 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1145 | { |
| 1146 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1147 | { |
| 1148 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1149 | { |
| 1150 | (*tensor)(i0, i1, i2) = vals[idx++]; |
| 1151 | } |
| 1152 | } |
| 1153 | } |
| 1154 | |
| 1155 | return 0; |
| 1156 | } |
| 1157 | |
| 1158 | template <> |
| 1159 | int TosaReference::Tensor4<bool>::setTensorValueBool(const size_t bufLen, const bool* vals) |
| 1160 | { |
| 1161 | uint32_t idx = 0; |
| 1162 | |
| 1163 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 1164 | |
| 1165 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1166 | { |
| 1167 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1168 | { |
| 1169 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1170 | { |
| 1171 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1172 | { |
| 1173 | (*tensor)(i0, i1, i2, i3) = vals[idx++]; |
| 1174 | } |
| 1175 | } |
| 1176 | } |
| 1177 | } |
| 1178 | |
| 1179 | return 0; |
| 1180 | } |
| 1181 | |
| 1182 | template <> |
| 1183 | int TosaReference::Tensor5<bool>::setTensorValueBool(const size_t bufLen, const bool* vals) |
| 1184 | { |
| 1185 | uint32_t idx = 0; |
| 1186 | |
| 1187 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 1188 | |
| 1189 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1190 | { |
| 1191 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1192 | { |
| 1193 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1194 | { |
| 1195 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1196 | { |
| 1197 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 1198 | { |
| 1199 | (*tensor)(i0, i1, i2, i3, i4) = vals[idx++]; |
| 1200 | } |
| 1201 | } |
| 1202 | } |
| 1203 | } |
| 1204 | } |
| 1205 | |
| 1206 | return 0; |
| 1207 | } |
| 1208 | |
| 1209 | template <> |
| 1210 | int TosaReference::Tensor6<bool>::setTensorValueBool(const size_t bufLen, const bool* vals) |
| 1211 | { |
| 1212 | uint32_t idx = 0; |
| 1213 | |
| 1214 | ASSERT_MSG(bufLen == getElementCount(), "Total elements must match"); |
| 1215 | |
| 1216 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1217 | { |
| 1218 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1219 | { |
| 1220 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1221 | { |
| 1222 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1223 | { |
| 1224 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 1225 | { |
| 1226 | for (int i5 = 0; i5 < shape[5]; i5++) |
| 1227 | { |
| 1228 | (*tensor)(i0, i1, i2, i3, i4, i5) = vals[idx++]; |
| 1229 | } |
| 1230 | } |
| 1231 | } |
| 1232 | } |
| 1233 | } |
| 1234 | } |
| 1235 | return 0; |
| 1236 | } |
| 1237 | |
| 1238 | template <class T> |
| 1239 | int TosaReference::TensorTemplate<T>::getTensorValueFloat(const size_t bufLen, float* vals) const |
| 1240 | { |
| 1241 | FATAL_ERROR("TensorTemplate<T>::getTensorValueFloat should not be called. " |
| 1242 | "Implement template specialization version."); |
| 1243 | return 0; |
| 1244 | } |
| 1245 | |
| 1246 | template <> |
| 1247 | int TosaReference::Tensor0<float>::getTensorValueFloat(const size_t bufLen, float* vals) const |
| 1248 | { |
| 1249 | int totalVals = 1; |
| 1250 | |
| 1251 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1252 | |
| 1253 | vals[0] = (*tensor)(0); |
| 1254 | |
| 1255 | return 0; |
| 1256 | } |
| 1257 | |
| 1258 | template <> |
| 1259 | int TosaReference::Tensor1<float>::getTensorValueFloat(const size_t bufLen, float* vals) const |
| 1260 | { |
| 1261 | uint32_t idx = 0; |
| 1262 | int totalVals = 1; |
| 1263 | |
| 1264 | for (size_t i = 0; i < shape.size(); i++) |
| 1265 | { |
| 1266 | totalVals *= shape[i]; |
| 1267 | } |
| 1268 | |
| 1269 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1270 | |
| 1271 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1272 | { |
| 1273 | vals[idx++] = (*tensor)(i0); |
| 1274 | } |
| 1275 | |
| 1276 | return 0; |
| 1277 | } |
| 1278 | |
| 1279 | template <> |
| 1280 | int TosaReference::Tensor2<float>::getTensorValueFloat(const size_t bufLen, float* vals) const |
| 1281 | { |
| 1282 | uint32_t idx = 0; |
| 1283 | int totalVals = 1; |
| 1284 | |
| 1285 | for (size_t i = 0; i < shape.size(); i++) |
| 1286 | { |
| 1287 | totalVals *= shape[i]; |
| 1288 | } |
| 1289 | |
| 1290 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1291 | |
| 1292 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1293 | { |
| 1294 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1295 | { |
| 1296 | vals[idx++] = (*tensor)(i0, i1); |
| 1297 | } |
| 1298 | } |
| 1299 | |
| 1300 | return 0; |
| 1301 | } |
| 1302 | |
| 1303 | template <> |
| 1304 | int TosaReference::Tensor3<float>::getTensorValueFloat(const size_t bufLen, float* vals) const |
| 1305 | { |
| 1306 | uint32_t idx = 0; |
| 1307 | int totalVals = 1; |
| 1308 | |
| 1309 | for (size_t i = 0; i < shape.size(); i++) |
| 1310 | { |
| 1311 | totalVals *= shape[i]; |
| 1312 | } |
| 1313 | |
| 1314 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1315 | |
| 1316 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1317 | { |
| 1318 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1319 | { |
| 1320 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1321 | { |
| 1322 | vals[idx++] = (*tensor)(i0, i1, i2); |
| 1323 | } |
| 1324 | } |
| 1325 | } |
| 1326 | |
| 1327 | return 0; |
| 1328 | } |
| 1329 | |
| 1330 | template <> |
| 1331 | int TosaReference::Tensor4<float>::getTensorValueFloat(const size_t bufLen, float* vals) const |
| 1332 | { |
| 1333 | uint32_t idx = 0; |
| 1334 | int totalVals = 1; |
| 1335 | |
| 1336 | for (size_t i = 0; i < shape.size(); i++) |
| 1337 | { |
| 1338 | totalVals *= shape[i]; |
| 1339 | } |
| 1340 | |
| 1341 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1342 | |
| 1343 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1344 | { |
| 1345 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1346 | { |
| 1347 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1348 | { |
| 1349 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1350 | { |
| 1351 | vals[idx++] = (*tensor)(i0, i1, i2, i3); |
| 1352 | } |
| 1353 | } |
| 1354 | } |
| 1355 | } |
| 1356 | |
| 1357 | return 0; |
| 1358 | } |
| 1359 | |
| 1360 | template <> |
| 1361 | int TosaReference::Tensor5<float>::getTensorValueFloat(const size_t bufLen, float* vals) const |
| 1362 | { |
| 1363 | uint32_t idx = 0; |
| 1364 | int totalVals = 1; |
| 1365 | |
| 1366 | for (size_t i = 0; i < shape.size(); i++) |
| 1367 | { |
| 1368 | totalVals *= shape[i]; |
| 1369 | } |
| 1370 | |
| 1371 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1372 | |
| 1373 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1374 | { |
| 1375 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1376 | { |
| 1377 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1378 | { |
| 1379 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1380 | { |
| 1381 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 1382 | { |
| 1383 | vals[idx++] = (*tensor)(i0, i1, i2, i3, i4); |
| 1384 | } |
| 1385 | } |
| 1386 | } |
| 1387 | } |
| 1388 | } |
| 1389 | |
| 1390 | return 0; |
| 1391 | } |
| 1392 | |
| 1393 | template <> |
| 1394 | int TosaReference::Tensor6<float>::getTensorValueFloat(const size_t bufLen, float* vals) const |
| 1395 | { |
| 1396 | uint32_t idx = 0; |
| 1397 | int totalVals = 1; |
| 1398 | |
| 1399 | for (size_t i = 0; i < shape.size(); i++) |
| 1400 | { |
| 1401 | totalVals *= shape[i]; |
| 1402 | } |
| 1403 | |
| 1404 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1405 | |
| 1406 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1407 | { |
| 1408 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1409 | { |
| 1410 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1411 | { |
| 1412 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1413 | { |
| 1414 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 1415 | { |
| 1416 | for (int i5 = 0; i5 < shape[5]; i5++) |
| 1417 | { |
| 1418 | vals[idx++] = (*tensor)(i0, i1, i2, i3, i4, i5); |
| 1419 | } |
| 1420 | } |
| 1421 | } |
| 1422 | } |
| 1423 | } |
| 1424 | } |
| 1425 | return 0; |
| 1426 | } |
| 1427 | |
| 1428 | template <class T> |
| 1429 | int TosaReference::TensorTemplate<T>::getTensorValueInt32(const size_t bufLen, int32_t* vals) const |
| 1430 | { |
| 1431 | FATAL_ERROR("TensorTemplate<T>::getTensorValueInt32 should not be called. " |
| 1432 | "Implement template specialization version."); |
| 1433 | return 0; |
| 1434 | } |
| 1435 | |
| 1436 | template <> |
| 1437 | int TosaReference::Tensor0<int32_t>::getTensorValueInt32(const size_t bufLen, int32_t* vals) const |
| 1438 | { |
| 1439 | int totalVals = 1; |
| 1440 | |
| 1441 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1442 | |
| 1443 | vals[0] = (*tensor)(0); |
| 1444 | |
| 1445 | return 0; |
| 1446 | } |
| 1447 | |
| 1448 | template <> |
| 1449 | int TosaReference::Tensor1<int32_t>::getTensorValueInt32(const size_t bufLen, int32_t* vals) const |
| 1450 | { |
| 1451 | uint32_t idx = 0; |
| 1452 | int totalVals = 1; |
| 1453 | |
| 1454 | for (size_t i = 0; i < shape.size(); i++) |
| 1455 | { |
| 1456 | totalVals *= shape[i]; |
| 1457 | } |
| 1458 | |
| 1459 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1460 | |
| 1461 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1462 | { |
| 1463 | vals[idx++] = (*tensor)(i0); |
| 1464 | } |
| 1465 | |
| 1466 | return 0; |
| 1467 | } |
| 1468 | |
| 1469 | template <> |
| 1470 | int TosaReference::Tensor2<int32_t>::getTensorValueInt32(const size_t bufLen, int32_t* vals) const |
| 1471 | { |
| 1472 | uint32_t idx = 0; |
| 1473 | int totalVals = 1; |
| 1474 | |
| 1475 | for (size_t i = 0; i < shape.size(); i++) |
| 1476 | { |
| 1477 | totalVals *= shape[i]; |
| 1478 | } |
| 1479 | |
| 1480 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1481 | |
| 1482 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1483 | { |
| 1484 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1485 | { |
| 1486 | vals[idx++] = (*tensor)(i0, i1); |
| 1487 | } |
| 1488 | } |
| 1489 | |
| 1490 | return 0; |
| 1491 | } |
| 1492 | |
| 1493 | template <> |
| 1494 | int TosaReference::Tensor3<int32_t>::getTensorValueInt32(const size_t bufLen, int32_t* vals) const |
| 1495 | { |
| 1496 | uint32_t idx = 0; |
| 1497 | int totalVals = 1; |
| 1498 | |
| 1499 | for (size_t i = 0; i < shape.size(); i++) |
| 1500 | { |
| 1501 | totalVals *= shape[i]; |
| 1502 | } |
| 1503 | |
| 1504 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1505 | |
| 1506 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1507 | { |
| 1508 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1509 | { |
| 1510 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1511 | { |
| 1512 | vals[idx++] = (*tensor)(i0, i1, i2); |
| 1513 | } |
| 1514 | } |
| 1515 | } |
| 1516 | |
| 1517 | return 0; |
| 1518 | } |
| 1519 | |
| 1520 | template <> |
| 1521 | int TosaReference::Tensor4<int32_t>::getTensorValueInt32(const size_t bufLen, int32_t* vals) const |
| 1522 | { |
| 1523 | uint32_t idx = 0; |
| 1524 | int totalVals = 1; |
| 1525 | |
| 1526 | for (size_t i = 0; i < shape.size(); i++) |
| 1527 | { |
| 1528 | totalVals *= shape[i]; |
| 1529 | } |
| 1530 | |
| 1531 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1532 | |
| 1533 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1534 | { |
| 1535 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1536 | { |
| 1537 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1538 | { |
| 1539 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1540 | { |
| 1541 | vals[idx++] = (*tensor)(i0, i1, i2, i3); |
| 1542 | } |
| 1543 | } |
| 1544 | } |
| 1545 | } |
| 1546 | |
| 1547 | return 0; |
| 1548 | } |
| 1549 | |
| 1550 | template <> |
| 1551 | int TosaReference::Tensor5<int32_t>::getTensorValueInt32(const size_t bufLen, int32_t* vals) const |
| 1552 | { |
| 1553 | uint32_t idx = 0; |
| 1554 | int totalVals = 1; |
| 1555 | |
| 1556 | for (size_t i = 0; i < shape.size(); i++) |
| 1557 | { |
| 1558 | totalVals *= shape[i]; |
| 1559 | } |
| 1560 | |
| 1561 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1562 | |
| 1563 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1564 | { |
| 1565 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1566 | { |
| 1567 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1568 | { |
| 1569 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1570 | { |
| 1571 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 1572 | { |
| 1573 | vals[idx++] = (*tensor)(i0, i1, i2, i3, i4); |
| 1574 | } |
| 1575 | } |
| 1576 | } |
| 1577 | } |
| 1578 | } |
| 1579 | |
| 1580 | return 0; |
| 1581 | } |
| 1582 | |
| 1583 | template <> |
| 1584 | int TosaReference::Tensor6<int32_t>::getTensorValueInt32(const size_t bufLen, int32_t* vals) const |
| 1585 | { |
| 1586 | uint32_t idx = 0; |
| 1587 | int totalVals = 1; |
| 1588 | |
| 1589 | for (size_t i = 0; i < shape.size(); i++) |
| 1590 | { |
| 1591 | totalVals *= shape[i]; |
| 1592 | } |
| 1593 | |
| 1594 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1595 | |
| 1596 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1597 | { |
| 1598 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1599 | { |
| 1600 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1601 | { |
| 1602 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1603 | { |
| 1604 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 1605 | { |
| 1606 | for (int i5 = 0; i5 < shape[5]; i5++) |
| 1607 | { |
| 1608 | vals[idx++] = (*tensor)(i0, i1, i2, i3, i4, i5); |
| 1609 | } |
| 1610 | } |
| 1611 | } |
| 1612 | } |
| 1613 | } |
| 1614 | } |
| 1615 | return 0; |
| 1616 | } |
| 1617 | |
| 1618 | template <class T> |
| 1619 | int TosaReference::TensorTemplate<T>::getTensorValueInt64(const size_t bufLen, int64_t* vals) const |
| 1620 | { |
| 1621 | FATAL_ERROR("TensorTemplate<T>::getTensorValueInt64 should not be called. " |
| 1622 | "Implement template specialization version."); |
| 1623 | return 0; |
| 1624 | } |
| 1625 | |
| 1626 | template <> |
| 1627 | int TosaReference::Tensor0<int64_t>::getTensorValueInt64(const size_t bufLen, int64_t* vals) const |
| 1628 | { |
| 1629 | int totalVals = 1; |
| 1630 | |
| 1631 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1632 | |
| 1633 | vals[0] = (*tensor)(0); |
| 1634 | |
| 1635 | return 0; |
| 1636 | } |
| 1637 | |
| 1638 | template <> |
| 1639 | int TosaReference::Tensor1<int64_t>::getTensorValueInt64(const size_t bufLen, int64_t* vals) const |
| 1640 | { |
| 1641 | uint32_t idx = 0; |
| 1642 | int totalVals = 1; |
| 1643 | |
| 1644 | for (size_t i = 0; i < shape.size(); i++) |
| 1645 | { |
| 1646 | totalVals *= shape[i]; |
| 1647 | } |
| 1648 | |
| 1649 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1650 | |
| 1651 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1652 | { |
| 1653 | vals[idx++] = (*tensor)(i0); |
| 1654 | } |
| 1655 | |
| 1656 | return 0; |
| 1657 | } |
| 1658 | |
| 1659 | template <> |
| 1660 | int TosaReference::Tensor2<int64_t>::getTensorValueInt64(const size_t bufLen, int64_t* vals) const |
| 1661 | { |
| 1662 | uint32_t idx = 0; |
| 1663 | int totalVals = 1; |
| 1664 | |
| 1665 | for (size_t i = 0; i < shape.size(); i++) |
| 1666 | { |
| 1667 | totalVals *= shape[i]; |
| 1668 | } |
| 1669 | |
| 1670 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1671 | |
| 1672 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1673 | { |
| 1674 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1675 | { |
| 1676 | vals[idx++] = (*tensor)(i0, i1); |
| 1677 | } |
| 1678 | } |
| 1679 | |
| 1680 | return 0; |
| 1681 | } |
| 1682 | |
| 1683 | template <> |
| 1684 | int TosaReference::Tensor3<int64_t>::getTensorValueInt64(const size_t bufLen, int64_t* vals) const |
| 1685 | { |
| 1686 | uint32_t idx = 0; |
| 1687 | int totalVals = 1; |
| 1688 | |
| 1689 | for (size_t i = 0; i < shape.size(); i++) |
| 1690 | { |
| 1691 | totalVals *= shape[i]; |
| 1692 | } |
| 1693 | |
| 1694 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1695 | |
| 1696 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1697 | { |
| 1698 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1699 | { |
| 1700 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1701 | { |
| 1702 | vals[idx++] = (*tensor)(i0, i1, i2); |
| 1703 | } |
| 1704 | } |
| 1705 | } |
| 1706 | |
| 1707 | return 0; |
| 1708 | } |
| 1709 | |
| 1710 | template <> |
| 1711 | int TosaReference::Tensor4<int64_t>::getTensorValueInt64(const size_t bufLen, int64_t* vals) const |
| 1712 | { |
| 1713 | uint32_t idx = 0; |
| 1714 | int totalVals = 1; |
| 1715 | |
| 1716 | for (size_t i = 0; i < shape.size(); i++) |
| 1717 | { |
| 1718 | totalVals *= shape[i]; |
| 1719 | } |
| 1720 | |
| 1721 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1722 | |
| 1723 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1724 | { |
| 1725 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1726 | { |
| 1727 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1728 | { |
| 1729 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1730 | { |
| 1731 | vals[idx++] = (*tensor)(i0, i1, i2, i3); |
| 1732 | } |
| 1733 | } |
| 1734 | } |
| 1735 | } |
| 1736 | |
| 1737 | return 0; |
| 1738 | } |
| 1739 | |
| 1740 | template <> |
| 1741 | int TosaReference::Tensor5<int64_t>::getTensorValueInt64(const size_t bufLen, int64_t* vals) const |
| 1742 | { |
| 1743 | uint32_t idx = 0; |
| 1744 | int totalVals = 1; |
| 1745 | |
| 1746 | for (size_t i = 0; i < shape.size(); i++) |
| 1747 | { |
| 1748 | totalVals *= shape[i]; |
| 1749 | } |
| 1750 | |
| 1751 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1752 | |
| 1753 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1754 | { |
| 1755 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1756 | { |
| 1757 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1758 | { |
| 1759 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1760 | { |
| 1761 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 1762 | { |
| 1763 | vals[idx++] = (*tensor)(i0, i1, i2, i3, i4); |
| 1764 | } |
| 1765 | } |
| 1766 | } |
| 1767 | } |
| 1768 | } |
| 1769 | |
| 1770 | return 0; |
| 1771 | } |
| 1772 | |
| 1773 | template <> |
| 1774 | int TosaReference::Tensor6<int64_t>::getTensorValueInt64(const size_t bufLen, int64_t* vals) const |
| 1775 | { |
| 1776 | uint32_t idx = 0; |
| 1777 | int totalVals = 1; |
| 1778 | |
| 1779 | for (size_t i = 0; i < shape.size(); i++) |
| 1780 | { |
| 1781 | totalVals *= shape[i]; |
| 1782 | } |
| 1783 | |
| 1784 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1785 | |
| 1786 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1787 | { |
| 1788 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1789 | { |
| 1790 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1791 | { |
| 1792 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1793 | { |
| 1794 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 1795 | { |
| 1796 | for (int i5 = 0; i5 < shape[5]; i5++) |
| 1797 | { |
| 1798 | vals[idx++] = (*tensor)(i0, i1, i2, i3, i4, i5); |
| 1799 | } |
| 1800 | } |
| 1801 | } |
| 1802 | } |
| 1803 | } |
| 1804 | } |
| 1805 | return 0; |
| 1806 | } |
| 1807 | |
| 1808 | template <class T> |
| 1809 | int TosaReference::TensorTemplate<T>::getTensorValueBool(const size_t bufLen, bool* vals) const |
| 1810 | { |
| 1811 | FATAL_ERROR("TensorTemplate<T>::getTensorValueBool should not be called. " |
| 1812 | "Implement template specialization version."); |
| 1813 | return 0; |
| 1814 | } |
| 1815 | |
| 1816 | template <> |
| 1817 | int TosaReference::Tensor0<bool>::getTensorValueBool(const size_t bufLen, bool* vals) const |
| 1818 | { |
| 1819 | int totalVals = 1; |
| 1820 | |
| 1821 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1822 | |
| 1823 | vals[0] = (*tensor)(0); |
| 1824 | |
| 1825 | return 0; |
| 1826 | } |
| 1827 | |
| 1828 | template <> |
| 1829 | int TosaReference::Tensor1<bool>::getTensorValueBool(const size_t bufLen, bool* vals) const |
| 1830 | { |
| 1831 | uint32_t idx = 0; |
| 1832 | int totalVals = 1; |
| 1833 | |
| 1834 | for (size_t i = 0; i < shape.size(); i++) |
| 1835 | { |
| 1836 | totalVals *= shape[i]; |
| 1837 | } |
| 1838 | |
| 1839 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1840 | |
| 1841 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1842 | { |
| 1843 | vals[idx++] = (*tensor)(i0); |
| 1844 | } |
| 1845 | |
| 1846 | return 0; |
| 1847 | } |
| 1848 | |
| 1849 | template <> |
| 1850 | int TosaReference::Tensor2<bool>::getTensorValueBool(const size_t bufLen, bool* vals) const |
| 1851 | { |
| 1852 | uint32_t idx = 0; |
| 1853 | int totalVals = 1; |
| 1854 | |
| 1855 | for (size_t i = 0; i < shape.size(); i++) |
| 1856 | { |
| 1857 | totalVals *= shape[i]; |
| 1858 | } |
| 1859 | |
| 1860 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1861 | |
| 1862 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1863 | { |
| 1864 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1865 | { |
| 1866 | vals[idx++] = (*tensor)(i0, i1); |
| 1867 | } |
| 1868 | } |
| 1869 | |
| 1870 | return 0; |
| 1871 | } |
| 1872 | |
| 1873 | template <> |
| 1874 | int TosaReference::Tensor3<bool>::getTensorValueBool(const size_t bufLen, bool* vals) const |
| 1875 | { |
| 1876 | uint32_t idx = 0; |
| 1877 | int totalVals = 1; |
| 1878 | |
| 1879 | for (size_t i = 0; i < shape.size(); i++) |
| 1880 | { |
| 1881 | totalVals *= shape[i]; |
| 1882 | } |
| 1883 | |
| 1884 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1885 | |
| 1886 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1887 | { |
| 1888 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1889 | { |
| 1890 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1891 | { |
| 1892 | vals[idx++] = (*tensor)(i0, i1, i2); |
| 1893 | } |
| 1894 | } |
| 1895 | } |
| 1896 | |
| 1897 | return 0; |
| 1898 | } |
| 1899 | |
| 1900 | template <> |
| 1901 | int TosaReference::Tensor4<bool>::getTensorValueBool(const size_t bufLen, bool* vals) const |
| 1902 | { |
| 1903 | uint32_t idx = 0; |
| 1904 | int totalVals = 1; |
| 1905 | |
| 1906 | for (size_t i = 0; i < shape.size(); i++) |
| 1907 | { |
| 1908 | totalVals *= shape[i]; |
| 1909 | } |
| 1910 | |
| 1911 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1912 | |
| 1913 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1914 | { |
| 1915 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1916 | { |
| 1917 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1918 | { |
| 1919 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1920 | { |
| 1921 | vals[idx++] = (*tensor)(i0, i1, i2, i3); |
| 1922 | } |
| 1923 | } |
| 1924 | } |
| 1925 | } |
| 1926 | |
| 1927 | return 0; |
| 1928 | } |
| 1929 | |
| 1930 | template <> |
| 1931 | int TosaReference::Tensor5<bool>::getTensorValueBool(const size_t bufLen, bool* vals) const |
| 1932 | { |
| 1933 | uint32_t idx = 0; |
| 1934 | int totalVals = 1; |
| 1935 | |
| 1936 | for (size_t i = 0; i < shape.size(); i++) |
| 1937 | { |
| 1938 | totalVals *= shape[i]; |
| 1939 | } |
| 1940 | |
| 1941 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1942 | |
| 1943 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1944 | { |
| 1945 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1946 | { |
| 1947 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1948 | { |
| 1949 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1950 | { |
| 1951 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 1952 | { |
| 1953 | vals[idx++] = (*tensor)(i0, i1, i2, i3, i4); |
| 1954 | } |
| 1955 | } |
| 1956 | } |
| 1957 | } |
| 1958 | } |
| 1959 | |
| 1960 | return 0; |
| 1961 | } |
| 1962 | |
| 1963 | template <> |
| 1964 | int TosaReference::Tensor6<bool>::getTensorValueBool(const size_t bufLen, bool* vals) const |
| 1965 | { |
| 1966 | uint32_t idx = 0; |
| 1967 | int totalVals = 1; |
| 1968 | |
| 1969 | for (size_t i = 0; i < shape.size(); i++) |
| 1970 | { |
| 1971 | totalVals *= shape[i]; |
| 1972 | } |
| 1973 | |
| 1974 | ASSERT_MSG((size_t)totalVals == bufLen, "Output buffer and tensor size do not match"); |
| 1975 | |
| 1976 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 1977 | { |
| 1978 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 1979 | { |
| 1980 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 1981 | { |
| 1982 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 1983 | { |
| 1984 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 1985 | { |
| 1986 | for (int i5 = 0; i5 < shape[5]; i5++) |
| 1987 | { |
| 1988 | vals[idx++] = (*tensor)(i0, i1, i2, i3, i4, i5); |
| 1989 | } |
| 1990 | } |
| 1991 | } |
| 1992 | } |
| 1993 | } |
| 1994 | } |
| 1995 | return 0; |
| 1996 | } |
| 1997 | |
| 1998 | template <> |
| 1999 | int TosaReference::Tensor0<float>::allocate() |
| 2000 | { |
| 2001 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2002 | tensor = new ETensor0<float>(); |
| 2003 | |
| 2004 | if (tensor) |
| 2005 | return 0; |
| 2006 | else |
| 2007 | return 1; |
| 2008 | } |
| 2009 | template <> |
| 2010 | int TosaReference::Tensor1<float>::allocate() |
| 2011 | { |
| 2012 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2013 | tensor = new ETensor1<float>(shape[0]); |
| 2014 | if (tensor) |
| 2015 | return 0; |
| 2016 | else |
| 2017 | return 1; |
| 2018 | } |
| 2019 | template <> |
| 2020 | int TosaReference::Tensor2<float>::allocate() |
| 2021 | { |
| 2022 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2023 | tensor = new ETensor2<float>(shape[0], shape[1]); |
| 2024 | if (tensor) |
| 2025 | return 0; |
| 2026 | else |
| 2027 | return 1; |
| 2028 | } |
| 2029 | |
| 2030 | template <> |
| 2031 | int TosaReference::Tensor3<float>::allocate() |
| 2032 | { |
| 2033 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2034 | tensor = new ETensor3<float>(shape[0], shape[1], shape[2]); |
| 2035 | if (tensor) |
| 2036 | return 0; |
| 2037 | else |
| 2038 | return 1; |
| 2039 | } |
| 2040 | |
| 2041 | template <> |
| 2042 | int TosaReference::Tensor4<float>::allocate() |
| 2043 | { |
| 2044 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2045 | tensor = new ETensor4<float>(shape[0], shape[1], shape[2], shape[3]); |
| 2046 | if (tensor) |
| 2047 | return 0; |
| 2048 | else |
| 2049 | return 1; |
| 2050 | } |
| 2051 | |
| 2052 | template <> |
| 2053 | int TosaReference::Tensor5<float>::allocate() |
| 2054 | { |
| 2055 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2056 | tensor = new ETensor5<float>(shape[0], shape[1], shape[2], shape[3], shape[4]); |
| 2057 | if (tensor) |
| 2058 | return 0; |
| 2059 | else |
| 2060 | return 1; |
| 2061 | } |
| 2062 | |
| 2063 | template <> |
| 2064 | int TosaReference::Tensor6<float>::allocate() |
| 2065 | { |
| 2066 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2067 | tensor = new ETensor6<float>(shape[0], shape[1], shape[2], shape[3], shape[4], shape[5]); |
| 2068 | if (tensor) |
| 2069 | return 0; |
| 2070 | else |
| 2071 | return 1; |
| 2072 | } |
| 2073 | |
| 2074 | template <> |
| 2075 | int TosaReference::Tensor0<int32_t>::allocate() |
| 2076 | { |
| 2077 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2078 | tensor = new ETensor0<int32_t>(); |
| 2079 | if (tensor) |
| 2080 | return 0; |
| 2081 | else |
| 2082 | return 1; |
| 2083 | } |
| 2084 | template <> |
| 2085 | int TosaReference::Tensor1<int32_t>::allocate() |
| 2086 | { |
| 2087 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2088 | tensor = new ETensor1<int32_t>(shape[0]); |
| 2089 | if (tensor) |
| 2090 | return 0; |
| 2091 | else |
| 2092 | return 1; |
| 2093 | } |
| 2094 | template <> |
| 2095 | int TosaReference::Tensor2<int32_t>::allocate() |
| 2096 | { |
| 2097 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2098 | tensor = new ETensor2<int32_t>(shape[0], shape[1]); |
| 2099 | if (tensor) |
| 2100 | return 0; |
| 2101 | else |
| 2102 | return 1; |
| 2103 | } |
| 2104 | |
| 2105 | template <> |
| 2106 | int TosaReference::Tensor3<int32_t>::allocate() |
| 2107 | { |
| 2108 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2109 | tensor = new ETensor3<int32_t>(shape[0], shape[1], shape[2]); |
| 2110 | if (tensor) |
| 2111 | return 0; |
| 2112 | else |
| 2113 | return 1; |
| 2114 | } |
| 2115 | |
| 2116 | template <> |
| 2117 | int TosaReference::Tensor4<int32_t>::allocate() |
| 2118 | { |
| 2119 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2120 | tensor = new ETensor4<int32_t>(shape[0], shape[1], shape[2], shape[3]); |
| 2121 | if (tensor) |
| 2122 | return 0; |
| 2123 | else |
| 2124 | return 1; |
| 2125 | } |
| 2126 | |
| 2127 | template <> |
| 2128 | int TosaReference::Tensor5<int32_t>::allocate() |
| 2129 | { |
| 2130 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2131 | tensor = new ETensor5<int32_t>(shape[0], shape[1], shape[2], shape[3], shape[4]); |
| 2132 | if (tensor) |
| 2133 | return 0; |
| 2134 | else |
| 2135 | return 1; |
| 2136 | } |
| 2137 | |
| 2138 | template <> |
| 2139 | int TosaReference::Tensor6<int32_t>::allocate() |
| 2140 | { |
| 2141 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2142 | tensor = new ETensor6<int32_t>(shape[0], shape[1], shape[2], shape[3], shape[4], shape[5]); |
| 2143 | if (tensor) |
| 2144 | return 0; |
| 2145 | else |
| 2146 | return 1; |
| 2147 | } |
| 2148 | |
| 2149 | template <> |
| 2150 | int TosaReference::Tensor0<int64_t>::allocate() |
| 2151 | { |
| 2152 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2153 | tensor = new ETensor0<int64_t>(); |
| 2154 | if (tensor) |
| 2155 | return 0; |
| 2156 | else |
| 2157 | return 1; |
| 2158 | } |
| 2159 | template <> |
| 2160 | int TosaReference::Tensor1<int64_t>::allocate() |
| 2161 | { |
| 2162 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2163 | tensor = new ETensor1<int64_t>(shape[0]); |
| 2164 | if (tensor) |
| 2165 | return 0; |
| 2166 | else |
| 2167 | return 1; |
| 2168 | } |
| 2169 | template <> |
| 2170 | int TosaReference::Tensor2<int64_t>::allocate() |
| 2171 | { |
| 2172 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2173 | tensor = new ETensor2<int64_t>(shape[0], shape[1]); |
| 2174 | if (tensor) |
| 2175 | return 0; |
| 2176 | else |
| 2177 | return 1; |
| 2178 | } |
| 2179 | |
| 2180 | template <> |
| 2181 | int TosaReference::Tensor3<int64_t>::allocate() |
| 2182 | { |
| 2183 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2184 | tensor = new ETensor3<int64_t>(shape[0], shape[1], shape[2]); |
| 2185 | if (tensor) |
| 2186 | return 0; |
| 2187 | else |
| 2188 | return 1; |
| 2189 | } |
| 2190 | |
| 2191 | template <> |
| 2192 | int TosaReference::Tensor4<int64_t>::allocate() |
| 2193 | { |
| 2194 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2195 | tensor = new ETensor4<int64_t>(shape[0], shape[1], shape[2], shape[3]); |
| 2196 | if (tensor) |
| 2197 | return 0; |
| 2198 | else |
| 2199 | return 1; |
| 2200 | } |
| 2201 | |
| 2202 | template <> |
| 2203 | int TosaReference::Tensor5<int64_t>::allocate() |
| 2204 | { |
| 2205 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2206 | tensor = new ETensor5<int64_t>(shape[0], shape[1], shape[2], shape[3], shape[4]); |
| 2207 | if (tensor) |
| 2208 | return 0; |
| 2209 | else |
| 2210 | return 1; |
| 2211 | } |
| 2212 | |
| 2213 | template <> |
| 2214 | int TosaReference::Tensor6<int64_t>::allocate() |
| 2215 | { |
| 2216 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2217 | tensor = new ETensor6<int64_t>(shape[0], shape[1], shape[2], shape[3], shape[4], shape[5]); |
| 2218 | if (tensor) |
| 2219 | return 0; |
| 2220 | else |
| 2221 | return 1; |
| 2222 | } |
| 2223 | |
| 2224 | template <> |
| 2225 | int TosaReference::Tensor0<bool>::allocate() |
| 2226 | { |
| 2227 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2228 | tensor = new ETensor0<bool>(); |
| 2229 | if (tensor) |
| 2230 | return 0; |
| 2231 | else |
| 2232 | return 1; |
| 2233 | } |
| 2234 | template <> |
| 2235 | int TosaReference::Tensor1<bool>::allocate() |
| 2236 | { |
| 2237 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2238 | tensor = new ETensor1<bool>(shape[0]); |
| 2239 | if (tensor) |
| 2240 | return 0; |
| 2241 | else |
| 2242 | return 1; |
| 2243 | } |
| 2244 | template <> |
| 2245 | int TosaReference::Tensor2<bool>::allocate() |
| 2246 | { |
| 2247 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2248 | tensor = new ETensor2<bool>(shape[0], shape[1]); |
| 2249 | if (tensor) |
| 2250 | return 0; |
| 2251 | else |
| 2252 | return 1; |
| 2253 | } |
| 2254 | |
| 2255 | template <> |
| 2256 | int TosaReference::Tensor3<bool>::allocate() |
| 2257 | { |
| 2258 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2259 | tensor = new ETensor3<bool>(shape[0], shape[1], shape[2]); |
| 2260 | if (tensor) |
| 2261 | return 0; |
| 2262 | else |
| 2263 | return 1; |
| 2264 | } |
| 2265 | |
| 2266 | template <> |
| 2267 | int TosaReference::Tensor4<bool>::allocate() |
| 2268 | { |
| 2269 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2270 | tensor = new ETensor4<bool>(shape[0], shape[1], shape[2], shape[3]); |
| 2271 | if (tensor) |
| 2272 | return 0; |
| 2273 | else |
| 2274 | return 1; |
| 2275 | } |
| 2276 | |
| 2277 | template <> |
| 2278 | int TosaReference::Tensor5<bool>::allocate() |
| 2279 | { |
| 2280 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2281 | tensor = new ETensor5<bool>(shape[0], shape[1], shape[2], shape[3], shape[4]); |
| 2282 | if (tensor) |
| 2283 | return 0; |
| 2284 | else |
| 2285 | return 1; |
| 2286 | } |
| 2287 | |
| 2288 | template <> |
| 2289 | int TosaReference::Tensor6<bool>::allocate() |
| 2290 | { |
| 2291 | ASSERT_MSG(tensor == nullptr, "Error: double allocate Eigen tensor"); |
| 2292 | tensor = new ETensor6<bool>(shape[0], shape[1], shape[2], shape[3], shape[4], shape[5]); |
| 2293 | if (tensor) |
| 2294 | return 0; |
| 2295 | else |
| 2296 | return 1; |
| 2297 | } |
| 2298 | |
| 2299 | template <> |
| 2300 | int TosaReference::Tensor0<float>::dumpTensor(FILE* out) const |
| 2301 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2302 | char fp_fmt[32]; |
| 2303 | snprintf(fp_fmt, sizeof(fp_fmt), "[ %%%sf ]\n", g_func_config.fp_format.c_str()); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2304 | |
| 2305 | if (tensor == nullptr) |
| 2306 | { |
| 2307 | fprintf(out, "<Not allocated>\n"); |
| 2308 | return 0; |
| 2309 | } |
| 2310 | |
| 2311 | fprintf(out, fp_fmt, (*tensor)(0)); |
| 2312 | |
| 2313 | return 0; |
| 2314 | } |
| 2315 | |
| 2316 | template <> |
| 2317 | int TosaReference::Tensor1<float>::dumpTensor(FILE* out) const |
| 2318 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2319 | char fp_fmt[32]; |
| 2320 | snprintf(fp_fmt, sizeof(fp_fmt), " %%%sf ", g_func_config.fp_format.c_str()); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2321 | |
| 2322 | if (tensor == nullptr) |
| 2323 | { |
| 2324 | fprintf(out, "<Not allocated>\n"); |
| 2325 | return 0; |
| 2326 | } |
| 2327 | |
| 2328 | fprintf(out, "["); |
| 2329 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2330 | { |
| 2331 | fprintf(out, fp_fmt, (*tensor)(i0)); |
| 2332 | } |
| 2333 | fprintf(out, "]\n"); |
| 2334 | |
| 2335 | return 0; |
| 2336 | } |
| 2337 | |
| 2338 | template <> |
| 2339 | int TosaReference::Tensor2<float>::dumpTensor(FILE* out) const |
| 2340 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2341 | char fp_fmt[32]; |
| 2342 | snprintf(fp_fmt, sizeof(fp_fmt), " %%%sf ", g_func_config.fp_format.c_str()); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2343 | |
| 2344 | if (tensor == nullptr) |
| 2345 | { |
| 2346 | fprintf(out, "<Not allocated>\n"); |
| 2347 | return 0; |
| 2348 | } |
| 2349 | |
| 2350 | fprintf(out, "["); |
| 2351 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2352 | { |
| 2353 | fprintf(out, "["); |
| 2354 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2355 | { |
| 2356 | fprintf(out, fp_fmt, (*tensor)(i0, i1)); |
| 2357 | } |
| 2358 | fprintf(out, "]\n"); |
| 2359 | } |
| 2360 | fprintf(out, "]\n"); |
| 2361 | |
| 2362 | return 0; |
| 2363 | } |
| 2364 | |
| 2365 | template <> |
| 2366 | int TosaReference::Tensor3<float>::dumpTensor(FILE* out) const |
| 2367 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2368 | char fp_fmt[32]; |
| 2369 | snprintf(fp_fmt, sizeof(fp_fmt), " %%%sf ", g_func_config.fp_format.c_str()); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2370 | |
| 2371 | if (tensor == nullptr) |
| 2372 | { |
| 2373 | fprintf(out, "<Not allocated>\n"); |
| 2374 | return 0; |
| 2375 | } |
| 2376 | |
| 2377 | fprintf(out, "["); |
| 2378 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2379 | { |
| 2380 | fprintf(out, "["); |
| 2381 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2382 | { |
| 2383 | fprintf(out, "["); |
| 2384 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 2385 | { |
| 2386 | fprintf(out, fp_fmt, (*tensor)(i0, i1, i2)); |
| 2387 | } |
| 2388 | fprintf(out, "]\n"); |
| 2389 | } |
| 2390 | fprintf(out, "]\n"); |
| 2391 | } |
| 2392 | fprintf(out, "]\n"); |
| 2393 | |
| 2394 | return 0; |
| 2395 | } |
| 2396 | |
| 2397 | template <> |
| 2398 | int TosaReference::Tensor4<float>::dumpTensor(FILE* out) const |
| 2399 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2400 | char fp_fmt[32]; |
| 2401 | snprintf(fp_fmt, sizeof(fp_fmt), " %%%sf ", g_func_config.fp_format.c_str()); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2402 | |
| 2403 | if (tensor == nullptr) |
| 2404 | { |
| 2405 | fprintf(out, "<Not allocated>\n"); |
| 2406 | return 0; |
| 2407 | } |
| 2408 | |
| 2409 | fprintf(out, "["); |
| 2410 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2411 | { |
| 2412 | fprintf(out, "["); |
| 2413 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2414 | { |
| 2415 | fprintf(out, "["); |
| 2416 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 2417 | { |
| 2418 | fprintf(out, "["); |
| 2419 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 2420 | { |
| 2421 | fprintf(out, fp_fmt, (*tensor)(i0, i1, i2, i3)); |
| 2422 | } |
| 2423 | fprintf(out, "]\n"); |
| 2424 | } |
| 2425 | fprintf(out, "]\n"); |
| 2426 | } |
| 2427 | fprintf(out, "]\n"); |
| 2428 | } |
| 2429 | fprintf(out, "]\n"); |
| 2430 | |
| 2431 | return 0; |
| 2432 | } |
| 2433 | |
| 2434 | template <> |
| 2435 | int TosaReference::Tensor5<float>::dumpTensor(FILE* out) const |
| 2436 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2437 | char fp_fmt[32]; |
| 2438 | snprintf(fp_fmt, sizeof(fp_fmt), " %%%sf ", g_func_config.fp_format.c_str()); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2439 | |
| 2440 | if (tensor == nullptr) |
| 2441 | { |
| 2442 | fprintf(out, "<Not allocated>\n"); |
| 2443 | return 0; |
| 2444 | } |
| 2445 | |
| 2446 | fprintf(out, "["); |
| 2447 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2448 | { |
| 2449 | fprintf(out, "["); |
| 2450 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2451 | { |
| 2452 | fprintf(out, "["); |
| 2453 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 2454 | { |
| 2455 | fprintf(out, "["); |
| 2456 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 2457 | { |
| 2458 | fprintf(out, "["); |
| 2459 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 2460 | { |
| 2461 | fprintf(out, fp_fmt, (*tensor)(i0, i1, i2, i3, i4)); |
| 2462 | } |
| 2463 | fprintf(out, "]\n"); |
| 2464 | } |
| 2465 | fprintf(out, "]\n"); |
| 2466 | } |
| 2467 | fprintf(out, "]\n"); |
| 2468 | } |
| 2469 | fprintf(out, "]\n"); |
| 2470 | } |
| 2471 | fprintf(out, "]\n"); |
| 2472 | |
| 2473 | return 0; |
| 2474 | } |
| 2475 | |
| 2476 | template <> |
| 2477 | int TosaReference::Tensor6<float>::dumpTensor(FILE* out) const |
| 2478 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2479 | char fp_fmt[32]; |
| 2480 | snprintf(fp_fmt, sizeof(fp_fmt), " %%%sf ", g_func_config.fp_format.c_str()); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2481 | |
| 2482 | if (tensor == nullptr) |
| 2483 | { |
| 2484 | fprintf(out, "<Not allocated>\n"); |
| 2485 | return 0; |
| 2486 | } |
| 2487 | |
| 2488 | fprintf(out, "["); |
| 2489 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2490 | { |
| 2491 | fprintf(out, "["); |
| 2492 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2493 | { |
| 2494 | fprintf(out, "["); |
| 2495 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 2496 | { |
| 2497 | fprintf(out, "["); |
| 2498 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 2499 | { |
| 2500 | fprintf(out, "["); |
| 2501 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 2502 | { |
| 2503 | fprintf(out, "["); |
| 2504 | for (int i5 = 0; i5 < shape[5]; i5++) |
| 2505 | { |
| 2506 | fprintf(out, fp_fmt, (*tensor)(i0, i1, i2, i3, i4, i5)); |
| 2507 | } |
| 2508 | fprintf(out, "]\n"); |
| 2509 | } |
| 2510 | fprintf(out, "]\n"); |
| 2511 | } |
| 2512 | fprintf(out, "]\n"); |
| 2513 | } |
| 2514 | fprintf(out, "]\n"); |
| 2515 | } |
| 2516 | fprintf(out, "]\n"); |
| 2517 | } |
| 2518 | fprintf(out, "]\n"); |
| 2519 | |
| 2520 | return 0; |
| 2521 | } |
| 2522 | |
| 2523 | template <> |
| 2524 | int TosaReference::Tensor0<int64_t>::dumpTensor(FILE* out) const |
| 2525 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2526 | char i64_fmt[32]; |
| 2527 | snprintf(i64_fmt, sizeof(i64_fmt), "[ %%ld ]\n"); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2528 | |
| 2529 | if (tensor == nullptr) |
| 2530 | { |
| 2531 | fprintf(out, "<Not allocated>\n"); |
| 2532 | return 0; |
| 2533 | } |
| 2534 | |
| 2535 | fprintf(out, i64_fmt, (*tensor)(0)); |
| 2536 | |
| 2537 | return 0; |
| 2538 | } |
| 2539 | |
| 2540 | template <> |
| 2541 | int TosaReference::Tensor1<int64_t>::dumpTensor(FILE* out) const |
| 2542 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2543 | char i64_fmt[32]; |
| 2544 | snprintf(i64_fmt, sizeof(i64_fmt), " %%ld "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2545 | |
| 2546 | if (tensor == nullptr) |
| 2547 | { |
| 2548 | fprintf(out, "<Not allocated>\n"); |
| 2549 | return 0; |
| 2550 | } |
| 2551 | |
| 2552 | fprintf(out, "["); |
| 2553 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2554 | { |
| 2555 | fprintf(out, i64_fmt, (*tensor)(i0)); |
| 2556 | } |
| 2557 | fprintf(out, "]\n"); |
| 2558 | |
| 2559 | return 0; |
| 2560 | } |
| 2561 | |
| 2562 | template <> |
| 2563 | int TosaReference::Tensor2<int64_t>::dumpTensor(FILE* out) const |
| 2564 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2565 | char i64_fmt[32]; |
| 2566 | snprintf(i64_fmt, sizeof(i64_fmt), " %%ld "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2567 | |
| 2568 | if (tensor == nullptr) |
| 2569 | { |
| 2570 | fprintf(out, "<Not allocated>\n"); |
| 2571 | return 0; |
| 2572 | } |
| 2573 | |
| 2574 | fprintf(out, "["); |
| 2575 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2576 | { |
| 2577 | fprintf(out, "["); |
| 2578 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2579 | { |
| 2580 | fprintf(out, i64_fmt, (*tensor)(i0, i1)); |
| 2581 | } |
| 2582 | fprintf(out, "]\n"); |
| 2583 | } |
| 2584 | fprintf(out, "]\n"); |
| 2585 | |
| 2586 | return 0; |
| 2587 | } |
| 2588 | |
| 2589 | template <> |
| 2590 | int TosaReference::Tensor3<int64_t>::dumpTensor(FILE* out) const |
| 2591 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2592 | char i64_fmt[32]; |
| 2593 | snprintf(i64_fmt, sizeof(i64_fmt), " %%ld "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2594 | |
| 2595 | if (tensor == nullptr) |
| 2596 | { |
| 2597 | fprintf(out, "<Not allocated>\n"); |
| 2598 | return 0; |
| 2599 | } |
| 2600 | |
| 2601 | fprintf(out, "["); |
| 2602 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2603 | { |
| 2604 | fprintf(out, "["); |
| 2605 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2606 | { |
| 2607 | fprintf(out, "["); |
| 2608 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 2609 | { |
| 2610 | fprintf(out, i64_fmt, (*tensor)(i0, i1, i2)); |
| 2611 | } |
| 2612 | fprintf(out, "]\n"); |
| 2613 | } |
| 2614 | fprintf(out, "]\n"); |
| 2615 | } |
| 2616 | fprintf(out, "]\n"); |
| 2617 | |
| 2618 | return 0; |
| 2619 | } |
| 2620 | |
| 2621 | template <> |
| 2622 | int TosaReference::Tensor4<int64_t>::dumpTensor(FILE* out) const |
| 2623 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2624 | char i64_fmt[32]; |
| 2625 | snprintf(i64_fmt, sizeof(i64_fmt), " %%ld "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2626 | |
| 2627 | if (tensor == nullptr) |
| 2628 | { |
| 2629 | fprintf(out, "<Not allocated>\n"); |
| 2630 | return 0; |
| 2631 | } |
| 2632 | |
| 2633 | fprintf(out, "["); |
| 2634 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2635 | { |
| 2636 | fprintf(out, "["); |
| 2637 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2638 | { |
| 2639 | fprintf(out, "["); |
| 2640 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 2641 | { |
| 2642 | fprintf(out, "["); |
| 2643 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 2644 | { |
| 2645 | fprintf(out, i64_fmt, (*tensor)(i0, i1, i2, i3)); |
| 2646 | } |
| 2647 | fprintf(out, "]\n"); |
| 2648 | } |
| 2649 | fprintf(out, "]\n"); |
| 2650 | } |
| 2651 | fprintf(out, "]\n"); |
| 2652 | } |
| 2653 | fprintf(out, "]\n"); |
| 2654 | |
| 2655 | return 0; |
| 2656 | } |
| 2657 | |
| 2658 | template <> |
| 2659 | int TosaReference::Tensor5<int64_t>::dumpTensor(FILE* out) const |
| 2660 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2661 | char i64_fmt[32]; |
| 2662 | snprintf(i64_fmt, sizeof(i64_fmt), " %%ld "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2663 | |
| 2664 | if (tensor == nullptr) |
| 2665 | { |
| 2666 | fprintf(out, "<Not allocated>\n"); |
| 2667 | return 0; |
| 2668 | } |
| 2669 | |
| 2670 | fprintf(out, "["); |
| 2671 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2672 | { |
| 2673 | fprintf(out, "["); |
| 2674 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2675 | { |
| 2676 | fprintf(out, "["); |
| 2677 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 2678 | { |
| 2679 | fprintf(out, "["); |
| 2680 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 2681 | { |
| 2682 | fprintf(out, "["); |
| 2683 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 2684 | { |
| 2685 | fprintf(out, i64_fmt, (*tensor)(i0, i1, i2, i3, i4)); |
| 2686 | } |
| 2687 | fprintf(out, "]\n"); |
| 2688 | } |
| 2689 | fprintf(out, "]\n"); |
| 2690 | } |
| 2691 | fprintf(out, "]\n"); |
| 2692 | } |
| 2693 | fprintf(out, "]\n"); |
| 2694 | } |
| 2695 | fprintf(out, "]\n"); |
| 2696 | |
| 2697 | return 0; |
| 2698 | } |
| 2699 | |
| 2700 | template <> |
| 2701 | int TosaReference::Tensor6<int64_t>::dumpTensor(FILE* out) const |
| 2702 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2703 | char i64_fmt[32]; |
| 2704 | snprintf(i64_fmt, sizeof(i64_fmt), " %%ld "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2705 | |
| 2706 | if (tensor == nullptr) |
| 2707 | { |
| 2708 | fprintf(out, "<Not allocated>\n"); |
| 2709 | return 0; |
| 2710 | } |
| 2711 | |
| 2712 | fprintf(out, "["); |
| 2713 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2714 | { |
| 2715 | fprintf(out, "["); |
| 2716 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2717 | { |
| 2718 | fprintf(out, "["); |
| 2719 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 2720 | { |
| 2721 | fprintf(out, "["); |
| 2722 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 2723 | { |
| 2724 | fprintf(out, "["); |
| 2725 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 2726 | { |
| 2727 | fprintf(out, "["); |
| 2728 | for (int i5 = 0; i5 < shape[5]; i5++) |
| 2729 | { |
| 2730 | fprintf(out, i64_fmt, (*tensor)(i0, i1, i2, i3, i4, i5)); |
| 2731 | } |
| 2732 | fprintf(out, "]\n"); |
| 2733 | } |
| 2734 | fprintf(out, "]\n"); |
| 2735 | } |
| 2736 | fprintf(out, "]\n"); |
| 2737 | } |
| 2738 | fprintf(out, "]\n"); |
| 2739 | } |
| 2740 | fprintf(out, "]\n"); |
| 2741 | } |
| 2742 | fprintf(out, "]\n"); |
| 2743 | |
| 2744 | return 0; |
| 2745 | } |
| 2746 | |
| 2747 | template <> |
| 2748 | int TosaReference::Tensor0<int32_t>::dumpTensor(FILE* out) const |
| 2749 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2750 | char i32_fmt[32]; |
| 2751 | snprintf(i32_fmt, sizeof(i32_fmt), "[ %%d ]\n"); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2752 | |
| 2753 | if (tensor == nullptr) |
| 2754 | { |
| 2755 | fprintf(out, "<Not allocated>\n"); |
| 2756 | return 0; |
| 2757 | } |
| 2758 | |
| 2759 | fprintf(out, i32_fmt, (*tensor)(0)); |
| 2760 | |
| 2761 | return 0; |
| 2762 | } |
| 2763 | |
| 2764 | template <> |
| 2765 | int TosaReference::Tensor1<int32_t>::dumpTensor(FILE* out) const |
| 2766 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2767 | char i32_fmt[32]; |
| 2768 | snprintf(i32_fmt, sizeof(i32_fmt), " %%d "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2769 | |
| 2770 | if (tensor == nullptr) |
| 2771 | { |
| 2772 | fprintf(out, "<Not allocated>\n"); |
| 2773 | return 0; |
| 2774 | } |
| 2775 | |
| 2776 | fprintf(out, "["); |
| 2777 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2778 | { |
| 2779 | fprintf(out, i32_fmt, (*tensor)(i0)); |
| 2780 | } |
| 2781 | fprintf(out, "]\n"); |
| 2782 | |
| 2783 | return 0; |
| 2784 | } |
| 2785 | |
| 2786 | template <> |
| 2787 | int TosaReference::Tensor2<int32_t>::dumpTensor(FILE* out) const |
| 2788 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2789 | char i32_fmt[32]; |
| 2790 | snprintf(i32_fmt, sizeof(i32_fmt), " %%d "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2791 | |
| 2792 | if (tensor == nullptr) |
| 2793 | { |
| 2794 | fprintf(out, "<Not allocated>\n"); |
| 2795 | return 0; |
| 2796 | } |
| 2797 | |
| 2798 | if (tensor == nullptr) |
| 2799 | { |
| 2800 | fprintf(out, "<Not allocated>\n"); |
| 2801 | return 0; |
| 2802 | } |
| 2803 | |
| 2804 | fprintf(out, "["); |
| 2805 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2806 | { |
| 2807 | fprintf(out, "["); |
| 2808 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2809 | { |
| 2810 | fprintf(out, i32_fmt, (*tensor)(i0, i1)); |
| 2811 | } |
| 2812 | fprintf(out, "]\n"); |
| 2813 | } |
| 2814 | fprintf(out, "]\n"); |
| 2815 | |
| 2816 | return 0; |
| 2817 | } |
| 2818 | |
| 2819 | template <> |
| 2820 | int TosaReference::Tensor3<int32_t>::dumpTensor(FILE* out) const |
| 2821 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2822 | char i32_fmt[32]; |
| 2823 | snprintf(i32_fmt, sizeof(i32_fmt), " %%d "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2824 | |
| 2825 | if (tensor == nullptr) |
| 2826 | { |
| 2827 | fprintf(out, "<Not allocated>\n"); |
| 2828 | return 0; |
| 2829 | } |
| 2830 | |
| 2831 | if (tensor == nullptr) |
| 2832 | { |
| 2833 | fprintf(out, "<Not allocated>\n"); |
| 2834 | return 0; |
| 2835 | } |
| 2836 | |
| 2837 | fprintf(out, "["); |
| 2838 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2839 | { |
| 2840 | fprintf(out, "["); |
| 2841 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2842 | { |
| 2843 | fprintf(out, "["); |
| 2844 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 2845 | { |
| 2846 | fprintf(out, i32_fmt, (*tensor)(i0, i1, i2)); |
| 2847 | } |
| 2848 | fprintf(out, "]\n"); |
| 2849 | } |
| 2850 | fprintf(out, "]\n"); |
| 2851 | } |
| 2852 | fprintf(out, "]\n"); |
| 2853 | |
| 2854 | return 0; |
| 2855 | } |
| 2856 | |
| 2857 | template <> |
| 2858 | int TosaReference::Tensor4<int32_t>::dumpTensor(FILE* out) const |
| 2859 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2860 | char i32_fmt[32]; |
| 2861 | snprintf(i32_fmt, sizeof(i32_fmt), " %%d "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2862 | |
| 2863 | if (tensor == nullptr) |
| 2864 | { |
| 2865 | fprintf(out, "<Not allocated>\n"); |
| 2866 | return 0; |
| 2867 | } |
| 2868 | |
| 2869 | fprintf(out, "["); |
| 2870 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2871 | { |
| 2872 | fprintf(out, "["); |
| 2873 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2874 | { |
| 2875 | fprintf(out, "["); |
| 2876 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 2877 | { |
| 2878 | fprintf(out, "["); |
| 2879 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 2880 | { |
| 2881 | fprintf(out, i32_fmt, (*tensor)(i0, i1, i2, i3)); |
| 2882 | } |
| 2883 | fprintf(out, "]\n"); |
| 2884 | } |
| 2885 | fprintf(out, "]\n"); |
| 2886 | } |
| 2887 | fprintf(out, "]\n"); |
| 2888 | } |
| 2889 | fprintf(out, "]\n"); |
| 2890 | |
| 2891 | return 0; |
| 2892 | } |
| 2893 | |
| 2894 | template <> |
| 2895 | int TosaReference::Tensor5<int32_t>::dumpTensor(FILE* out) const |
| 2896 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2897 | char i32_fmt[32]; |
| 2898 | snprintf(i32_fmt, sizeof(i32_fmt), " %%d "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2899 | |
| 2900 | if (tensor == nullptr) |
| 2901 | { |
| 2902 | fprintf(out, "<Not allocated>\n"); |
| 2903 | return 0; |
| 2904 | } |
| 2905 | |
| 2906 | fprintf(out, "["); |
| 2907 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2908 | { |
| 2909 | fprintf(out, "["); |
| 2910 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2911 | { |
| 2912 | fprintf(out, "["); |
| 2913 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 2914 | { |
| 2915 | fprintf(out, "["); |
| 2916 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 2917 | { |
| 2918 | fprintf(out, "["); |
| 2919 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 2920 | { |
| 2921 | fprintf(out, i32_fmt, (*tensor)(i0, i1, i2, i3, i4)); |
| 2922 | } |
| 2923 | fprintf(out, "]\n"); |
| 2924 | } |
| 2925 | fprintf(out, "]\n"); |
| 2926 | } |
| 2927 | fprintf(out, "]\n"); |
| 2928 | } |
| 2929 | fprintf(out, "]\n"); |
| 2930 | } |
| 2931 | fprintf(out, "]\n"); |
| 2932 | |
| 2933 | return 0; |
| 2934 | } |
| 2935 | |
| 2936 | template <> |
| 2937 | int TosaReference::Tensor6<int32_t>::dumpTensor(FILE* out) const |
| 2938 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2939 | char i32_fmt[32]; |
| 2940 | snprintf(i32_fmt, sizeof(i32_fmt), " %%d "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2941 | |
| 2942 | if (tensor == nullptr) |
| 2943 | { |
| 2944 | fprintf(out, "<Not allocated>\n"); |
| 2945 | return 0; |
| 2946 | } |
| 2947 | |
| 2948 | fprintf(out, "["); |
| 2949 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 2950 | { |
| 2951 | fprintf(out, "["); |
| 2952 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 2953 | { |
| 2954 | fprintf(out, "["); |
| 2955 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 2956 | { |
| 2957 | fprintf(out, "["); |
| 2958 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 2959 | { |
| 2960 | fprintf(out, "["); |
| 2961 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 2962 | { |
| 2963 | fprintf(out, "["); |
| 2964 | for (int i5 = 0; i5 < shape[5]; i5++) |
| 2965 | { |
| 2966 | fprintf(out, i32_fmt, (*tensor)(i0, i1, i2, i3, i4, i5)); |
| 2967 | } |
| 2968 | fprintf(out, "]\n"); |
| 2969 | } |
| 2970 | fprintf(out, "]\n"); |
| 2971 | } |
| 2972 | fprintf(out, "]\n"); |
| 2973 | } |
| 2974 | fprintf(out, "]\n"); |
| 2975 | } |
| 2976 | fprintf(out, "]\n"); |
| 2977 | } |
| 2978 | fprintf(out, "]\n"); |
| 2979 | |
| 2980 | return 0; |
| 2981 | } |
| 2982 | |
| 2983 | template <> |
| 2984 | int TosaReference::Tensor0<bool>::dumpTensor(FILE* out) const |
| 2985 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 2986 | char bool_fmt[32]; |
| 2987 | snprintf(bool_fmt, sizeof(bool_fmt), "[ %%s ]\n"); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 2988 | |
| 2989 | if (tensor == nullptr) |
| 2990 | { |
| 2991 | fprintf(out, "<Not allocated>\n"); |
| 2992 | return 0; |
| 2993 | } |
| 2994 | |
| 2995 | fprintf(out, bool_fmt, bool_to_str((*tensor)(0))); |
| 2996 | |
| 2997 | return 0; |
| 2998 | } |
| 2999 | |
| 3000 | template <> |
| 3001 | int TosaReference::Tensor1<bool>::dumpTensor(FILE* out) const |
| 3002 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 3003 | char bool_fmt[32]; |
| 3004 | snprintf(bool_fmt, sizeof(bool_fmt), " %%s "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 3005 | |
| 3006 | if (tensor == nullptr) |
| 3007 | { |
| 3008 | fprintf(out, "<Not allocated>\n"); |
| 3009 | return 0; |
| 3010 | } |
| 3011 | |
| 3012 | fprintf(out, "["); |
| 3013 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 3014 | { |
| 3015 | fprintf(out, bool_fmt, bool_to_str((*tensor)(i0))); |
| 3016 | } |
| 3017 | fprintf(out, "]\n"); |
| 3018 | |
| 3019 | return 0; |
| 3020 | } |
| 3021 | |
| 3022 | template <> |
| 3023 | int TosaReference::Tensor2<bool>::dumpTensor(FILE* out) const |
| 3024 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 3025 | char bool_fmt[32]; |
| 3026 | snprintf(bool_fmt, sizeof(bool_fmt), " %%s "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 3027 | |
| 3028 | if (tensor == nullptr) |
| 3029 | { |
| 3030 | fprintf(out, "<Not allocated>\n"); |
| 3031 | return 0; |
| 3032 | } |
| 3033 | |
| 3034 | fprintf(out, "["); |
| 3035 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 3036 | { |
| 3037 | fprintf(out, "["); |
| 3038 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 3039 | { |
| 3040 | fprintf(out, bool_fmt, bool_to_str((*tensor)(i0, i1))); |
| 3041 | } |
| 3042 | fprintf(out, "]\n"); |
| 3043 | } |
| 3044 | fprintf(out, "]\n"); |
| 3045 | |
| 3046 | return 0; |
| 3047 | } |
| 3048 | |
| 3049 | template <> |
| 3050 | int TosaReference::Tensor3<bool>::dumpTensor(FILE* out) const |
| 3051 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 3052 | char bool_fmt[32]; |
| 3053 | snprintf(bool_fmt, sizeof(bool_fmt), " %%s "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 3054 | |
| 3055 | if (tensor == nullptr) |
| 3056 | { |
| 3057 | fprintf(out, "<Not allocated>\n"); |
| 3058 | return 0; |
| 3059 | } |
| 3060 | |
| 3061 | fprintf(out, "["); |
| 3062 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 3063 | { |
| 3064 | fprintf(out, "["); |
| 3065 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 3066 | { |
| 3067 | fprintf(out, "["); |
| 3068 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 3069 | { |
| 3070 | fprintf(out, bool_fmt, bool_to_str((*tensor)(i0, i1, i2))); |
| 3071 | } |
| 3072 | fprintf(out, "]\n"); |
| 3073 | } |
| 3074 | fprintf(out, "]\n"); |
| 3075 | } |
| 3076 | fprintf(out, "]\n"); |
| 3077 | |
| 3078 | return 0; |
| 3079 | } |
| 3080 | |
| 3081 | template <> |
| 3082 | int TosaReference::Tensor4<bool>::dumpTensor(FILE* out) const |
| 3083 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 3084 | char bool_fmt[32]; |
| 3085 | snprintf(bool_fmt, sizeof(bool_fmt), " %%s "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 3086 | |
| 3087 | if (tensor == nullptr) |
| 3088 | { |
| 3089 | fprintf(out, "<Not allocated>\n"); |
| 3090 | return 0; |
| 3091 | } |
| 3092 | |
| 3093 | fprintf(out, "["); |
| 3094 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 3095 | { |
| 3096 | fprintf(out, "["); |
| 3097 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 3098 | { |
| 3099 | fprintf(out, "["); |
| 3100 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 3101 | { |
| 3102 | fprintf(out, "["); |
| 3103 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 3104 | { |
| 3105 | fprintf(out, bool_fmt, bool_to_str((*tensor)(i0, i1, i2, i3))); |
| 3106 | } |
| 3107 | fprintf(out, "]\n"); |
| 3108 | } |
| 3109 | fprintf(out, "]\n"); |
| 3110 | } |
| 3111 | fprintf(out, "]\n"); |
| 3112 | } |
| 3113 | fprintf(out, "]\n"); |
| 3114 | |
| 3115 | return 0; |
| 3116 | } |
| 3117 | |
| 3118 | template <> |
| 3119 | int TosaReference::Tensor5<bool>::dumpTensor(FILE* out) const |
| 3120 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 3121 | char bool_fmt[32]; |
| 3122 | snprintf(bool_fmt, sizeof(bool_fmt), " %%s "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 3123 | |
| 3124 | if (tensor == nullptr) |
| 3125 | { |
| 3126 | fprintf(out, "<Not allocated>\n"); |
| 3127 | return 0; |
| 3128 | } |
| 3129 | |
| 3130 | fprintf(out, "["); |
| 3131 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 3132 | { |
| 3133 | fprintf(out, "["); |
| 3134 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 3135 | { |
| 3136 | fprintf(out, "["); |
| 3137 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 3138 | { |
| 3139 | fprintf(out, "["); |
| 3140 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 3141 | { |
| 3142 | fprintf(out, "["); |
| 3143 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 3144 | { |
| 3145 | fprintf(out, bool_fmt, bool_to_str((*tensor)(i0, i1, i2, i3, i4))); |
| 3146 | } |
| 3147 | fprintf(out, "]\n"); |
| 3148 | } |
| 3149 | fprintf(out, "]\n"); |
| 3150 | } |
| 3151 | fprintf(out, "]\n"); |
| 3152 | } |
| 3153 | fprintf(out, "]\n"); |
| 3154 | } |
| 3155 | fprintf(out, "]\n"); |
| 3156 | |
| 3157 | return 0; |
| 3158 | } |
| 3159 | |
| 3160 | template <> |
| 3161 | int TosaReference::Tensor6<bool>::dumpTensor(FILE* out) const |
| 3162 | { |
Eric Kunze | 286f834 | 2022-06-22 11:30:23 -0700 | [diff] [blame] | 3163 | char bool_fmt[32]; |
| 3164 | snprintf(bool_fmt, sizeof(bool_fmt), " %%s "); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 3165 | |
| 3166 | if (tensor == nullptr) |
| 3167 | { |
| 3168 | fprintf(out, "<Not allocated>\n"); |
| 3169 | return 0; |
| 3170 | } |
| 3171 | |
| 3172 | fprintf(out, "["); |
| 3173 | for (int i0 = 0; i0 < shape[0]; i0++) |
| 3174 | { |
| 3175 | fprintf(out, "["); |
| 3176 | for (int i1 = 0; i1 < shape[1]; i1++) |
| 3177 | { |
| 3178 | fprintf(out, "["); |
| 3179 | for (int i2 = 0; i2 < shape[2]; i2++) |
| 3180 | { |
| 3181 | fprintf(out, "["); |
| 3182 | for (int i3 = 0; i3 < shape[3]; i3++) |
| 3183 | { |
| 3184 | fprintf(out, "["); |
| 3185 | for (int i4 = 0; i4 < shape[4]; i4++) |
| 3186 | { |
| 3187 | fprintf(out, "["); |
| 3188 | for (int i5 = 0; i5 < shape[5]; i5++) |
| 3189 | { |
| 3190 | fprintf(out, bool_fmt, bool_to_str((*tensor)(i0, i1, i2, i3, i4, i5))); |
| 3191 | } |
| 3192 | fprintf(out, "]\n"); |
| 3193 | } |
| 3194 | fprintf(out, "]\n"); |
| 3195 | } |
| 3196 | fprintf(out, "]\n"); |
| 3197 | } |
| 3198 | fprintf(out, "]\n"); |
| 3199 | } |
| 3200 | fprintf(out, "]\n"); |
| 3201 | } |
| 3202 | fprintf(out, "]\n"); |
| 3203 | |
| 3204 | return 0; |
| 3205 | } |
| 3206 | |
| 3207 | template <class T> |
| 3208 | int TosaReference::TensorTemplate<T>::dumpTensor(FILE* out) const |
| 3209 | { |
| 3210 | return 0; |
| 3211 | } |
| 3212 | |
| 3213 | // template explicit specialization |
| 3214 | template class TosaReference::TensorTemplate<Eigen::Tensor<float, 0>>; |
| 3215 | template class TosaReference::TensorTemplate<Eigen::Tensor<float, 1>>; |
| 3216 | template class TosaReference::TensorTemplate<Eigen::Tensor<float, 2>>; |
| 3217 | template class TosaReference::TensorTemplate<Eigen::Tensor<float, 3>>; |
| 3218 | template class TosaReference::TensorTemplate<Eigen::Tensor<float, 4>>; |
| 3219 | template class TosaReference::TensorTemplate<Eigen::Tensor<float, 5>>; |
| 3220 | template class TosaReference::TensorTemplate<Eigen::Tensor<float, 6>>; |
| 3221 | |
| 3222 | template class TosaReference::TensorTemplate<Eigen::Tensor<int32_t, 0>>; |
| 3223 | template class TosaReference::TensorTemplate<Eigen::Tensor<int32_t, 1>>; |
| 3224 | template class TosaReference::TensorTemplate<Eigen::Tensor<int32_t, 2>>; |
| 3225 | template class TosaReference::TensorTemplate<Eigen::Tensor<int32_t, 3>>; |
| 3226 | template class TosaReference::TensorTemplate<Eigen::Tensor<int32_t, 4>>; |
| 3227 | template class TosaReference::TensorTemplate<Eigen::Tensor<int32_t, 5>>; |
| 3228 | template class TosaReference::TensorTemplate<Eigen::Tensor<int32_t, 6>>; |
| 3229 | |
| 3230 | template class TosaReference::TensorTemplate<Eigen::Tensor<int64_t, 0>>; |
| 3231 | template class TosaReference::TensorTemplate<Eigen::Tensor<int64_t, 1>>; |
| 3232 | template class TosaReference::TensorTemplate<Eigen::Tensor<int64_t, 2>>; |
| 3233 | template class TosaReference::TensorTemplate<Eigen::Tensor<int64_t, 3>>; |
| 3234 | template class TosaReference::TensorTemplate<Eigen::Tensor<int64_t, 4>>; |
| 3235 | template class TosaReference::TensorTemplate<Eigen::Tensor<int64_t, 5>>; |
| 3236 | template class TosaReference::TensorTemplate<Eigen::Tensor<int64_t, 6>>; |
| 3237 | |
| 3238 | template class TosaReference::TensorTemplate<Eigen::Tensor<bool, 0>>; |
| 3239 | template class TosaReference::TensorTemplate<Eigen::Tensor<bool, 1>>; |
| 3240 | template class TosaReference::TensorTemplate<Eigen::Tensor<bool, 2>>; |
| 3241 | template class TosaReference::TensorTemplate<Eigen::Tensor<bool, 3>>; |
| 3242 | template class TosaReference::TensorTemplate<Eigen::Tensor<bool, 4>>; |
| 3243 | template class TosaReference::TensorTemplate<Eigen::Tensor<bool, 5>>; |
| 3244 | template class TosaReference::TensorTemplate<Eigen::Tensor<bool, 6>>; |