| 
									
										
										
										
											2020-11-05 16:41:56 +08:00
										 |  |  | //
 | 
					
						
							|  |  |  | //  ShapeRandomUniform.cpp
 | 
					
						
							|  |  |  | //  MNN
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //  Created by MNN on 2020/8/14.
 | 
					
						
							|  |  |  | //  Copyright © 2018, Alibaba Group Holding Limited
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "core/Macro.h"
 | 
					
						
							|  |  |  | #include "shape/SizeComputer.hpp"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace MNN { | 
					
						
							| 
									
										
										
										
											2021-04-28 18:02:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-05 16:41:56 +08:00
										 |  |  | class RandomUniformComputer : public SizeComputer { | 
					
						
							| 
									
										
										
										
											2021-04-28 18:02:10 +08:00
										 |  |  |     virtual bool onComputeSize(const MNN::Op *op, const std::vector<Tensor*>& inputs, | 
					
						
							| 
									
										
										
										
											2020-11-05 16:41:56 +08:00
										 |  |  |                                const std::vector<Tensor*>& outputs) const override { | 
					
						
							|  |  |  |         MNN_ASSERT(1 == outputs.size()); | 
					
						
							| 
									
										
										
										
											2021-04-28 18:02:10 +08:00
										 |  |  |         auto param = op->main_as_RandomUniform(); | 
					
						
							|  |  |  |         outputs[0]->setType(param->type()); | 
					
						
							|  |  |  |         auto &output = outputs[0]->buffer(); | 
					
						
							|  |  |  |         auto shapePtr = inputs[0]->host<int>(); | 
					
						
							|  |  |  |         output.dimensions = inputs[0]->elementSize(); | 
					
						
							|  |  |  |         for (int i = 0; i < outputs[0]->dimensions(); i++) { | 
					
						
							|  |  |  |             output.dim[i].extent = shapePtr[i]; | 
					
						
							| 
									
										
										
										
											2020-11-05 16:41:56 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-04-28 18:02:10 +08:00
										 |  |  |         TensorUtils::setLinearLayout(outputs[0]); | 
					
						
							| 
									
										
										
										
											2020-11-05 16:41:56 +08:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | REGISTER_SHAPE_INPUTS(RandomUniformComputer, OpType_RandomUniform, {0}); | 
					
						
							| 
									
										
										
										
											2022-01-04 10:50:40 +08:00
										 |  |  | REGISTER_SHAPE_INPUTS(RandomUniformComputer, OpType_RandomNormal, {0}); | 
					
						
							| 
									
										
										
										
											2020-11-05 16:41:56 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace MNN
 |