From 6940dd720ebb6b3d1df8ca203ab696daefe58189 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Fri, 20 Mar 2020 12:25:56 +0000 Subject: renamed Documentation folder 20.02 and added .nojekyll file Signed-off-by: Jim Flynn --- 20.02/_convert_constants_8hpp_source.xhtml | 147 +++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 20.02/_convert_constants_8hpp_source.xhtml (limited to '20.02/_convert_constants_8hpp_source.xhtml') diff --git a/20.02/_convert_constants_8hpp_source.xhtml b/20.02/_convert_constants_8hpp_source.xhtml new file mode 100644 index 0000000000..bf0351e98c --- /dev/null +++ b/20.02/_convert_constants_8hpp_source.xhtml @@ -0,0 +1,147 @@ + + + + + + + + + + + + + +ArmNN: src/armnn/optimizations/ConvertConstants.hpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
ConvertConstants.hpp
+
+
+Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include "Optimization.hpp"
9 
11 
13 
15 
16 #include <Half.hpp>
17 
18 namespace armnn
19 {
20 namespace optimizations
21 {
22 
24 {
25  static void Func(std::unique_ptr<ScopedCpuTensorHandle>& handle)
26  {
27  const TensorInfo& info = handle->GetTensorInfo();
28 
29  if (info.GetDataType() == DataType::Float16)
30  {
31  std::vector<float> newValues(info.GetNumElements());
32 
34  info.GetNumElements(),
35  newValues.data());
36 
37  TensorInfo newInfo(info.GetShape(), DataType::Float32);
38  ConstTensor newInput(newInfo, newValues);
39  handle.reset(new ScopedCpuTensorHandle(newInput));
40  }
41  }
42 };
43 
45 {
46  static void Func(std::unique_ptr<ScopedCpuTensorHandle>& handle)
47  {
48  const TensorInfo& info = handle->GetTensorInfo();
49 
50  if (info.GetDataType() == DataType::Float32)
51  {
52  std::vector<Half> newValues(info.GetNumElements());
53 
55  info.GetNumElements(),
56  newValues.data());
57 
58  TensorInfo newInfo(info.GetShape(), DataType::Float16);
59  ConstTensor newInput(newInfo, newValues);
60  handle.reset(new ScopedCpuTensorHandle(newInput));
61  }
62  }
63 };
64 
65 template<typename Converter, typename Predicate>
67 {
68 public:
69  ConvertConstants() = default;
70  ConvertConstants(const ConvertConstants&) = default;
71  virtual ~ConvertConstants() = default;
72 
73  void Run(Graph& graph, Layer& layer) const override
74  {
75  IgnoreUnused(graph);
76  if (Predicate::Test(layer))
77  {
78  layer.OperateOnConstantTensors(Converter::Func);
79  }
80  }
81 protected:
82 };
83 
85 {
86  static bool Test(const Layer& layer)
87  {
88  return layer.GetDataType() == DataType::Float32;
89  }
90 };
91 
93 {
94  static bool Test(const Layer& layer)
95  {
96  return layer.GetDataType() == DataType::Float16;
97  }
98 };
99 
102 
103 } //namespace optimizations
104 } //namespace armnn
+ +
static bool Test(const Layer &layer)
+ +
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
+ + +
static bool Test(const Layer &layer)
+
void OperateOnConstantTensors(Op op)
Definition: Layer.hpp:292
+
static void Func(std::unique_ptr< ScopedCpuTensorHandle > &handle)
+
Copyright (c) 2020 ARM Limited.
+
void IgnoreUnused(Ts &&...)
+
static void Func(std::unique_ptr< ScopedCpuTensorHandle > &handle)
+ +
DataType GetDataType() const
Definition: Tensor.hpp:95
+ +
static void ConvertFloat32To16(const float *srcFloat32Buffer, size_t numElements, void *dstFloat16Buffer)
Converts a buffer of FP32 values to FP16, and stores in the given dstFloat16Buffer.
+
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:199
+ + +
static void ConvertFloat16To32(const void *srcFloat16Buffer, size_t numElements, float *dstFloat32Buffer)
+
void Run(Graph &graph, Layer &layer) const override
+ + + + + +
DataType GetDataType() const
Definition: Layer.cpp:273
+ + +
half_float::half Half
Definition: Half.hpp:16
+ + +
unsigned int GetNumElements() const
Definition: Tensor.hpp:93
+
+
+ + + + -- cgit v1.2.1