text
stringlengths
0
2.2M
void TemplateUtil::init(void *ddlibr) {
ddlib = ddlibr;
}
TemplatePtr TemplateUtil::getTemplateFunc(const std::string& appName, const std::string& tpe) {
std::string tpeFname = CommonUtils::getTpeFnName(tpe, appName);
return (TemplatePtr)dlsym(ddlib, tpeFname.c_str());
}
// bslma_deallocatorguard.cpp -*-C++-*-
#include <bslma_deallocatorguard.h>
#include <bsls_ident.h>
BSLS_IDENT("$Id$ $CSID$")
#include <bslma_default.h> // for testing
#include <bslma_testallocator.h> // for testing
// ----------------------------------------------------------------------------
// Copyright 2013 Bloomberg Finance L.P.
//
// 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
// limitations under the License.
// ----------------------------- END-OF-FILE ----------------------------------
#include <torch/csrc/lazy/core/view_ops/permute.h>
#include <torch/csrc/lazy/core/helpers.h>
namespace torch {
namespace lazy {
Permute::Permute(const Value& input, std::vector<int64_t> dims)
: TsNode(
OpKind(at::aten::permute),
{input},
/*num_outputs=*/1,
MHash(dims)),
dims_(std::move(dims)) {
SetShapeDeferred([&]() {
return MakePermuteShape(GetShapeFromTsOutput(operand(0)), dims_);
});
}
std::string Permute::ToString() const {
std::stringstream ss;
ss << TsNode::ToString() << ", dims=(" << c10::Join(", ", dims_) << ")";
return ss.str();
}
Shape Permute::MakePermuteShape(
const Shape& source_shape,
c10::ArrayRef<int64_t> permutation) {
return Shape(
source_shape.scalar_type(),
PermuteDimensions(permutation, source_shape.sizes()));
}
} // namespace lazy
} // namespace torch
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <stdexcept>
#include "flashlight/fl/meter/MSEMeter.h"
namespace fl {
MSEMeter::MSEMeter() {
reset();
}
void MSEMeter::reset() {
curN_ = 0;
curValue_ = .0;
}
void MSEMeter::add(const af::array& output, const af::array& target) {
if (output.dims() != target.dims()) {
throw std::invalid_argument("dimension mismatch in MSEMeter");
}
++curN_;