blob: d2a89da2665c4d81f621a1ba7855930638ac1d3c [file] [log] [blame]
evacha019c96eef2024-02-07 11:21:55 +00001// Copyright (c) 2024, ARM Limited.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include "generate_full_range.h"
16#include "half.hpp"
17
18namespace
19{
20
21template <typename DataType>
22bool generate(const TosaReference::GenerateConfig& cfg, DataType* data, size_t size)
23{
24 const TosaReference::FullRangeInfo& frinfo = cfg.fullRangeInfo;
25 DataType value = frinfo.startVal;
26
27 const auto T = TosaReference::numElementsFromShape(cfg.shape);
28 for (auto t = 0; t < T; ++t)
29 {
30 data[t] = value;
31 value++;
32 }
33 return true;
34}
35} // namespace
36
37namespace TosaReference
38{
39bool generateFullRange(const GenerateConfig& cfg, void* data, size_t size)
40{
41 // Check we support the operator
42 if (cfg.opType == Op::Op_UNKNOWN)
43 {
44 WARNING("[Generator][PR] Unknown operator.");
45 return false;
46 }
47
48 switch (cfg.dataType)
49 {
50 case DType::DType_FP16: {
51 uint16_t* outData = reinterpret_cast<uint16_t*>(data);
52 return generate(cfg, outData, size);
53 }
54 default:
55 WARNING("[Generator][PR] Unsupported type.");
56 return false;
57 }
58}
59} // namespace TosaReference