2019-11-21 11:31:20 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2019 Konduit K.K.
|
|
|
|
*
|
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
* terms of the Apache License, Version 2.0 which is available at
|
|
|
|
* https://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 limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
//
|
|
|
|
// @author raver119@gmail.com
|
|
|
|
//
|
|
|
|
|
2020-03-02 10:49:41 +01:00
|
|
|
#include <system/op_boilerplate.h>
|
2019-11-21 11:31:20 +01:00
|
|
|
#if NOT_EXCLUDED(OP_shapes_of)
|
|
|
|
|
|
|
|
#include <ops/declarable/CustomOperations.h>
|
|
|
|
|
2020-03-02 10:49:41 +01:00
|
|
|
namespace sd {
|
2019-11-21 11:31:20 +01:00
|
|
|
namespace ops {
|
2019-12-02 19:37:21 +01:00
|
|
|
|
2019-11-21 11:31:20 +01:00
|
|
|
CUSTOM_OP_IMPL(create, 1, 1, false, 0, 1) {
|
|
|
|
auto init = block.numB() > 0 ? B_ARG(0) : true;
|
|
|
|
|
|
|
|
if (init)
|
|
|
|
OUTPUT_VARIABLE(0)->nullify();
|
|
|
|
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
DECLARE_SHAPE_FN(create) {
|
|
|
|
auto shapeInput = INPUT_VARIABLE(0);
|
|
|
|
auto order = (char) INT_ARG(0);
|
|
|
|
auto dtype = DataTypeUtils::fromInt(INT_ARG(1));
|
|
|
|
|
|
|
|
REQUIRE_TRUE(order == 'c' || order == 'f', 0, "create: order must be either c or f");
|
|
|
|
|
|
|
|
auto shape = shapeInput->getBufferAsVector<Nd4jLong>();
|
|
|
|
|
2020-06-06 14:26:55 +02:00
|
|
|
return SHAPELIST(sd::ConstantShapeHelper::getInstance().createShapeInfo(dtype, order, shape));
|
2019-11-21 11:31:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DECLARE_TYPES(create) {
|
|
|
|
getOpDescriptor()
|
|
|
|
->setAllowedInputTypes({ALL_INTS})
|
2020-03-02 10:49:41 +01:00
|
|
|
->setAllowedOutputTypes(sd::DataType::ANY);
|
2019-11-21 11:31:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|