2 // Copyright (c) 2016 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "softmax_inst.h"
18 #include "primitive_type_base.h"
19 #include "json_object.h"
23 primitive_type_id softmax_type_id()
25 static primitive_type_base<softmax> instance;
29 layout softmax_inst::calc_output_layout(softmax_node const& node)
31 assert((bool)node.get_primitive()->output_data_type == false
32 && "Output data type forcing is not supported for softmax_node!");
33 return node.input().get_output_layout();
36 std::string softmax_inst::to_string(softmax_node const& node)
38 auto desc = node.get_primitive();
39 auto node_info = node.desc_to_json();
41 std::stringstream primitive_description;
43 node_info->dump(primitive_description);
45 return primitive_description.str();
48 softmax_inst::typed_primitive_inst(network_impl& network, softmax_node const& node)
49 : parent(network, node)
51 // auto& input_offset = arg.input_offset;
52 // auto& output_offset = arg.output_offset;
53 // auto& output_size = arg.output_size;
55 // auto& input_inst = arg.input[0].primitive().as<const memory&>().argument;
56 // auto& output_inst = arg.output[0].as<const memory&>().argument;
57 // for (auto &x : input_offset.raw) if (x < 0) throw std::runtime_error("Softmax negative input offset.");
59 // for(size_t i = 0; i < input_inst.size.raw.size(); ++i) {
60 // if( input_inst.size.raw[i] < output_size.raw[i] + input_offset.raw[i]) throw std::runtime_error("Softmax input/output size does not match.");
61 // if(output_inst.size.raw[i] < output_size.raw[i] + output_offset.raw[i]) throw std::runtime_error("Softmax sizes too small.");
64 //auto& input_inst = network.get_topology()->get_primitives().at(desc->input()[0]);
65 //if (input_inst->output_layout->size.format == cldnn::format::bfyx)
66 // if (input_inst->output_layout->size.spatial[0] != 1 || input_inst->output_layout->size.spatial[1] != 1)
67 // throw std::runtime_error("Softmax input has more than one dimension per batch");