Commit f0ce2244 authored by Adam Procter's avatar Adam Procter

De-Eigenize not

parent 21d4e6e3
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
namespace ngraph
{
namespace runtime
{
namespace kernel
{
void logical_not(char* arg, char* out, size_t count) // FIXME: temporararily char not bool
{
for (size_t i = 0; i < count; i++)
{
out[i] = !(arg[i]);
}
}
}
}
}
......@@ -105,7 +105,7 @@
#include "ngraph/runtime/ngvm/instruction/minimum.hpp"
#include "ngraph/runtime/ngvm/instruction/multiply.hpp"
#include "ngraph/runtime/ngvm/instruction/negate.hpp"
#include "ngraph/runtime/ngvm/eigen/not.hpp"
#include "ngraph/runtime/ngvm/instruction/not.hpp"
#include "ngraph/runtime/ngvm/instruction/not_equal.hpp"
#include "ngraph/runtime/ngvm/instruction/power.hpp"
#include "ngraph/runtime/ngvm/eigen/reduce_matrix_columns.hpp"
......@@ -399,6 +399,8 @@ ExternalFunction::OpMap& ExternalFunction::get_op_map()
REGISTER_POLYMORPHIC_BINOP(op::Less, instruction::LessInstruction);
REGISTER_POLYMORPHIC_BINOP(op::LessEq, instruction::LessEqInstruction);
REGISTER_LOGICAL_UNOP(op::Not, instruction::NotInstruction);
REGISTER_POLYMORPHIC_TERNOP(op::Select, instruction::SelectInstruction);
REGISTER_CONSTANT_INSTRUCTIONS(element::Bool);
......@@ -410,8 +412,6 @@ ExternalFunction::OpMap& ExternalFunction::get_op_map()
REGISTER_CONSTANT_INSTRUCTIONS(element::UInt32);
REGISTER_CONSTANT_INSTRUCTIONS(element::UInt64);
REGISTER_LOGICAL_UNOP(op::Not, eigen::NotInstruction);
REGISTER_TO_OP_MAP(op::Broadcast)
{
auto broadcast = static_cast<const op::Broadcast*>(n);
......
......@@ -14,8 +14,9 @@
#pragma once
#include "ngraph/runtime/kernel/not.hpp"
#include "ngraph/runtime/ngvm/call_frame.hpp"
#include "ngraph/runtime/ngvm/eigen/utils.hpp"
#include "ngraph/runtime/ngvm/utils.hpp"
#include "ngraph/runtime/ngvm/instruction.hpp"
#include "ngraph/runtime/tensor_view.hpp"
......@@ -25,12 +26,13 @@ namespace ngraph
{
namespace ngvm
{
namespace eigen
namespace instruction
{
class NotInstruction : public Instruction
{
public:
NotInstruction(TensorViewInfo arg, TensorViewInfo out)
NotInstruction(const TensorViewInfo& arg,
const TensorViewInfo& out)
: m_arg(arg)
, m_out(out)
{
......@@ -38,13 +40,12 @@ namespace ngraph
virtual void execute(CallFrame& call_frame) const override
{
// This is a bit frustrating. We have to cast the Eigen
// matrix to a real bool, negate that, then cast that
// back to our storage representation (ultimately char).
EigenArray1d<element::Bool>(call_frame, m_out) =
(!(EigenArray1d<element::Bool>(call_frame, m_arg)
.template cast<bool>()))
.template cast<element::Bool::type>();
char* arg = get_tensor_data_ptr<element::Bool>(call_frame, m_arg); // FIXME: temporarily char not bool
char* out = get_tensor_data_ptr<element::Bool>(call_frame, m_out); // FIXME: temporarily char not bool
size_t count = get_tensor_element_count(call_frame, m_arg);
kernel::logical_not(arg, out, count);
}
protected:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment